3749 Commits

Author SHA1 Message Date
Kazu Hirata
6d2a7b4546
[clang] Use llvm::find_if (NFC) (#140983) 2025-05-21 20:31:52 -07:00
Owen Pan
d5d8d8ac76
[clang-format][NFC] Minor efficiency cleanup (#140835) 2025-05-21 20:24:56 -07:00
Owen Pan
0dfdf7efbf
[clang-format] Handle raw string literals containing JSON code (#140666)
Fix #65400
2025-05-20 19:15:57 -07:00
Owen Pan
5ddcd765db
[clang-format][NFC] Upgrade SortIncludes option to a struct (#140497)
This allows adding other suboptions e.g. IgnoreExtension in #137840.
2025-05-19 01:32:17 -07:00
Owen Pan
6da2acf8e9
[clang-format] Merge short inline function in macro definition body (#140366)
Fix #62356
2025-05-19 01:30:42 -07:00
Owen Pan
0cac25bcf5
[clang-format] Fix the indent of StartOfName after AttributeMacro (#140361)
Fix #139510
2025-05-19 01:29:16 -07:00
Kazu Hirata
0fc9cd13a6
[clang] Use llvm::unique (NFC) (#140459) 2025-05-18 09:47:06 -07:00
Kazu Hirata
4567c11d28
[clang] Use llvm::binary_search (NFC) (#140216) 2025-05-16 07:32:44 -07:00
Owen Pan
6a1d3ea57d
[clang-format] Handle Java record (#139215)
Fix #62089
2025-05-09 18:05:16 -07:00
Owen Pan
9bafaf6dfd
[clang-format][NFC] Delete duplicates in CSharpExtraKeywords (#139199) 2025-05-09 18:03:00 -07:00
Owen Pan
4bcc083a72
[clang-format] Handle C# where clause in SeparateDefinitionBlocks (#139034)
Fix #61956
2025-05-08 19:38:01 -07:00
Filip Milosevic
5df01abe19
[clang-format] Add SpaceAfterOperatorKeyword option (#137610)
Add SpaceAfterOperatorKeyword option to clang-format
2025-05-07 22:47:56 -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
79210feb29
[clang-format] Fix a crash on formatting missing r_paren/r_brace (#138230)
Fix #138097
2025-05-02 19:20:42 -07:00
Owen Pan
d3506ee573
[clang-format] RemoveParentheses shouldn't remove empty parentheses (#138229)
Fix #138124
2025-05-02 19:19:39 -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
8effc8da29 Reland [clang-format] Add OneLineFormatOffRegex option (#137577) 2025-04-30 19:58:59 -07:00
Owen Pan
7752e0a10b Revert "[clang-format] Add OneLineFormatOffRegex option (#137577)"
This reverts commit b8bb1ccb4f9126d1bc9817be24e17f186a75a08b which triggered
an assertion failure in CodeGenTest.TestNonAlterTest.
2025-04-30 00:12:41 -07:00
Owen Pan
b8bb1ccb4f
[clang-format] Add OneLineFormatOffRegex option (#137577)
Close #54334
2025-04-29 19:22:53 -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
0af26149e2 [clang-format][NFC] Use UnwrappedLineParser::eof() whenever possible 2025-04-25 22:16:59 -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
82f1f5e5d4
[clang-format] Correctly identify include guards (#137112)
Fix #136814
2025-04-24 20:17:07 -07:00
Owen Pan
da8f2d5242 Revert "[clang-format] Allow breaking before kw___attribute (#128623)"
This reverts commit 8fc8a84e23471fe56214e68706addc712b5a2949, which caused a
regression.

Fixes #136675.
2025-04-22 23:49:26 -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
Kazu Hirata
f2ec5e40d9
[clang] Use llvm::unique (NFC) (#136469) 2025-04-19 20:33:53 -07:00
Kazu Hirata
c2d6c7cea7
[clang] Use llvm::append_range (NFC) (#136448) 2025-04-19 12:21:14 -07:00
Owen Pan
58a5c469d9
[clang-format] Fix a bug in BWACS_MultiLine (#136281)
Fixes #136266
2025-04-18 18:13:02 -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
c64f670255
[clang-format] Fix a crash in EnumTrailingComma (#135903)
Fix #135819
2025-04-18 18:11:56 -07:00
Owen Pan
c99ffe58af
[clang-format] Fix a bug in FormatToken::isObjCAccessSpecifier() (#136109)
Fix #136092
2025-04-17 19:07:14 -07:00
Owen Pan
9bd0c8726a
[clang-format] Fix a bug in BWACS_MultiLine (#135906)
Fix #51940
2025-04-16 18:48:10 -07:00
Owen Pan
c41ef751f8
[clang-format] Treat lambda in braced init as inline (#135520)
Fix #125430
2025-04-13 09:02:46 -07:00
Owen Pan
5f11d64cfb
[clang-format] Fix a bug in AlignConsecutiveDeclarations (#135516)
Fix #109768
2025-04-13 09:01:37 -07:00
Owen Pan
5f744cc630
[clang-format] Wrap and indent lambda braces in GNU style (#135479)
Fix #133135
2025-04-12 15:06:21 -07:00
Owen Pan
09c8cfe219
[clang-format][NFC] Add isJava() and isTextProto() in FormatStyle (#135466)
Also remove redundant name qualifiers format::, FormatStyle::, and
LanguageKind::.
2025-04-12 15:04:29 -07:00
Tim Clephas
c893f1d18d
Treat ipynb as json (#135137)
Fixes #110727
2025-04-10 20:40:43 +02: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
sstwcw
ed85822027
[clang-format] Handle C++ keywords in other languages better (#132941)
There is some code to make sure that C++ keywords that are identifiers
in the other languages are not treated as keywords.  Right now, the kind
is set to identifier, and the identifier info is cleared.  The latter is
probably so that the code for identifying C++ structures does not
recognize those structures by mistake when formatting a language that
does not have those structures.  But we did not find an instance where
the language can have the sequence of tokens, the code tries to parse
the structure as if it is C++ using the identifier info instead of the
token kind, but without checking for the language setting.  However,
there are places where the code checks whether the identifier info field
is null or not.  They are places where an identifier and a keyword are
treated the same way.  For example, the name of a function in
JavaScript.  This patch removes the lines that clear the identifier
info.  This way, a C++ keyword gets treated in the same way as an
identifier in those places.

JavaScript

New

```JavaScript
async function
union(
    myparamnameiswaytooloooong) {
}
```

Old

```JavaScript
async function
    union(
        myparamnameiswaytooloooong) {
}
```

Java

New

```Java
enum union { ABC, CDE }
```

Old

```Java
enum
union { ABC, CDE }
```

This reverts commit 97dcbdef6089175c45e14fcbcf5c88b10233a79a.
2025-04-10 12:51:10 +00:00
Owen Pan
f344838389
[clang-format] Keep the space between not and a unary operator (#135035)
Also keep the space between `not` and `::`.

Based on the
[documentation](https://releases.llvm.org/20.1.0/tools/clang/docs/ClangFormatStyleOptions.html#spaceafterlogicalnot),
it can be argued that SpaceAfterLogicalNot doesn't cover the alternative
operator `not`.

Closes #125465
2025-04-09 17:52:12 -07:00
Owen Pan
75cbb1f0fa
[clang-format][NFC] Add FormatToken::is(tok::ObjCKeywordKind) (#134973)
This allows simplification of code that checks if a token is an
Objective-C keyword.

Also, delete the following in
UnwrappedLineParser::parseStructuralElement():
- an else-after-break in the tok::at case
- the copypasted code in the tok::objc_autoreleasepool case
2025-04-09 17:49:26 -07:00
Owen Pan
aaaeb86ace
[clang-format] Merge inline short functions for BS_Whitesmiths (#134473)
Fix #126747
2025-04-05 17:03:55 -07: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