[clang] clang-format: Add AlignFunctionDeclarations attribute to AlignConsecutiveDeclarations (PR #108241)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 11 19:46:02 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff ba4bcce5f5ffa9e7d4af72c20fe4f1baf97075fc e2091a7c50301c4a1e5c2eacb65a23bc0175e81a --extensions cpp,h -- clang/include/clang/Format/Format.h clang/lib/Format/Format.cpp clang/lib/Format/WhitespaceManager.cpp clang/unittests/Format/ConfigParseTest.cpp clang/unittests/Format/FormatTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index d4c3e2af58..9d0d2740a2 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -104,7 +104,7 @@ template <> struct MappingTraits<FormatStyle::AlignConsecutiveStyle> {
IO.mapOptional("AlignCompound", Value.AlignCompound);
IO.mapOptional("AlignFunctionPointers", Value.AlignFunctionPointers);
IO.mapOptional("AlignFunctionDeclarations",
- Value.AlignFunctionDeclarations);
+ Value.AlignFunctionDeclarations);
IO.mapOptional("PadOperators", Value.PadOperators);
}
};
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index c1b841bc79..bef0f06b15 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -306,32 +306,28 @@ TEST(ConfigParseTest, ParsesConfiguration) {
{/*Enabled=*/false, /*AcrossEmptyLines=*/false, \
/*AcrossComments=*/false, /*AlignCompound=*/false, \
/*AlignFunctionPointers=*/false, \
- /*AlignFunctionDeclarations=*/true, \
- /*PadOperators=*/true})); \
+ /*AlignFunctionDeclarations=*/true, /*PadOperators=*/true})); \
CHECK_PARSE( \
#FIELD ": Consecutive", FIELD, \
FormatStyle::AlignConsecutiveStyle( \
{/*Enabled=*/true, /*AcrossEmptyLines=*/false, \
/*AcrossComments=*/false, /*AlignCompound=*/false, \
/*AlignFunctionPointers=*/false, \
- /*AlignFunctionDeclarations=*/true, \
- /*PadOperators=*/true})); \
+ /*AlignFunctionDeclarations=*/true, /*PadOperators=*/true})); \
CHECK_PARSE( \
#FIELD ": AcrossEmptyLines", FIELD, \
FormatStyle::AlignConsecutiveStyle( \
{/*Enabled=*/true, /*AcrossEmptyLines=*/true, \
/*AcrossComments=*/false, /*AlignCompound=*/false, \
/*AlignFunctionPointers=*/false, \
- /*AlignFunctionDeclarations=*/true, \
- /*PadOperators=*/true})); \
+ /*AlignFunctionDeclarations=*/true, /*PadOperators=*/true})); \
CHECK_PARSE( \
#FIELD ": AcrossEmptyLinesAndComments", FIELD, \
FormatStyle::AlignConsecutiveStyle( \
{/*Enabled=*/true, /*AcrossEmptyLines=*/true, \
/*AcrossComments=*/true, /*AlignCompound=*/false, \
/*AlignFunctionPointers=*/false, \
- /*AlignFunctionDeclarations=*/true, \
- /*PadOperators=*/true})); \
+ /*AlignFunctionDeclarations=*/true, /*PadOperators=*/true})); \
/* For backwards compability, false / true should still parse */ \
CHECK_PARSE( \
#FIELD ": false", FIELD, \
@@ -339,16 +335,14 @@ TEST(ConfigParseTest, ParsesConfiguration) {
{/*Enabled=*/false, /*AcrossEmptyLines=*/false, \
/*AcrossComments=*/false, /*AlignCompound=*/false, \
/*AlignFunctionPointers=*/false, \
- /*AlignFunctionDeclarations=*/true, \
- /*PadOperators=*/true})); \
+ /*AlignFunctionDeclarations=*/true, /*PadOperators=*/true})); \
CHECK_PARSE( \
#FIELD ": true", FIELD, \
FormatStyle::AlignConsecutiveStyle( \
{/*Enabled=*/true, /*AcrossEmptyLines=*/false, \
/*AcrossComments=*/false, /*AlignCompound=*/false, \
/*AlignFunctionPointers=*/false, \
- /*AlignFunctionDeclarations=*/true, \
- /*PadOperators=*/true})); \
+ /*AlignFunctionDeclarations=*/true, /*PadOperators=*/true})); \
\
CHECK_PARSE_NESTED_BOOL(FIELD, Enabled); \
CHECK_PARSE_NESTED_BOOL(FIELD, AcrossEmptyLines); \
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index aea7df5ad1..6a41179bc2 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -20011,7 +20011,6 @@ TEST_F(FormatTest, AlignConsecutiveDeclarations) {
"}() };",
BracedAlign);
-
Alignment.AlignConsecutiveDeclarations.AlignFunctionDeclarations = false;
verifyFormat("unsigned int f1(void);\n"
"void f2(void);\n"
``````````
</details>
https://github.com/llvm/llvm-project/pull/108241
More information about the cfe-commits
mailing list