286 Commits

Author SHA1 Message Date
owenca
9a692e0f94
[clang-format] Don't annotate class property specifiers as StartOfName (#153525)
Fixes #153443
2025-08-17 12:53:57 -07:00
Owen Pan
4d48996ff0
[clang-format][NFC] Clean up around StringRef initializations (#149765)
Consistently use `constexpr StringRef Code("string literal");`.
2025-07-21 19:11:17 -07:00
Owen Pan
a8f5e9ed6b
[clang-format] Fix a regression of annotating PointerOrReference (#149039)
Fixes #149010
2025-07-17 21:43:43 -07:00
Owen Pan
cb52efb893
[clang-format] Split line comments separated by backslashes (#147648)
Fixes #147341
2025-07-10 18:14:45 -07:00
Owen Pan
2e7fbb94bc
[clang-format] Fix a bug in annotating braces (#144095)
Stop looking for function decls after hitting a BK_BracedInit brace.

Fixes #144057.
2025-06-14 00:21:39 -07:00
Owen Pan
9a894ae794
[clang-format] Parse JSON outermost l_brace as braced list brace (#143327)
See
https://github.com/llvm/llvm-project/issues/65400#issuecomment-2922181979.
2025-06-09 20:34:12 -07:00
Owen Pan
0c495ce9c4
[clang-format] Handle function decls with MS calling conventions (#143083) 2025-06-06 20:43:35 -07:00
Owen Pan
05c12b2284
[clang-format] Handle requires clause following a pointer type (#142893)
Fix #142818
2025-06-05 19:55:37 -07:00
Owen Pan
7bf5862dbf
[clang-format] Correctly annotate token-pasted function decl names (#142337)
Fix #142178
2025-06-02 13:35:27 -07:00
Owen Pan
c5cce4861c Revert "[clang-format] Handle token-pasted function decl names (#142251)"
This reverts commit 29f79ea3c59649f7686a09845665660c25ca3f9b which caused a regression.

See https://github.com/llvm/llvm-project/pull/142251#issuecomment-2928718530.
2025-06-01 23:32:00 -07:00
Owen Pan
29f79ea3c5
[clang-format] Handle token-pasted function decl names (#142251)
Fix #142178
2025-05-31 11:11:00 -07:00
Owen Pan
4851886693
[clang-format] Handle bit-field colon of non-numeric-constant size (#142110)
Fix #142050
2025-05-30 18:51:01 -07:00
Owen Pan
6a1d3ea57d
[clang-format] Handle Java record (#139215)
Fix #62089
2025-05-09 18:05:16 -07:00
Owen Pan
fa09d031d3
[clang-format] Correctly annotate ObjC * __autoreleasing * (#138799)
Fix #138484
2025-05-07 22:41:57 -07:00
Owen Pan
0e75810456
[clang-format] Fix a bug in annotating binary operator && (#138633)
Fix #138485
2025-05-06 19:37:54 -07:00
Owen Pan
b1e6c4b435
[clang-format] Correctly annotate C# nullable value type ? (#138631)
Fix #78666
2025-05-06 19:37:26 -07:00
Owen Pan
17ea830baf
[clang-format] Don't annotate enum colon as InheritanceColon (#138440)
Fix #61156
2025-05-06 19:36:51 -07:00
Owen Pan
deec7fb42d
[clang-format] Correctly annotate tok::star in braced list (#138389)
Fix #138382
2025-05-03 14:54:48 -07:00
Owen Pan
e6d7f46ce9
[clang-format] Correctly annotate user-defined conversion function call (#137914)
Fix #137770
2025-04-30 20:08:00 -07:00
Owen Pan
d403c70ff3
[clang-format] Annotate tok::star in a*b*c as BinaryOperator (#137433)
Fix #137400
2025-04-26 12:55:00 -07:00
Owen Pan
ae07f48913
[clang-format] Correctly handle C# new modifier (#137430)
Fix #75815
2025-04-26 12:54:38 -07:00
Owen Pan
61d78d0c08
[clang-format] Correctly handle C# where clause (#137295)
Fix #74947
2025-04-25 13:08:16 -07:00
Owen Pan
037657de7e
[clang-format] Correctly annotate kw_operator in using decls (#136545)
Fix #136541
2025-04-22 21:08:56 -07:00
Owen Pan
9efabbbbe5
[clang-format] Fix a bug in lexing C++ UDL ending in $ (#136476)
Fix #61612
2025-04-22 21:08:09 -07:00
Owen Pan
4f71655b64
[clang-format] Fix a bug in parsing C-style cast of lambdas (#136099)
Fix #135959
2025-04-22 21:07:31 -07:00
Owen Pan
ab4c939579
[clang-format] Fix a bug in annotating TT_PointerOrReference (#136073)
Fix #135972
2025-04-18 18:12:27 -07:00
Owen Pan
c99ffe58af
[clang-format] Fix a bug in FormatToken::isObjCAccessSpecifier() (#136109)
Fix #136092
2025-04-17 19:07:14 -07:00
sstwcw
f7617f7f90
[clang-format] Recognize TableGen paste operator on separate line (#133722)
Formatting this piece of code made the program crash.

```
class TypedVecListRegOperand<RegisterClass Reg, int lanes, string eltsize>
    : RegisterOperand<Reg, "printTypedVectorList<" # lanes # ", '"
                                                   # eltsize # "'>">;
```

The line starting with the `#` was treated as a separate preprocessor
directive line. Then the code dereferenced a null pointer when it tried
to continue parsing the first line that did not end in a semicolon.

Now the 2 problems are fixed.
2025-04-10 12:52:02 +00:00
Owen Pan
d71ee7d230
[clang-format] Set C11 instead of C17 for LK_C (#134472)
Fix #134453
2025-04-05 13:35:45 -07:00
Owen Pan
4fe0d74275
[clang-format] Fix a bug in annotating braces (#134039)
Fix #133873
2025-04-02 20:08:56 -07:00
Owen Pan
d3be29642f
[clang-format] Correctly annotate pointer/reference in _Generic (#133673)
Fix #133663
2025-03-31 23:16:41 -07:00
Owen Pan
b8a0558dea
[clang-format] Fix a regression on annotating template angles (#132885)
Annotate the angles in `A<B != A>B` as template opener/closer as it's
unlikely that they are less/greater-than operators in this context.

Fix #132248
2025-03-27 00:57:17 -07:00
Owen Pan
2497945a95
[clang-format] Correctly annotate requires clause in && requires( (#132882)
Fix #132334
2025-03-25 08:19:43 -07:00
Owen Pan
91328dbae9
[clang-format] Correctly annotate user-defined conversion functions (#131434)
Also fix/delete existing invalid/redundant test cases.

Fix #130894
2025-03-16 16:11:39 -07:00
Jan Voung
467ad6a035
[clang-format] Add support for absl nullability macros (#130346)
Add support for formatting w/ absl nullability macros
(c52afac4f8/absl/base/nullability.h (L237)).
Example at https://godbolt.org/z/PYv19M1Gj
input:
```
std::vector<int* _Nonnull> x;
std::vector<int* absl_nonnull> y;
```

orig output:
```
std::vector<int* _Nonnull> x;
std::vector<int * absl_nonnull> y;
```

new output:
```
std::vector<int* _Nonnull> x;
std::vector<int* absl_nonnull> y;
```
credit to @ymand for the original patch
2025-03-14 00:01:35 -07:00
Owen Pan
136f2574dd
[clang-format] Lex C++ only keywords as identifiers in C (#129426)
Fix #128847
2025-03-03 17:40:28 -08:00
Owen Pan
2d585ccecc
[clang-format] Fix a bug that changes keyword or to an identifier (#128410)
Fixes #105482
2025-02-26 18:14:26 -08:00
Owen Pan
13de15c9c4
[clang-format] Fix a bug in annotating StartOfName (#127545)
Also ensure we can break before ClassHeadName like StartOfName.

Fixes #127470
2025-02-18 00:15:01 -08:00
Owen Pan
885382f437
[clang-format] Fix a bug in annotating braces (#127306)
Fixes #107616.
2025-02-16 19:30:33 -08:00
Owen Pan
3063153b56
[clang-format] Fix a bug in annotating ObjCMethodSpecifier (#127159)
Fixes #58202.
2025-02-14 21:10:08 -08:00
Owen Pan
3ca9238cb0 [clang-format][NFC] Fix test case format 2025-02-11 23:58:53 -08:00
Owen Pan
8d373ceaec
[clang-format] Handle C-style cast of member function pointer type (#126340)
Fixes #125012.
2025-02-08 23:22:33 -08:00
Owen Pan
6980d97946
[clang-format] Fix a bug in annotating ClassHeadName (#125326) 2025-02-01 20:20:43 -08:00
Owen Pan
1a25bea852
[clang-format] Add ClassHeadName to help annotating StartOfName (#124891)
Fixes #124574.
2025-01-30 19:33:15 -08:00
Owen Pan
ea84474966
[clang-format] Fix annotation of Java/JavaScript keyword extends (#125038)
Uncovered in #124891.
2025-01-30 18:03:42 -08:00
Owen Pan
4fb8078887
[clang-format] Fix annotation of class name after requires clause (#125019)
Uncovered in #124891.
2025-01-30 18:02:40 -08:00
Owen Pan
1e89355dad
[clang-format] Treat f<N | M>(a) as template function call (#124438)
Fixes #123144.
2025-01-27 09:28:29 -08:00
Owen Pan
9452ee4f75
[clang-format] Treat uppercase identifiers after struct as macros (#124397)
This restores the behavior before llvmorg-20-init.

Fixes #94184.
Fixes #117477.
Fixes #122690.
Fixes #123142.
2025-01-27 00:11:18 -08:00
Owen Pan
8e31050bc2
[clang-format] Fix a bug in annotating overloaded co_await decl (#124240)
Fixes #124223.
2025-01-24 17:57:04 -08:00
Owen Pan
a7bca1861b
[clang-format] Correctly annotate braces in macro definitions (#123279)
Fixes #123179.
2025-01-17 19:26:00 -08:00