#
966f24e5 |
| 17-Jan-2022 |
Cameron Mulhern <csmulhern@gmail.com> |
[clang-format] Add a BlockIndent option to AlignAfterOpenBracket
This style is similar to AlwaysBreak, but places closing brackets on new lines.
For example, if you have a multiline parameter list,
[clang-format] Add a BlockIndent option to AlignAfterOpenBracket
This style is similar to AlwaysBreak, but places closing brackets on new lines.
For example, if you have a multiline parameter list, clang-format currently only supports breaking per-parameter, but places the closing bracket on the line of the last parameter.
Function( param1, param2, param3);
A style supported by other code styling tools (e.g. rustfmt) is to allow the closing brackets to be placed on their own line, aiding the user in being able to quickly infer the bounds of the block of code.
Function( param1, param2, param3 );
For prior work on a similar feature, see: https://reviews.llvm.org/D33029.
Note: This currently only supports block indentation for closing parentheses.
Differential Revision: https://reviews.llvm.org/D109557
show more ...
|
#
533fbae8 |
| 13-Dec-2021 |
Owen Pan <owenpiano@gmail.com> |
[clang-format] Add experimental option to remove LLVM braces
See the style examples at: https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-
[clang-format] Add experimental option to remove LLVM braces
See the style examples at: https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
Differential Revision: https://reviews.llvm.org/D116316
show more ...
|
#
7af11989 |
| 14-Jan-2022 |
Marek Kurdej <marek.kurdej+llvm.org@gmail.com> |
[clang-format] Fix short functions being considered as inline inside an indented namespace.
Fixes https://github.com/llvm/llvm-project/issues/24784.
With config: ``` AllowShortFunctionsOnASingleLin
[clang-format] Fix short functions being considered as inline inside an indented namespace.
Fixes https://github.com/llvm/llvm-project/issues/24784.
With config: ``` AllowShortFunctionsOnASingleLine: Inline NamespaceIndentation: All ```
The code: ``` namespace Test { void f() { return; } } ``` was incorrectly formatted to: ``` namespace Test { void f() { return; } } ```
since the function `f` was considered being inside a class/struct/record. That's because the check was simplistic and only checked for a non-zero indentation level of the line starting `f`.
Reviewed By: MyDeveloperDay, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D117142
show more ...
|
#
6ea3d9ef |
| 14-Jan-2022 |
Marek Kurdej <marek.kurdej+llvm.org@gmail.com> |
[clang-format] Fix CompactNamespaces corner case when AllowShortLambdasOnASingleLine/BraceWrapping.BeforeLambdaBody are set
In clang-format 12, `CompactNamespaces` misformatted the code when `AllowS
[clang-format] Fix CompactNamespaces corner case when AllowShortLambdasOnASingleLine/BraceWrapping.BeforeLambdaBody are set
In clang-format 12, `CompactNamespaces` misformatted the code when `AllowShortLambdasOnASingleLine` is set to false and `BraceWrapping.BeforeLambdaBody` is true.
Input: ``` namespace out { namespace in { } } // namespace out::in ```
Expected output: ``` namespace out { namespace in { }} // namespace out::in ```
Output from v12: ``` namespace out { namespace in { } } // namespace out::in ```
Config triggering the issue: ``` --- AllowShortLambdasOnASingleLine: None BraceWrapping: BeforeLambdaBody : true BreakBeforeBraces: Custom CompactNamespaces: true ... ```
Seems there's a corner case when `AllowShortLambdasOnASingleLine` is false, and `BraceWrapping.BeforeLambdaBody` is true, that causes CompactNamespaces to stop working. The cause was a misannotation of `{` opening brace after `namespace` as a lambda opening brace. The regression was probably introduced with [this commit](https://github.com/llvm/llvm-project/commit/fa0118e6e588fe303b08e7e06ba28ac1f8d50c68).
Originally contributed by Ahmed Mahdy (@aybassiouny). Thank you!
Reviewed By: Wawha, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D99031
show more ...
|
#
6a4957cb |
| 14-Jan-2022 |
Marek Kurdej <marek.kurdej+llvm.org@gmail.com> |
[clang-format] Add missing test for loops formatting. NFC.
The case with an inner while loop wasn't tested before. Same for outer loop with a ForeachMacro.
|
#
cd3ab156 |
| 14-Jan-2022 |
Marek Kurdej <marek.kurdej+llvm.org@gmail.com> |
[clang-format] Fix typos in test. NFC.
|
#
3cf86c36 |
| 14-Jan-2022 |
Marek Kurdej <marek.kurdej+llvm.org@gmail.com> |
Revert unrelated change from: [clang-format] Fix break being added to macro define with ColumnLimit: 0
|
#
47a9eb21 |
| 13-Jan-2022 |
Armen Khachkinaev <armen114@yandex.ru> |
[clang-format] Fix break being added to macro define with ColumnLimit: 0
Fix for #[[ https://github.com/llvm/llvm-project/issues/49164 | 49164 ]] issue.
Reviewed By: MyDeveloperDay, HazardyKnusperk
[clang-format] Fix break being added to macro define with ColumnLimit: 0
Fix for #[[ https://github.com/llvm/llvm-project/issues/49164 | 49164 ]] issue.
Reviewed By: MyDeveloperDay, HazardyKnusperkeks, curdeius, owenpan
Differential Revision: https://reviews.llvm.org/D116859
show more ...
|
#
7ee42367 |
| 13-Jan-2022 |
mydeveloperday <mydeveloperday@gmail.com> |
[clang-format] clang-format eats space in front of attributes for operator delete
https://github.com/llvm/llvm-project/issues/27037
Sorry its taken so long to get to this issue! (got it before it h
[clang-format] clang-format eats space in front of attributes for operator delete
https://github.com/llvm/llvm-project/issues/27037
Sorry its taken so long to get to this issue! (got it before it hit its 6th birthday!)
``` void operator delete(void *foo)ATTRIB; ```
(void *foo) is incorrectly determined to be a C-Style Cast resulting in the space being removed after the ) and before the attrib, due to the detection of
``` delete (A* )a; ```
The following was previously unaffected
``` void operator new(void *foo) ATTRIB; ```
Fixes #27037
Reviewed By: curdeius, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D116920
show more ...
|
#
5c2e7c9c |
| 10-Jan-2022 |
mydeveloperday <mydeveloperday@gmail.com> |
[clang-format] Ensure we can correctly parse lambda in the template argument list
https://github.com/llvm/llvm-project/issues/46505
The presence of a lambda in an argument template list ignored the
[clang-format] Ensure we can correctly parse lambda in the template argument list
https://github.com/llvm/llvm-project/issues/46505
The presence of a lambda in an argument template list ignored the [] as a lambda at all, this caused the contents of the <> to be incorrectly analyzed.
``` struct Y : X < [] { return 0; } > {}; ``` Fixes: #46505
Reviewed By: curdeius
Differential Revision: https://reviews.llvm.org/D116806
show more ...
|
#
49d31187 |
| 06-Jan-2022 |
mydeveloperday <mydeveloperday@gmail.com> |
[clang-format] Missing space after cast in a macro
https://github.com/llvm/llvm-project/issues/52979
Though SpaceAfterCStyleCast is set to true, clang-format 13 does not add a space after (void *)
[clang-format] Missing space after cast in a macro
https://github.com/llvm/llvm-project/issues/52979
Though SpaceAfterCStyleCast is set to true, clang-format 13 does not add a space after (void *) here:
``` ```
This patch addresses that
Fixes: #52979
Reviewed By: curdeius, HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D116592
show more ...
|
#
5109737c |
| 05-Jan-2022 |
Marek Kurdej <marek.kurdej+llvm.org@gmail.com> |
[clang-format] Fix indentation for array variables with alignment of consecutive assignments and declarations.
Fixes https://github.com/llvm/llvm-project/issues/52914.
Reviewed By: HazardyKnusperke
[clang-format] Fix indentation for array variables with alignment of consecutive assignments and declarations.
Fixes https://github.com/llvm/llvm-project/issues/52914.
Reviewed By: HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D116527
show more ...
|
#
da6b0d0b |
| 04-Jan-2022 |
Rajat Bajpai <rb.macboy@gmail.com> |
[clang-format] Add an option to add a space between operator overloading and opening parentheses
This change adds an option AfterOverloadedOperator in SpaceBeforeParensOptions to add a space between
[clang-format] Add an option to add a space between operator overloading and opening parentheses
This change adds an option AfterOverloadedOperator in SpaceBeforeParensOptions to add a space between overloaded operator and opening parentheses in clang-format.
Reviewed By: MyDeveloperDay, curdeius, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D116283
show more ...
|
#
e2b6e21f |
| 03-Jan-2022 |
Marek Kurdej <marek.kurdej+llvm.org@gmail.com> |
[clang-format] Fix incorrect formatting of lambdas inside brace initialisation
Fixes https://github.com/llvm/llvm-project/issues/27146. Fixes https://github.com/llvm/llvm-project/issues/52943.
Befo
[clang-format] Fix incorrect formatting of lambdas inside brace initialisation
Fixes https://github.com/llvm/llvm-project/issues/27146. Fixes https://github.com/llvm/llvm-project/issues/52943.
Before:
``` namespace ns {
void foo() { std::variant<int, double> v; std::visit(overloaded{[](auto &&) -> int (*)[] { return nullptr; }}, v); }
} // namespace ns
int break_me() { int x = 42; return int{[x = x]() { return x; }()}; } ```
got formatted as: ``` namespace ns {
void foo() { std::variant<int, double> v; std::visit(overloaded{[](auto &&) -> int (*)[] { return nullptr; } } // namespace ns , v); }
} // namespace ns
int break_me() { int x = 42; return int{[x = x](){return x; } () } ; } ```
Reviewed By: HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D116553
show more ...
|
#
cfe31807 |
| 03-Jan-2022 |
G. Pery <gpery@pm.me> |
[clang-format] Add penalty for breaking after '('
My team has a vendetta against lines ending with an open parenthesis, thought it might be useful for others too
Reviewed By: HazardyKnusperkeks,
[clang-format] Add penalty for breaking after '('
My team has a vendetta against lines ending with an open parenthesis, thought it might be useful for others too
Reviewed By: HazardyKnusperkeks, curdeius
Differential Revision: https://reviews.llvm.org/D116170
show more ...
|
#
7972b2e4 |
| 03-Jan-2022 |
Michael Zimmermann <sigmaepsilon92@gmail.com> |
[clang-format] respect AfterEnum for enums
There is some similar looking code in `TokenAnnotator.cpp` but given that I've never worked on clang-format before I don't know what the purpose of that co
[clang-format] respect AfterEnum for enums
There is some similar looking code in `TokenAnnotator.cpp` but given that I've never worked on clang-format before I don't know what the purpose of that code is and how it's related to `UnwrappedLineParser.cpp`.
Either way, it fixes clang-format with `BraceWrapping.AfterEnum=true` and `AllowShortEnumsOnASingleLine=false` to behave like the documentation says.
Before this patch: ``` enum { A, B } myEnum; ```
After this patch: ``` enum { A, B } myEnum; ```
According to the unittests which I had to modify this would change the LLVM style. Please evaluate if you want to change the defaults or if you consider the current style a bug.
Reviewed By: curdeius, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D106349
show more ...
|
#
cd2b050f |
| 03-Jan-2022 |
mydeveloperday <mydeveloperday@gmail.com> |
[clang-format] spacesRequiredBetween is not honouring clang-format off/on
https://github.com/llvm/llvm-project/issues/52881
It seems that clang-format off/on is not being honoured in regard to addi
[clang-format] spacesRequiredBetween is not honouring clang-format off/on
https://github.com/llvm/llvm-project/issues/52881
It seems that clang-format off/on is not being honoured in regard to adding spaces.
My understanding of clang-format off/on is that it marks the token as finalized based on whether formatting is currently enabled or disabled.
This was causing a space to be added between the `<` and `<<` in the Cuda kernel `foo<<<1, 1>>>();`
This if doesn't solve this actual issue but ensure that clang-format is at least honoured.
Reviewed By: curdeius, owenpan
Differential Revision: https://reviews.llvm.org/D116494
show more ...
|
#
b9e173fc |
| 03-Jan-2022 |
Zhao Wei Liew <zhaoweiliew@gmail.com> |
[clang-format] Add option to explicitly specify a config file
This diff extends the -style=file option to allow a config file to be specified explicitly. This is useful (for instance) when adding ID
[clang-format] Add option to explicitly specify a config file
This diff extends the -style=file option to allow a config file to be specified explicitly. This is useful (for instance) when adding IDE commands to reformat code to a personal style.
Usage: `clang-format -style=file:<path/to/config/file> ...`
Reviewed By: HazardyKnusperkeks, curdeius, MyDeveloperDay, zwliew
Differential Revision: https://reviews.llvm.org/D72326
show more ...
|
#
0090cd4e |
| 03-Jan-2022 |
Zhao Wei Liew <zhaoweiliew@gmail.com> |
[clang-format] Support inheriting from more than 1 parents in the fallback case
Currently, we are unable to inherit from a chain of parent configs where the outermost parent config has `BasedOnStyle
[clang-format] Support inheriting from more than 1 parents in the fallback case
Currently, we are unable to inherit from a chain of parent configs where the outermost parent config has `BasedOnStyle: InheritParentConfig` set. This patch adds a test case for this scenario, and adds support for it.
To illustrate, suppose we have the following directory structure: ``` - e/ |- .clang-format (BasedOnStyle: InheritParentConfig) <-- outermost config |- sub/ |- .clang-format (BasedOnStyle: InheritParentConfig) |- sub/ |- .clang-format (BasedOnStyle: InheritParentConfig) |- code.cpp ``` Now consider what happens when we run `clang-format --style=file /e/sub/sub/code.cpp`.
Without this patch, on a release build, only the innermost config will be applied. On a debug build, clang-format crashes due to an assertion failure. With this patch, clang-format behaves as we'd expect, applying all 3 configs.
Reviewed By: HazardyKnusperkeks, curdeius
Differential Revision: https://reviews.llvm.org/D116371
show more ...
|
#
ab0bfbda |
| 03-Jan-2022 |
Marek Kurdej <marek.kurdej+llvm.org@gmail.com> |
[clang-format] Use get*StyleWithColumns helper. NFC.
|
#
8ea64d55 |
| 24-Dec-2021 |
Gabriel Smith <ga29smith@gmail.com> |
[clang-format] Fix short enums getting wrapped even when denied
Single-variant enums were still getting placed on a single line even when AllowShortEnumsOnASingleLine was false. This fixes that by c
[clang-format] Fix short enums getting wrapped even when denied
Single-variant enums were still getting placed on a single line even when AllowShortEnumsOnASingleLine was false. This fixes that by checking that setting when looking to merge lines.
Differential Revision: https://reviews.llvm.org/D116188
show more ...
|
#
f66d602c |
| 22-Dec-2021 |
Marek Kurdej <marek.kurdej+llvm.org@gmail.com> |
[clang-format] Fix wrong indentation after trailing requires clause.
Fixes https://github.com/llvm/llvm-project/issues/52834.
Before this patch, clang-format would wrongly parse top-level entities
[clang-format] Fix wrong indentation after trailing requires clause.
Fixes https://github.com/llvm/llvm-project/issues/52834.
Before this patch, clang-format would wrongly parse top-level entities (e.g. namespaces) and format: ``` template<int I> constexpr void foo requires(I == 42) {} namespace ns { void foo() {} } // namespace ns ``` into: `````` template<int I> constexpr void foo requires(I == 42) {} namespace ns { void foo() {} } // namespace ns ``` with configuration: ``` NamespaceIndentation: None ````
Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D116183
show more ...
|
#
450ddddc |
| 21-Dec-2021 |
Marek Kurdej <marek.kurdej+llvm.org@gmail.com> |
[clang-format] Remove unnecessary qualifications. NFC.
|
#
36ea9861 |
| 21-Dec-2021 |
Marek Kurdej <marek.kurdej+llvm.org@gmail.com> |
[clang-format] Remove unnecessary qualifications. NFC.
|
#
07fe4513 |
| 21-Dec-2021 |
Marek Kurdej <marek.kurdej+llvm.org@gmail.com> |
[clang-format] Fix SplitEmptyRecord affecting SplitEmptyFunction.
Fixes https://github.com/llvm/llvm-project/issues/50051.
Given the style: ``` BraceWrapping AfterFunction: true SplitEmptyFuncti
[clang-format] Fix SplitEmptyRecord affecting SplitEmptyFunction.
Fixes https://github.com/llvm/llvm-project/issues/50051.
Given the style: ``` BraceWrapping AfterFunction: true SplitEmptyFunction: true SplitEmptyRecord: false ... ```
The code that should be like: ``` void f(int aaaaaaaaaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbbbbbbbbbbbbb) { } ```
gets the braces merged together: ``` void f(int aaaaaaaaaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbbbbbbbbbbbbb) {} ```
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D116049
show more ...
|