aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Format/ConfigParseTest.cpp
AgeCommit message (Collapse)AuthorFilesLines
3 days[clang-format] Add AfterNot to SpaceBeforeParensOptions (#150367)Owen Pan1-0/+1
Closes #149971
11 days[clang-format] Add IgnoreExtension to SortIncludes (#137840)Daan De Meyer1-9/+13
Sorting by stem gives nicer results when various header file names are substrings of other header file names. For example, a CLI application with a main header named analyze.h and an analyze-xxx.h header for each subcommand currently will always put analyze.h last after all the analyze-xxx.h headers, but putting analyze.h first instead is arguably nicer to read. TLDR; Instead of ``` #include "analyze-blame.h" #include "analyze.h" ``` You'd get ``` #include "analyze.h" #include "analyze-blame.h" ``` Let's allow sorting by stem instead of full path by adding IgnoreExtension to SortIncludes.
2025-07-13[clang-format] Add MacrosSkippedByRemoveParentheses option (#148345)Owen Pan1-0/+1
This allows RemoveParentheses to skip the invocations of function-like macros. Fixes #68354. Fixes #147780.
2025-05-28[clang-format] Handle .h files for LK_C and LK_ObjC (#141714)Owen Pan1-0/+18
Fix #137792
2025-05-19[clang-format][NFC] Upgrade SortIncludes option to a struct (#140497)Owen Pan1-6/+13
This allows adding other suboptions e.g. IgnoreExtension in #137840.
2025-05-07[clang-format] Add SpaceAfterOperatorKeyword option (#137610)Filip Milosevic1-0/+1
Add SpaceAfterOperatorKeyword option to clang-format
2025-04-30Reland [clang-format] Add OneLineFormatOffRegex option (#137577)Owen Pan1-0/+1
2025-04-30Revert "[clang-format] Add OneLineFormatOffRegex option (#137577)"Owen Pan1-1/+0
This reverts commit b8bb1ccb4f9126d1bc9817be24e17f186a75a08b which triggered an assertion failure in CodeGenTest.TestNonAlterTest.
2025-04-29[clang-format] Add OneLineFormatOffRegex option (#137577)Owen Pan1-0/+1
Close #54334
2025-03-30[clang-format] Add an option for editing enum trailing commas (#133576)Owen Pan1-0/+8
Also refactor the code that removes/replaces a token.
2025-03-27[clang-format] Allow `Language: Cpp` for C files (#133033)Owen Pan1-0/+20
Fix #132832
2025-03-14[clang-format] Add support for absl nullability macros (#130346)Jan Voung1-0/+5
Add support for formatting w/ absl nullability macros (https://github.com/abseil/abseil-cpp/blob/c52afac4f87ef76e6293b84874e5126a62be1f15/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-02-27[clang-format] Change BracedInitializerIndentWidth to int (#128988)Owen Pan1-3/+7
Fixes #108526
2025-02-07[clang-format] Add BinPackLongBracedList style option (#112482)Gedare Bloom1-0/+1
The use of Cpp11BracedListStyle with BinPackArguments=False avoids bin packing until reaching a hard-coded limit of 20 items. This is an arbitrary choice. Introduce a new style option to allow disabling this limit.
2025-02-06[clang-format] Add BreakBeforeTemplateCloser option (#118046)leijurv1-0/+1
In clang-format, multiline templates have the `>` on the same line as the last parameter: ```c++ template < typename Foo, typename Bar> void foo() { ``` I would like to add an option to put the `>` on the next line, like this: ```c++ template < typename Foo, typename Bar > void foo() { ``` An example of a large project that uses this style is NVIDIA's CUTLASS, here is an example: https://github.com/NVIDIA/cutlass/blob/main/include/cutlass/epilogue/dispatch_policy.hpp#L149-L156 My reasoning is that it reminds me of this style of braces: ```c++ if (foo()) { bar(); baz();} ``` Most people agree this is better: ```c++ if (foo()) { bar(); baz(); } ``` --------- Co-authored-by: Owen Pan <owenpiano@gmail.com>
2025-01-28[clang-format] Simplify ConfigParseTest for int/unsigned options (#124704)Owen Pan1-26/+35
Also add a number of missing tests for unsigned options.
2025-01-27[clang-format] Add style option `PenaltyBreakBeforeMemberAccess` (#118409)Gedare Bloom1-0/+2
The penalty for breaking before a member access is hard-coded to 150. Add a configuration option to allow setting it. --------- Co-authored-by: Owen Pan <owenpiano@gmail.com>
2025-01-21[clang-format] Rename ExportBlockIndentation -> IndentExportBlock (#123493)Sirraide1-0/+1
This renames the `ExportBlockIndentation` option and adds a config parse test, as requested in #110381.
2025-01-04[clang-format][NFC] Add missing config tests for List of Strings (#121451)Owen Pan1-5/+12
Also, simplify the existing test for NamespaceMacros. Like the options tested by the added tests, it's also a list of arbitrary strings and initialized to an empty list. (The other existing tests for list of strings either are initialized to a list of one or more strings or require specific strings.)
2025-01-02[clang-format] Add option WrapNamespaceBodyWithNewlines (#106145)dmasloff1-0/+7
It wraps the body of namespace with additional newlines, turning this code: ``` namespace N { int function(); } ``` into the following: ``` namespace N { int function(); } ``` --------- Co-authored-by: Owen Pan <owenpiano@gmail.com>
2024-12-30[clang-format] Add `AllowShortNamespacesOnASingleLine` option (#105597)Galen Elias1-0/+1
This fixes #101363 which is a resurrection of a previously opened but never completed review: https://reviews.llvm.org/D11851 The feature is to allow code like the following not to be broken across multiple lines: ``` namespace foo { class bar; } namespace foo { namespace bar { class baz; } } ``` Code like this is commonly used for forward declarations, which are ideally kept compact. This is also apparently the format that include-what-you-use will insert for forward declarations. Also, fix an off-by-one error in `CompactNamespaces` code. For nested namespaces with 3 or more namespaces, it was incorrectly compacting lines which were 1 or two spaces over the `ColumnLimit`, leading to incorrect formatting results.
2024-10-23[clang-format] Add KeepFormFeed option (#113268)Owen Pan1-3/+4
Closes #113170.
2024-10-17[clang-format] Add RemoveEmptyLinesInUnwrappedLines option (#112325)Owen Pan1-0/+1
Fixes #111340.
2024-10-11[clang-format] Introduce "ReflowComments: IndentOnly" to re-indent comments ↵Iuri Chaer1-1/+10
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-07[clang-format][NFC] Clean up AlignConsecutiveStyle (#111285)Owen Pan1-0/+8
- Add a `CHECK_PARSE` for `AcrossComments`. - Add a `CHECK_PARSE_NESTED_BOOL` for `AlignFunctionPointers`. - Remove redundant statements. - Clean up documentation.
2024-10-06[clang-format] Add AlignFunctionDeclarations to AlignConsecutiveDeclarations ↵Brad House1-12/+9
(#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-08-22[clang-format] Change BinPackParameters to enum and add AlwaysOnePerLine ↵Tom1-1/+13
(#101882) Related issues that have requested this feature: #51833 #23796 #53190 Partially solves - this issue requests is for both arguments and parameters
2024-08-10[clang-format] Add BreakBinaryOperations configuration (#95013)Ameer J1-0/+8
By default, clang-format packs binary operations, but it may be desirable to have compound operations be on individual lines instead of being packed. This PR adds the option `BreakBinaryOperations` to break up large compound binary operations to be on one line each. This applies to all logical and arithmetic/bitwise binary operations Maybe partially addresses #79487 ? Closes #58014 Closes #57280
2024-07-02[clang-format] Add SpacesInParensOption for filtering repeated parens (#77522)Gedare Bloom1-8/+13
The __attribute((specifier-list)) currently is formatted based on the SpacesInParensOptions.Other (previously, SpacesInParentheses). This change allows finer control over addition of spaces between the consecutive parens, and between the inner parens and the list of attribute specifiers. Differential Revision: https://reviews.llvm.org/D155529 This is migrated from Phabricator, see more discussion there. --------- Co-authored-by: Owen Pan <owenpiano@gmail.com>
2024-06-30[clang-format] Add option to remove leading blank lines (#91221)sstwcw1-2/+6
The options regarding which blank lines are kept are also aggregated. The new option is `KeepEmptyLines`. This patch was initially part of 9267f8f19a2e502e. I neglected to check the server builds before I added it. It broke clangd. Jie Fu fixed the problem in 4c91b49bab0728d4. I was unaware of it. I thought the main branch was still broken. I reverted the first patch in 70cfece24d6cbb57. It broke his fix. He reverted it in c69ea04fb9738db2. Now the feature is added again including the fix.
2024-06-25Revert "[clang-format] Add option to remove leading blank lines (#91221)"sstwcw1-6/+2
This reverts commit 9267f8f19a2e502ef5a216c0d52b352b3699d399. I changed a formatter option. I forgot to update other components that depend on the formatter when the option name changed.
2024-06-25[clang-format] Add option to remove leading blank lines (#91221)sstwcw1-2/+6
The options regarding which blank lines are kept are also aggregated. The new option is `KeepEmptyLines`.
2024-06-16[clang-format][NFC] Suppress diagnostic noise in GetStyleOfFile testOwen Pan1-5/+8
2024-06-16[clang-format] Add DiagHandler parameter to format::getStyle() (#91317)pointhex1-0/+21
It allows to control of error output for the function. Closes #94205. --------- Co-authored-by: Owen Pan <owenpiano@gmail.com>
2024-05-27[clang-format] Add LeftWithLastLine to AlignEscapedNewlines option (#93402)Owen Pan1-0/+2
Closes #92999.
2024-05-06[clang-format] Handle Java switch expressions (#91112)Owen Pan1-0/+2
Also adds AllowShortCaseExpressionOnASingleLine option and AlignCaseArrows suboption of AlignConsecutiveShortCaseStatements. Fixes #55903.
2024-02-14[clang-format][NFC] Drop "Always" in "AlwaysBreakAfterReturnType". (#81591)rmarker1-21/+19
Complete the switch from "AlwaysBreakAfterReturnType" to "BreakAfterReturnType".
2024-02-12[clang-format] Rename option AlwaysBreakAfterReturnType. (#80827)rmarker1-0/+16
Changes the option to BreakAfterReturnType option, with a more relevant name, deprecating and replacing AlwaysBreakAfterReturnType. Following up on #78010.
2024-02-09[clang-format][NFC] Drop "Always" in "AlwaysBreakTemplateDeclarations"Owen Pan1-19/+19
2024-02-09[clang-format] Rename option AlwaysBreakTemplateDeclarations (#81093)Owen Pan1-0/+13
Drop the "Always" prefix to remove the self-contradiction.
2024-02-07[clang-format] Add Leave to AlwaysBreakTemplateDeclarations (#80569)Owen Pan1-0/+2
Closes #78067.
2024-02-04[clang-format] Add Automatic and ExceptShortType options for ↵rmarker1-0/+4
AlwaysBreakAfterReturnType. (#78011) The RTBS_None option in Clang-format avoids breaking after a short return type. However, there was an issue with the behaviour in that it wouldn't take the leading indentation of the line into account. This meant that the behaviour wasn't applying when intended. In order to address this situation without breaking the existing formatting, RTBS_None has been deprecated. In its place are two new options for AlwaysBreakAfterReturnType. The option RTBS_Automatic will break after the return type based on PenaltyReturnTypeOnItsOwnLine. The option RTBS_ExceptShortType will take the leading indentation into account and prevent breaking after short return types. This allows the inconsistent behaviour of RTBS_None to be avoided and users to decide whether they want to allow breaking after short return types or not. Resolves #78010
2024-01-31[clang-format] Simplify the AfterPlacementOperator option (#79796)Owen Pan1-18/+1
Change AfterPlacementOperator to a boolean and deprecate SBPO_Never, which meant never inserting a space except when after new/delete. Fixes #78892.
2024-01-20[clang-format] Add SkipMacroDefinitionBody option (#78682)Owen Pan1-0/+1
Closes #67991. See also: #70338 Co-authored-by: @tomekpaszek
2024-01-16[clang-format] Add parse tests for SeparateDefinitionBlocks option (#78256)serbanu1-0/+8
Add config parse tests for SeparateDefinitionBlocks option.
2024-01-14[clang-format] Add PenaltyBreakScopeResolution option. (#78015)rmarker1-0/+2
Resolves #78014
2024-01-10[clang-format]: Split alignment of declarations around assignment (#69340)Gedare Bloom1-30/+36
Function pointers are detected as a type of declaration using FunctionTypeLParen. They are aligned based on rules for AlignConsecutiveDeclarations. When a function pointer is on the right-hand side of an assignment, the alignment of the function pointer can result in excessive whitespace padding due to the ordering of alignment, as the alignment processes a line from left-to-right and first aligns the declarations before and after the assignment operator, and then aligns the assignment operator. Injection of whitespace by alignment of declarations after the equal sign followed by alignment of the equal sign results in the excessive whitespace. Fixes #68079.
2023-11-27[clang-format] Add BreakAdjacentStringLiterals option (#73432)Owen Pan1-0/+1
Closes #70451.
2023-10-26[clang-format][NFC] Remove extraneous newlines in some unit test filesOwen Pan1-1/+1
2023-10-25[clang-format] AllowShortCompoundRequirementOnASingleLineBackl1ght1-0/+1
clang-format brace wrapping did not take requires into consideration, compound requirements will be affected by BraceWrapping.AfterFunction. Closes #59412. Differential Revision: https://reviews.llvm.org/D139834