3562 Commits

Author SHA1 Message Date
Owen Pan
df232d46f5
[clang-format] Don't re-annotate CaseLabelColon as ConditionalExpr (#114639)
Fixes #114627.
2024-11-02 14:42:41 -07:00
Owen Pan
6ca816f88d
[clang-format] Fix a regression in parsing switch in macro call (#114506)
Fixes #114408.
2024-11-01 18:47:50 -07:00
Owen Pan
78e7d9592d [clang-format][NFC] Use CLANG_SOURCE_DIR in CMakeLists 2024-10-24 18:36:58 -07:00
Owen Pan
786db636b9
[clang-format] Add KeepFormFeed option (#113268)
Closes #113170.
2024-10-23 19:55:32 -07:00
Owen Pan
d005be33ee
[clang-format] Handle C# goto case constructs (#113257)
Fixes #113256.
2024-10-22 18:39:32 -07:00
Owen Pan
b69ac31a3b
[clang-format] Use RemoveEmptyLinesInUnwrappedLines in clang-format s… (#113260)
…tyle
2024-10-22 18:37:43 -07:00
Emilia Kond
aea60ab94d
[clang-format] Make bitwise and imply requires clause (#110942)
This patch adjusts the requires clause/expression parser to imply a
requires clause if it is preceded by a bitwise and operator `&`, and
assume it is a reference qualifier. The justification is that bitwise
operations should not be used for requires expressions.

This is a band-aid fix. The real problems lie in the lookahead heuristic
in the same method. It may be worth it to rewrite that whole heuristic
to track more state in the future, instead of just blindly marching
forward across multiple unrelated definitions, since right now, the
definition following the one with the requires clause can influence
whether the heuristic chooses clause or expression.

Fixes https://github.com/llvm/llvm-project/issues/110485
2024-10-22 13:36:28 +03:00
Owen Pan
b5bcdb5cfa
[clang-format] Fix a crash on C# goto case (#113056)
Fixes #113011.
2024-10-21 18:50:13 -07:00
Owen Pan
d989c2410e
[clang-format] Add RemoveEmptyLinesInUnwrappedLines option (#112325)
Fixes #111340.
2024-10-17 20:21:42 -07:00
Owen Pan
67f576f31d
[clang-format] Handle template opener/closer in braced list (#112494)
Fixes #112487.
2024-10-17 19:56:09 -07:00
Owen Pan
ee6468494e Revert "[clang-format] Correctly annotate */& in if condition with braced init (#109505)"
This reverts commit 98281da29f7e36e22ff1e20b9cfefda8c31dbe56 which caused a
regression.

Fixes #112176.
2024-10-14 19:29:44 -07:00
sstwcw
253ff32724
[clang-format] Stop crashing when formatting Verilog (#112043)
The part of the code for parsing Verilog module instantiations
dereferenced a pointer without checking for null pointer. The pointer
may be null if the input is not complete and a line starts with a comma.
2024-10-14 13:57:35 +00:00
Iuri Chaer
0fba8381d2
[clang-format] Introduce "ReflowComments: IndentOnly" to re-indent comments without breaking internal structure (think Doxygen). (#96804)
* Convert `ReflowComments` from boolean into a new `enum` which can take
on the value `RCS_Never`, `RCS_IndentOnly`, or `RCS_Always`. The first
one is equivalent to the old `false`, the third one is `true`, and the
middle one means that multiline comments should only have their
indentation corrected, which is what Doxygen users will want.
* Preserve backward compatibility while parsing `ReflowComments`.
2024-10-11 19:14:09 -07:00
Owen Pan
1809d0fa1c
[clang-format] Insert a space between l_paren and ref-qualifier (#111465)
Fixes #111346.
2024-10-08 21:24:17 -07:00
Owen Pan
65688274b1
[clang-format][NFC] Clean up AlignConsecutiveStyle (#111285)
- Add a `CHECK_PARSE` for `AcrossComments`.
- Add a `CHECK_PARSE_NESTED_BOOL` for `AlignFunctionPointers`.
- Remove redundant statements.
- Clean up documentation.
2024-10-07 19:12:47 -07:00
Owen Pan
4b6e41b61e
[clang-format] Don't insert spaces after keywords in protobuf field o… (#111229)
…ptions

Fixes #54848.
2024-10-07 19:10:24 -07:00
Brad House
f0bd62d870
[clang-format] Add AlignFunctionDeclarations to AlignConsecutiveDeclarations (#108241)
Enabling AlignConsecutiveDeclarations also aligns function prototypes
or declarations.  This is often unexpected as typically function
prototypes, especially in public headers, don't use any padding.

Setting AlignFunctionDeclarations to false will skip this alignment.
It is by default set to true to keep compatibility with prior
versions to not make unexpected changes.

Fixes #74320
2024-10-06 17:46:43 -07:00
Owen Pan
b5f6689dc9
[clang-format] Annotate ::operator as FunctionDeclarationName (#111115)
Fixes #111011.
2024-10-04 18:20:21 -07:00
Owen Pan
e5b05a51b8
[clang-format] Handle template closer followed by braces (#110971)
Fixes #110968.
2024-10-04 18:18:03 -07:00
Owen Pan
eaff3a7434
[clang-format] Fix a bug that misannotates binary operators */&/&& (#110945)
Fixes #110879.
2024-10-03 18:57:50 -07:00
Owen Pan
14e1fef736
[clang-format] Handle template closer followed by empty paretheses (#110408)
Fixes #109925.
2024-10-02 19:06:56 -07:00
Owen Pan
688bc958bd
[clang-format] Add TemplateNames option to help parse C++ angles (#109916)
Closes #109912.
2024-10-02 18:10:56 -07:00
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
Gedare Bloom
df935ff4ec
[clang-format] Fix regression with BlockIndent of Braced Initializers (#108717)
Fixes #73584.
2024-09-22 14:31:19 -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
Gedare Bloom
c9aa9d53b6
[clang-format] Fix regression in BAS_AlwaysBreak for-await (#108634)
Fixes #108589.
2024-09-18 19:44: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
Owen Pan
a8dd8f6302
[clang-format] Fix a bug in SpacesInParens InConditionalStatements (#108797)
Fixes #64416.
2024-09-17 21:17:30 -07:00
Owen Pan
7153a4bbf6
[clang-format] Reimplement InsertNewlineAtEOF (#108513)
Fixes #108333.
2024-09-17 21:16:20 -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
Kazu Hirata
9159179451
[Format] Avoid repeated hash lookups (NFC) (#108794) 2024-09-16 06:43:26 -07:00
Owen Pan
8168088f0a
[clang-format] Fix regressions in BAS_AlwaysBreak (#107506)
Fixes #107401.
Fixes #107574.
2024-09-11 19:34:54 -07:00
Kazu Hirata
19a2f178da
[Format] Avoid repeated hash lookups (NFC) (#107962)
Co-authored-by: Owen Pan <owenpiano@gmail.com>
2024-09-10 07:32:54 -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
fac7e87d66
[clang-format] Insert a space between new/delete and a C-style cast (#106175)
It doesn't make sense to remove the space between new/delete and a
C-style cast when SpaceBeforeParensOptions.AfterPlacementOperator is set
to false.

Fixes #105628.
2024-08-27 19:14:16 -07:00
Owen Pan
656d5aa958
[clang-format] Fix misalignments of pointers in angle brackets (#106013)
Fixes #105898.
2024-08-27 19:13:27 -07: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
kadir çetinkaya
e439fdf4ea
[clang-format] Treat new expressions as simple functions (#105168)
ccae7b461be339e717d02f99ac857cf0bc7d17f improved handling for nested
calls, but this resulted in a lot of changes near `new` expressions.

This patch tries to restore previous behavior around new expressions, by
treating them as simple functions, which seem to align with the concept.

Fixes https://github.com/llvm/llvm-project/issues/105133.
2024-08-24 03:04:30 +02:00