#
2e7add81 |
| 18-Sep-2020 |
mydeveloperday <mydeveloperday@gmail.com> |
[clang-format] Add a option for the position of Java static import
Some Java style guides and IDEs group Java static imports after non-static imports. This patch allows clang-format to control th
[clang-format] Add a option for the position of Java static import
Some Java style guides and IDEs group Java static imports after non-static imports. This patch allows clang-format to control the location of static imports.
Patch by: @bc-lee
Reviewed By: MyDeveloperDay, JakeMerdichAMD
Differential Revision: https://reviews.llvm.org/D87201
show more ...
|
#
40e771c1 |
| 17-Sep-2020 |
mydeveloperday <mydeveloperday@gmail.com> |
[clang-format][regression][PR47461] ifdef causes catch to be seen as a function
https://bugs.llvm.org/show_bug.cgi?id=47461
The following change {D80940} caused a regression in code which ifdef's a
[clang-format][regression][PR47461] ifdef causes catch to be seen as a function
https://bugs.llvm.org/show_bug.cgi?id=47461
The following change {D80940} caused a regression in code which ifdef's around the try and catch block cause incorrect brace placement around the catch
``` try { } catch (...) { // This is not a small function bar = 1; } } ```
The brace after the catch will be placed on a newline
Reviewed By: curdeius
Differential Revision: https://reviews.llvm.org/D87291
show more ...
|
#
c81dd3d1 |
| 08-Sep-2020 |
mydeveloperday <mydeveloperday@gmail.com> |
[clang-format] Handle shifts within conditions
In some situation shifts can be treated as a template, and is thus formatted as one. So, by doing a couple extra checks to assure that the condition do
[clang-format] Handle shifts within conditions
In some situation shifts can be treated as a template, and is thus formatted as one. So, by doing a couple extra checks to assure that the condition doesn't contain a template, and is in fact a bit shift should solve this problem.
This is a fix for [[ https://bugs.llvm.org/show_bug.cgi?id=46969 | bug 46969 ]]
Reviewed By: MyDeveloperDay
Patch By: Saldivarcher
Differential Revision: https://reviews.llvm.org/D86581
show more ...
|
#
05147d33 |
| 07-Sep-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Correctly parse function declarations with TypenameMacros
When using the always break after return type setting: Before: SomeType funcdecl(LIST(uint64_t)); After: SomeType funcdecl(LI
[clang-format] Correctly parse function declarations with TypenameMacros
When using the always break after return type setting: Before: SomeType funcdecl(LIST(uint64_t)); After: SomeType funcdecl(LIST(uint64_t));"
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D87007
show more ...
|
#
9a22eba1 |
| 07-Sep-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Parse __underlying_type(T) as a type
Before: MACRO(__underlying_type(A) * a); After: MACRO(__underlying_type(A) *a);
Reviewed By: MyDeveloperDay
Differential Revision: https://revi
[clang-format] Parse __underlying_type(T) as a type
Before: MACRO(__underlying_type(A) * a); After: MACRO(__underlying_type(A) *a);
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D86960
show more ...
|
#
56fa7d1d |
| 01-Sep-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Fix formatting of _Atomic() qualifier
Before: _Atomic(uint64_t) * a; After: _Atomic(uint64_t) *a;
This treats _Atomic the same as the the TypenameMacros and decltype. It also allows
[clang-format] Fix formatting of _Atomic() qualifier
Before: _Atomic(uint64_t) * a; After: _Atomic(uint64_t) *a;
This treats _Atomic the same as the the TypenameMacros and decltype. It also allows some cleanup by removing checks whether the token before a paren is kw_decltype and instead checking for TT_TypeDeclarationParen. While touching this code also extend the decltype test cases to also check for typeof() and _Atomic(T).
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D86959
show more ...
|
#
cd01eec1 |
| 07-Sep-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Check that */& after typename macros are pointers/references
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D86950
|
#
8aa3b8da |
| 07-Sep-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Handle typename macros inside cast expressions
Before: x = (STACK_OF(uint64_t)) & a; After: x = (STACK_OF(uint64_t))&a;
Reviewed By: MyDeveloperDay
Differential Revision: https://r
[clang-format] Handle typename macros inside cast expressions
Before: x = (STACK_OF(uint64_t)) & a; After: x = (STACK_OF(uint64_t))&a;
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D86930
show more ...
|
#
e7bd058c |
| 07-Sep-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Allow configuring list of macros that map to attributes
This adds a `AttributeMacros` configuration option that causes certain identifiers to be parsed like a __attribute__((foo)) ann
[clang-format] Allow configuring list of macros that map to attributes
This adds a `AttributeMacros` configuration option that causes certain identifiers to be parsed like a __attribute__((foo)) annotation. This is motivated by our CHERI C/C++ fork which adds a __capability qualifier for pointer/reference. Without this change clang-format parses many type declarations as multiplications/bitwise-and instead. I initially considered adding "__capability" as a new clang-format keyword, but having a list of macros that should be treated as attributes is more flexible since it can be used e.g. for static analyzer annotations or other language extensions.
Example: std::vector<foo * __capability> -> std::vector<foo *__capability>
Depends on D86775 (to apply cleanly)
Reviewed By: MyDeveloperDay, jrtc27
Differential Revision: https://reviews.llvm.org/D86782
show more ...
|
#
2108bcec |
| 04-Sep-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
FormatTest: Provide real line number in failure messages
Currently a test failure always reports a line number inside verifyFormat() which is not very helpful to see which test failed. With this cha
FormatTest: Provide real line number in failure messages
Currently a test failure always reports a line number inside verifyFormat() which is not very helpful to see which test failed. With this change we now emit the line number where the verify function was called. When using an IDE such as CLion, the output now includes a clickable link that points to the call site.
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D86926
show more ...
|
#
8c810acc |
| 04-Sep-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Parse __ptr32/__ptr64 as a pointer qualifier
Before: x = (foo *__ptr32) * v; MACRO(A * __ptr32 a); x = (foo *__ptr64) * v; MACRO(A * __ptr64 a);
After: x = (foo *__ptr32)*v; MACRO(A
[clang-format] Parse __ptr32/__ptr64 as a pointer qualifier
Before: x = (foo *__ptr32) * v; MACRO(A * __ptr32 a); x = (foo *__ptr64) * v; MACRO(A * __ptr64 a);
After: x = (foo *__ptr32)*v; MACRO(A *__ptr32 a); x = (foo *__ptr64)*v; MACRO(A *__ptr64 a);
Depends on D86721 (to apply cleanly)
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D86775
show more ...
|
#
d70e05c9 |
| 02-Sep-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Parse double-square attributes as pointer qualifiers
Before: x = (foo *[[clang::attr]]) * v; After: x = (foo *[[clang::attr]])*v;
Reviewed By: aaron.ballman
Differential Revision:
[clang-format] Parse double-square attributes as pointer qualifiers
Before: x = (foo *[[clang::attr]]) * v; After: x = (foo *[[clang::attr]])*v;
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D86721
show more ...
|
#
96824abe |
| 28-Aug-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Detect pointer qualifiers in cast expressions
When guessing whether a closing paren is then end of a cast expression also skip over pointer qualifiers while looking for TT_PointerOrRe
[clang-format] Detect pointer qualifiers in cast expressions
When guessing whether a closing paren is then end of a cast expression also skip over pointer qualifiers while looking for TT_PointerOrReference. This prevents some address-of and dereference operators from being parsed as a binary operator.
Before: x = (foo *const) * v; x = (foo *const volatile restrict __attribute__((foo)) _Nonnull _Null_unspecified _Nonnull) & v;
After: x = (foo *const)*v; x = (foo *const volatile restrict __attribute__((foo)) _Nonnull _Null_unspecified _Nonnull)&v;
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D86716
show more ...
|
#
d304360d |
| 28-Aug-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Parse nullability attributes as a pointer qualifier
Before: void f() { MACRO(A * _Nonnull a); } void f() { MACRO(A * _Nullable a); } void f() { MACRO(A * _Null_unspecified a); }
Afte
[clang-format] Parse nullability attributes as a pointer qualifier
Before: void f() { MACRO(A * _Nonnull a); } void f() { MACRO(A * _Nullable a); } void f() { MACRO(A * _Null_unspecified a); }
After: void f() { MACRO(A *_Nonnull a); } void f() { MACRO(A *_Nullable a); } void f() { MACRO(A *_Null_unspecified a); }
Reviewed By: JakeMerdichAMD
Differential Revision: https://reviews.llvm.org/D86713
show more ...
|
#
37cdabdb |
| 28-Aug-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Parse __attribute((foo)) as a pointer qualifier
Before: void f() { MACRO(A * __attribute((foo)) a); } After: void f() { MACRO(A *__attribute((foo)) a); }
Also check that the __attri
[clang-format] Parse __attribute((foo)) as a pointer qualifier
Before: void f() { MACRO(A * __attribute((foo)) a); } After: void f() { MACRO(A *__attribute((foo)) a); }
Also check that the __attribute__ alias is handled.
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D86711
show more ...
|
#
4f103695 |
| 28-Aug-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Parse restrict as a pointer qualifier
Before: void f() { MACRO(A * restrict a); } After: void f() { MACRO(A *restrict a); }
Also check that the __restrict and __restrict__ aliases a
[clang-format] Parse restrict as a pointer qualifier
Before: void f() { MACRO(A * restrict a); } After: void f() { MACRO(A *restrict a); }
Also check that the __restrict and __restrict__ aliases are handled.
Reviewed By: JakeMerdichAMD
Differential Revision: https://reviews.llvm.org/D86710
show more ...
|
#
1908da26 |
| 28-Aug-2020 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
[clang-format] Parse volatile as a pointer qualifier
Before: void f() { MACRO(A * volatile a); } After: void f() { MACRO(A *volatile a); }
Also check that the __volatile and __volatile__ aliases a
[clang-format] Parse volatile as a pointer qualifier
Before: void f() { MACRO(A * volatile a); } After: void f() { MACRO(A *volatile a); }
Also check that the __volatile and __volatile__ aliases are handled.
Reviewed By: JakeMerdichAMD
Differential Revision: https://reviews.llvm.org/D86708
show more ...
|
#
b18c63e8 |
| 11-Aug-2020 |
Maximilian Fickert <maximilian.fickert@gmail.com> |
[clang-format] use spaces for alignment of binary/ternary expressions with UT_AlignWithSpaces
Use spaces to align binary and ternary expressions when using AlignOperands and UT_AlignWithSpaces.
Thi
[clang-format] use spaces for alignment of binary/ternary expressions with UT_AlignWithSpaces
Use spaces to align binary and ternary expressions when using AlignOperands and UT_AlignWithSpaces.
This fixes an oversight in the new UT_AlignWithSpaces option (see D75034), which did not correctly identify the alignment of binary/ternary expressions.
Reviewed By: curdeius
Patch by: fickert
Differential Revision: https://reviews.llvm.org/D85600
show more ...
|
#
7ad60f64 |
| 05-Aug-2020 |
Mitchell Balan <mitchell@stellarscience.com> |
[clang-format] fix BreakBeforeBraces.MultiLine with for each macros Summary: The MultiLine option in BreakBeforeBraces was only handling standard control statement, leading to invalid indentation wit
[clang-format] fix BreakBeforeBraces.MultiLine with for each macros Summary: The MultiLine option in BreakBeforeBraces was only handling standard control statement, leading to invalid indentation with for each macros:
Previous behavior:
/* invalid: brace should be on the same line */ Q_FOREACH(int a; list) { foo(); }
/* valid */ Q_FOREACH(int longVariable; list) { foo(); }
To fix this, simply add the TT_ForEachMacro kind in the list of recognized control statements for the multiline option.
This is a fix for https://bugs.llvm.org/show_bug.cgi?id=44632
Reviewers: MyDeveloperDay, mitchell-stellar
Reviewed by: mitchell-stellar
Contributed by: vthib
Subscribers: cfe-commits
Tags: #clang, #clang-format, #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D85304
show more ...
|
Revision tags: llvmorg-11.0.0-rc1 |
|
#
52ab7aa0 |
| 18-Jul-2020 |
Anders Waldenborg <anders@0x63.nu> |
[clang-format] Add BitFieldColonSpacing option
This new option allows controlling if there should be spaces around the ':' in a bitfield declaration.
BitFieldColonSpacing accepts four different val
[clang-format] Add BitFieldColonSpacing option
This new option allows controlling if there should be spaces around the ':' in a bitfield declaration.
BitFieldColonSpacing accepts four different values:
// "Both" - default unsigned bitfield : 5 unsigned bf2 : 5 // AlignConsecutiveBitFields=true
// "None" unsigned bitfield:5 unsigned bf2 :5
// "Before" unsigned bitfield :5 unsigned bf2 :5
// "After" unsigned bitfield: 5 unsigned bf2 : 5
Differential Revision: https://reviews.llvm.org/D84090
show more ...
|
Revision tags: llvmorg-12-init |
|
#
65dc97b7 |
| 12-Jul-2020 |
mydeveloperday <mydeveloperday@gmail.com> |
[clang-format] PR46609 clang-format does not obey `PointerAlignment: Right` for ellipsis in declarator for pack
Summary: https://bugs.llvm.org/show_bug.cgi?id=46609
Ensure `*...` obey they left/mid
[clang-format] PR46609 clang-format does not obey `PointerAlignment: Right` for ellipsis in declarator for pack
Summary: https://bugs.llvm.org/show_bug.cgi?id=46609
Ensure `*...` obey they left/middle/right rules of Pointer alignment
Reviewed By: curdeius
Differential Revision: https://reviews.llvm.org/D83564
show more ...
|
Revision tags: llvmorg-10.0.1, llvmorg-10.0.1-rc4, llvmorg-10.0.1-rc3, llvmorg-10.0.1-rc2 |
|
#
0c332a77 |
| 26-Jun-2020 |
Jake Merdich <Jake.Merdich@amd.com> |
[clang-format] Preserve whitespace in selected macros
Summary: https://bugs.llvm.org/show_bug.cgi?id=46383
When the c preprocessor stringizes tokens, the generated string literals are affected by t
[clang-format] Preserve whitespace in selected macros
Summary: https://bugs.llvm.org/show_bug.cgi?id=46383
When the c preprocessor stringizes tokens, the generated string literals are affected by the whitespace. This means clang-format can affect codegen silently, adding spaces and newlines to strings. Practically speaking, the vast majority of cases will be harmless, only affecting single identifiers or debug macros.
In the interest of doing no harm in other cases though, this introduces a blacklist option 'WhitespaceSensitiveMacros', which contains a list of names of function-like macros whose contents should not be touched by clang-format, period. Clang-format can't automatically detect these without a real compile context, so users will have to specify it explicitly (it still beats clang-format off'ing at every invocation).
Defaults include "STRINGIZE", "PP_STRINGIZE", and "BOOST_PP_STRINGIZE".
Subscribers: kristof.beyls, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D82620
show more ...
|
#
eb50838b |
| 27-Jun-2020 |
mydeveloperday <mydeveloperday@gmail.com> |
[clang-format] [PR462254] fix indentation of default and break correctly in whitesmiths style
Summary: https://bugs.llvm.org/show_bug.cgi?id=46254
Reviewed By: curdeius, jbcoe
Differential Revisio
[clang-format] [PR462254] fix indentation of default and break correctly in whitesmiths style
Summary: https://bugs.llvm.org/show_bug.cgi?id=46254
Reviewed By: curdeius, jbcoe
Differential Revision: https://reviews.llvm.org/D8201
show more ...
|
#
0fad648b |
| 24-Jun-2020 |
Krasimir Georgiev <krasimir@google.com> |
[clang-format] restore indent in conditionals when AlignOperands is DontAlign
Summary: After D50078, we're experiencing unexpected un-indent using a style combining `AlignOperands: DontAlign` with `
[clang-format] restore indent in conditionals when AlignOperands is DontAlign
Summary: After D50078, we're experiencing unexpected un-indent using a style combining `AlignOperands: DontAlign` with `BreakBeforeTernaryOperators: false`, such as Google's JavaScript style: ``` % bin/clang-format -style=google ~/test.js aaaaaaaaaaa = bbbbbbbb ? cccccccccccccccccc() : dddddddddd ? eeeeeeeeeeeeee : fffff; ``` The issue lies with the interaction of `AlignOperands: DontAlign` and the edited code section in ContinuationIndenter.cpp, which de-dents the intent by `Style.ContinuationIndentWidth`. From [[ https://github.com/llvm/llvm-project/blob/ac3e5c4d93fbe7fb2db3c745c721aff41cc1b851/clang/include/clang/Format/Format.h#L170 | the documentation ]] of AlignOperands: DontAlign: > The wrapped lines are indented `ContinuationIndentWidth` spaces from the start of the line. So the de-dent effectively erases the necessary `ContinuationIndentWidth` in that case.
This patch restores the `AlignOperands: DontAlign` behavior, producing: ``` % bin/clang-format -style=google ~/test.js aaaaaaaaaaa = bbbbbbbb ? cccccccccccccccccc() : dddddddddd ? eeeeeeeeeeeeee : fffff; ```
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D82199
show more ...
|
#
0487f6f1 |
| 13-Jun-2020 |
mydeveloperday <mydeveloperday@gmail.com> |
[clang-format] Fix short block when braking after control statement
Summary: This patch fixes bug #44192
When clang-format is run with option AllowShortBlocksOnASingleLine, it is expected to either
[clang-format] Fix short block when braking after control statement
Summary: This patch fixes bug #44192
When clang-format is run with option AllowShortBlocksOnASingleLine, it is expected to either succeed in putting the short block with its control statement on a single line or fail and leave the block as is. When brace wrapping after control statement is activated, if the block + the control statement length is superior to column limit but the block alone is not, clang-format puts the block in two lines: one for the control statement and one for the block. This patch removes this unexpected behaviour. Current unittests are updated to check for this behaviour.
Patch By: Bouska
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D71512
show more ...
|