diff options
author | Brad House <brad@brad-house.com> | 2024-10-06 20:46:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-06 17:46:43 -0700 |
commit | f0bd62d8709a49dd87eb75411e41e2e11e0ab59d (patch) | |
tree | d4dd33a3ca91a69d146ddab9497b4e1d328a52ae /clang/unittests/Format/ConfigParseTest.cpp | |
parent | c4d89203f3822b0466f5cc58654cb016aeb86648 (diff) | |
download | llvm-f0bd62d8709a49dd87eb75411e41e2e11e0ab59d.zip llvm-f0bd62d8709a49dd87eb75411e41e2e11e0ab59d.tar.gz llvm-f0bd62d8709a49dd87eb75411e41e2e11e0ab59d.tar.bz2 |
[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
Diffstat (limited to 'clang/unittests/Format/ConfigParseTest.cpp')
-rw-r--r-- | clang/unittests/Format/ConfigParseTest.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp index b8bdfaa..aa8fbb8 100644 --- a/clang/unittests/Format/ConfigParseTest.cpp +++ b/clang/unittests/Format/ConfigParseTest.cpp @@ -300,48 +300,45 @@ TEST(ConfigParseTest, ParsesConfiguration) { #define CHECK_ALIGN_CONSECUTIVE(FIELD) \ do { \ Style.FIELD.Enabled = true; \ - CHECK_PARSE( \ - #FIELD ": None", FIELD, \ - FormatStyle::AlignConsecutiveStyle( \ - {/*Enabled=*/false, /*AcrossEmptyLines=*/false, \ - /*AcrossComments=*/false, /*AlignCompound=*/false, \ - /*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \ + CHECK_PARSE(#FIELD ": None", FIELD, \ + FormatStyle::AlignConsecutiveStyle({})); \ CHECK_PARSE( \ #FIELD ": Consecutive", FIELD, \ FormatStyle::AlignConsecutiveStyle( \ {/*Enabled=*/true, /*AcrossEmptyLines=*/false, \ /*AcrossComments=*/false, /*AlignCompound=*/false, \ + /*AlignFunctionDeclarations=*/true, \ /*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \ CHECK_PARSE( \ #FIELD ": AcrossEmptyLines", FIELD, \ FormatStyle::AlignConsecutiveStyle( \ {/*Enabled=*/true, /*AcrossEmptyLines=*/true, \ /*AcrossComments=*/false, /*AlignCompound=*/false, \ + /*AlignFunctionDeclarations=*/true, \ /*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \ CHECK_PARSE( \ #FIELD ": AcrossEmptyLinesAndComments", FIELD, \ FormatStyle::AlignConsecutiveStyle( \ {/*Enabled=*/true, /*AcrossEmptyLines=*/true, \ /*AcrossComments=*/true, /*AlignCompound=*/false, \ + /*AlignFunctionDeclarations=*/true, \ /*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \ /* For backwards compability, false / true should still parse */ \ - CHECK_PARSE( \ - #FIELD ": false", FIELD, \ - FormatStyle::AlignConsecutiveStyle( \ - {/*Enabled=*/false, /*AcrossEmptyLines=*/false, \ - /*AcrossComments=*/false, /*AlignCompound=*/false, \ - /*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \ + CHECK_PARSE(#FIELD ": false", FIELD, \ + FormatStyle::AlignConsecutiveStyle({})); \ CHECK_PARSE( \ #FIELD ": true", FIELD, \ FormatStyle::AlignConsecutiveStyle( \ {/*Enabled=*/true, /*AcrossEmptyLines=*/false, \ /*AcrossComments=*/false, /*AlignCompound=*/false, \ + /*AlignFunctionDeclarations=*/true, \ /*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \ \ CHECK_PARSE_NESTED_BOOL(FIELD, Enabled); \ CHECK_PARSE_NESTED_BOOL(FIELD, AcrossEmptyLines); \ CHECK_PARSE_NESTED_BOOL(FIELD, AcrossComments); \ CHECK_PARSE_NESTED_BOOL(FIELD, AlignCompound); \ + CHECK_PARSE_NESTED_BOOL(FIELD, AlignFunctionDeclarations); \ CHECK_PARSE_NESTED_BOOL(FIELD, PadOperators); \ } while (false) |