218 Commits

Author SHA1 Message Date
Owen Pan
98281da29f
[clang-format] Correctly annotate */& in if condition with braced init (#109505)
Fixes #109371.
2024-10-02 18:07:57 -07:00
Owen Pan
6ae14c0505
[clang-format] Annotate the l_paren of function pointer types (#109229)
Fixes #109146.
2024-10-02 18:01:25 -07:00
Owen Pan
c28e268c32
[clang-format] Correctly annotate pointer/reference in if statement (#109370)
Fixes #60146.
2024-09-20 18:13:21 -07:00
Owen Pan
4fd14b9a3a
[clang-format] Correctly annotate pointer/reference in range-for loop (#109361)
Fixes #109358.
2024-09-20 18:12:09 -07:00
Owen Pan
4d18ce1dd2
[clang-format] Handle C-style cast of qualified type (#108929)
Fixes #102874.
2024-09-17 21:19:56 -07:00
kadir çetinkaya
04d71ea11b
[Format] Dont treat LBrace after extends/implements as initializer list (#108524)
This extends the fix in https://github.com/llvm/llvm-project/pull/106242
for other derived class types.
2024-09-16 20:18:39 +02:00
Owen Pan
94698369e9 [clang-format][NFC] Minor clean of TokenAnnotatorTest 2024-09-11 20:35:13 -07:00
Owen Pan
bcd586b5ab
[clang-format] Fix a bug in annotating CastRParen (#107675)
Fixes #107568.
2024-09-07 16:56:28 -07:00
Owen Pan
616a8ce620
[clang-format] Correctly annotate braces in macro definition (#107352)
Also add a test case for #107096.

Fixes #106418.
2024-09-05 18:45:21 -07:00
Owen Pan
3449ed8dec Revert "[clang-format] Correctly annotate braces in macro definition (#106662)"
This reverts commit 0fa78b6c7bd43c2498700a98c47a02cf4fd06388 due to
regression.

Fixes #107096.
2024-09-03 22:54:50 -07:00
Owen Pan
812c96e8b9
[clang-format] Handle pointer/reference in macro definitions (#107074)
A macro definition needs its own scope stack in the annotator, so we add
the MacroBodyScopes stack and use ScopeStack to refer to it when in the
macro definition body.

Also, we need to have a scope type for a child block because its parent
line is parsed (and thus the scope type for the braces is popped off the
scope stack) before the lines in the child block are.

Fixes #99271.
2024-09-03 19:11:12 -07:00
Owen Pan
a27ff17034
[clang-format] Fix a regression in annotating ObjCBlockLParen (#107021)
Fixes #106994.
2024-09-03 19:07:14 -07:00
Owen Pan
0fa78b6c7b
[clang-format] Correctly annotate braces in macro definition (#106662)
Fixes #106418.
2024-09-02 01:40:13 -07:00
Owen Pan
e0f2368cde
[clang-format] Correctly annotate braces in ObjC square brackets (#106654)
See
https://github.com/llvm/llvm-project/pull/88238#issuecomment-2316954781.
2024-08-30 19:23:45 -07:00
Owen Pan
7579787e05
[clang-format] Correctly identify token-pasted record names (#106484)
See
https://github.com/llvm/llvm-project/pull/89706#issuecomment-2315549955.
2024-08-29 19:14:19 -07:00
Owen Pan
438ad9f2bf
[clang-format] Revert "[clang-format][NFC] Delete TT_LambdaArrow (#70… (#105923)
…519)"

This reverts commit e00d32afb9d33a1eca48e2b041c9688436706c5b and adds a
test for lambda arrow SplitPenalty.

Fixes #105480.
2024-08-28 18:23:54 -07:00
Krasimir Georgiev
77d63cfd18
[clang-format] js handle anonymous classes (#106242)
Addresses a regression in JavaScript when formatting anonymous classes.

---------

Co-authored-by: Owen Pan <owenpiano@gmail.com>
2024-08-28 13:45:17 +02:00
Owen Pan
0916ae49b8
[clang-format] Fix a misannotation of less/greater as angle brackets (#105941)
Fixes #105877.
2024-08-24 20:10:03 -07:00
Owen Pan
6bc225e063
[clang-format] Fix a misannotation of redundant r_paren as CastRParen (#105921)
Fixes #105880.
2024-08-24 19:12:15 -07:00
Owen Pan
3496245ed3
[clang-format] Change GNU style language standard to LS_Latest (#104669)
Fixes #104655.
2024-08-18 12:02:15 -07:00
Owen Pan
ee2359968f
[clang-format] Fix annotation of braces enclosing stringification (#102998)
Fixes #102937.
2024-08-13 12:39:33 -07:00
Owen Pan
8c7a038f90
[clang-format] Fix a bug in annotating CastRParen (#102261)
Fixes #102102.
2024-08-07 21:05:42 -07:00
Owen Pan
8abdf7cc71
[clang-format] Fix a misannotation of PointerOrReference (#101291)
Fixes #101138.
2024-08-01 21:55:43 -07:00
Owen Pan
73c961a334
[clang-format] Fix misannotations of < in ternary expressions (#100980)
Fixes #100300.
2024-07-29 18:01:44 -07:00
Gedare Bloom
ccae7b461b
[clang-format] Improve BlockIndent at ColumnLimit (#93140)
Fixes #55731

The reported formatting problems were related to ignoring deep nesting
of "simple" functions (causing #54808) and to allowing the trailing
annotation to become separated from the closing parens, which allowed a
break to occur between the closing parens and the trailing annotation.
The fix for the nesting of "simple" functions is to detect them more
carefully. "Simple" was defined in a comment as being a single
non-expression argument. I tried to stay as close to the original intent
of the implementation while fixing the various bad formatting reports.

In the process of fixing these bugs, some latent bugs were discovered
related to how JavaScript Template Strings are handled. Those are also
fixed here.

---------

Co-authored-by: Owen Pan <owenpiano@gmail.com>
2024-07-24 19:47:11 -07:00
Owen Pan
7e7a9069d4 Revert "[clang-format] Fix a bug in annotating * in #defines (#99433)"
This reverts commit ce1a87437cc143889665c41046107e84cdf6246e.

Closes #100304.
2024-07-24 19:33:44 -07:00
Owen Pan
0387cd052b
[clang-format] Fix a bug in annotating FunctionAnnotationRParen (#99802)
Fixes #37906.
2024-07-21 14:54:50 -07:00
Owen Pan
dcebe29736
[clang-format] Fix a bug in annotating StartOfName (#99791)
Fixes #99758.
2024-07-21 13:14:18 -07:00
Owen Pan
ce1a87437c
[clang-format] Fix a bug in annotating * in #defines (#99433)
Fixes #99271.
2024-07-20 12:22:50 -07:00
Owen Pan
b2ac7f52fa
[clang-format][NFC] Annotate function/ctor/dtor declaration l_paren (#97938) 2024-07-10 00:10:24 -07:00
Emilia Kond
834ac2e205
[clang-format] Allow ternary in all templates (#96801)
Currently, question mark and colon tokens are not allowed between angle
brackets, as a template argument, if we are in an expression context.

However, expressions can still allowed in non-expression contexts,
leading to inconsistent formatting.

Removing this check entirely fixes this issue, and, surprisingly, breaks
no tests.

Fixes https://github.com/llvm/llvm-project/issues/81385
2024-06-29 14:39:34 +03:00
Emilia Kond
6621505a1e
[clang-format] Don't count template template parameter as declaration (#96396)
Reapply 4a7bf42a9b83144db8a11ac06cce4da21166e6a2
which was reverted in 34d44eb41dfbbbf01712719558b02763334fbeb3

Not sure why there are tests elsewhere in clang that rely on the output
of clang-format, but they were wrong
2024-06-22 21:16:51 +03:00
Mehdi Amini
34d44eb41d
Revert "[clang-format] Don't count template template parameter as declaration" (#96388)
Reverts llvm/llvm-project#95025 ; many bots are broken
2024-06-22 14:18:59 +02:00
Emilia Kond
4a7bf42a9b
[clang-format] Don't count template template parameter as declaration (#95025)
In ContinuationIndenter::mustBreak, a break is required between a
template declaration and the function/class declaration it applies to,
if the template declaration spans multiple lines.

However, this also includes template template parameters, which can
cause extra erroneous line breaks in some declarations.

This patch makes template template parameters not be counted as template
declarations.

Fixes https://github.com/llvm/llvm-project/issues/93793
Fixes https://github.com/llvm/llvm-project/issues/48746
2024-06-22 12:51:36 +03:00
Owen Pan
d69050d614
[clang-format] Annotate r_paren before braced list as TT_CastRParen (#96271)
Fixes #96096.
2024-06-21 20:23:18 -07:00
Owen Pan
fa00e8bb6a
[clang-format] Correctly annotate l_brace after TypenameMacro (#96026)
Closes #95418.
2024-06-19 17:49:35 -07:00
Owen Pan
61571e9046
[clang-format] Handle function try block with ctor-initializer (#95878)
Fixes #58987.
Fixes #95679.
2024-06-18 18:56:33 -07:00
Owen Pan
82e19318e6
[clang-format] Fix a bug in annotating lambda l_square (#95084)
Fixes #95072.
2024-06-12 00:56:48 -07:00
Gedare Bloom
a10135f492
[clang-format]: Annotate colons found in inline assembly (#92617)
Short-circuit the parsing of tok::colon to label colons found within
lines starting with asm as InlineASMColon.

Fixes #92616.

---------

Co-authored-by: Owen Pan <owenpiano@gmail.com>
2024-06-06 18:38:21 -07:00
Owen Pan
13f6797826
[clang-format] Handle AttributeMacros in parseRecord() (#94189)
Fixes #94184.
2024-06-03 12:55:10 -07:00
Owen Pan
f06f016419 [clang-format][NFC] Add missing parens of __attribute in unit tests 2024-06-02 12:44:40 -07:00
Owen Pan
80303cb287
[clang-format] Handle attributes before lambda return arrow (#94119)
Fixes #92657.
2024-06-02 12:26:10 -07:00
Owen Pan
3db1f3110e
[clang-format] Fix a regression in annotating class decl braces (#93657)
Fixes #93604.
2024-05-29 21:05:32 -07:00
Owen Pan
a6d97dec89
[clang-format] Correctly annotate C++ alternative operators in C (#92880)
PR #90161 uncovered a bug that annotates C++ xor as UnaryOperator if
followed by a binary operator. This patch fixes that and all other C++
alternative operator keywords when followed by a binary operator in C.

Fixes #92688.
2024-05-21 19:16:39 -07:00
Owen Pan
d89f20058b
[clang-format] Fix a bug in formatting goto labels in macros (#92494)
Fixes #92300.
2024-05-21 01:35:31 -07:00
Owen Pan
1c58208d89 [clang-format][NFC] Remove redundnat llvm::, clang::, etc. 2024-05-20 20:32:18 -07:00
Owen Pan
88d351e2e6
[clang-format] Fix a regression in annotating struct braces (#92352)
Fixes #92350.
2024-05-16 19:24:35 -07:00
Owen Pan
236b3e1aad
[clang-format] Handle Java switch expressions (#91112)
Also adds AllowShortCaseExpressionOnASingleLine option and
AlignCaseArrows suboption of AlignConsecutiveShortCaseStatements.

Fixes #55903.
2024-05-06 19:55:55 -07:00
Emilia Kond
c609043dd0
[clang-format] Don't allow comma in front of structural enum (#91056)
Assume that a comma in front of `enum` means it is actually a part of an
elaborated type in a template parameter list.

Fixes https://github.com/llvm/llvm-project/issues/47782
2024-05-06 06:44:13 +03:00
Owen Pan
8e9b1e9aa8
[clang-format] Fix a bug in annotating struct braces (#90555)
Fixes #60040.
2024-04-30 20:01:34 -07:00