-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang-format][NFC] Clean up AlignConsecutiveStyle #111285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) ChangesFull diff: https://github.com/llvm/llvm-project/pull/111285.diff 4 Files Affected:
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 5350c66ea5132b..d691d198f8025d 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -44,11 +44,7 @@ struct ScalarEnumerationTraits<FormatStyle::BreakBeforeNoexceptSpecifierStyle> {
template <> struct MappingTraits<FormatStyle::AlignConsecutiveStyle> {
static void enumInput(IO &IO, FormatStyle::AlignConsecutiveStyle &Value) {
- IO.enumCase(Value, "None",
- FormatStyle::AlignConsecutiveStyle(
- {/*Enabled=*/false, /*AcrossEmptyLines=*/false,
- /*AcrossComments=*/false, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ IO.enumCase(Value, "None", FormatStyle::AlignConsecutiveStyle({}));
IO.enumCase(Value, "Consecutive",
FormatStyle::AlignConsecutiveStyle(
{/*Enabled=*/true, /*AcrossEmptyLines=*/false,
@@ -76,11 +72,7 @@ template <> struct MappingTraits<FormatStyle::AlignConsecutiveStyle> {
{/*Enabled=*/true, /*AcrossEmptyLines=*/false,
/*AcrossComments=*/false, /*AlignCompound=*/false,
/*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
- IO.enumCase(Value, "false",
- FormatStyle::AlignConsecutiveStyle(
- {/*Enabled=*/false, /*AcrossEmptyLines=*/false,
- /*AcrossComments=*/false, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ IO.enumCase(Value, "false", FormatStyle::AlignConsecutiveStyle({}));
}
static void mapping(IO &IO, FormatStyle::AlignConsecutiveStyle &Value) {
@@ -1441,12 +1433,6 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.AlignAfterOpenBracket = FormatStyle::BAS_Align;
LLVMStyle.AlignArrayOfStructures = FormatStyle::AIAS_None;
LLVMStyle.AlignConsecutiveAssignments = {};
- LLVMStyle.AlignConsecutiveAssignments.AcrossComments = false;
- LLVMStyle.AlignConsecutiveAssignments.AcrossEmptyLines = false;
- LLVMStyle.AlignConsecutiveAssignments.AlignCompound = false;
- LLVMStyle.AlignConsecutiveAssignments.AlignFunctionPointers = false;
- LLVMStyle.AlignConsecutiveAssignments.Enabled = false;
- LLVMStyle.AlignConsecutiveAssignments.PadOperators = true;
LLVMStyle.AlignConsecutiveBitFields = {};
LLVMStyle.AlignConsecutiveDeclarations = {};
LLVMStyle.AlignConsecutiveMacros = {};
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index b8bdfaaa74e10e..4d723981d73926 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -300,12 +300,8 @@ 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( \
@@ -319,18 +315,20 @@ TEST(ConfigParseTest, ParsesConfiguration) {
/*AcrossComments=*/false, /*AlignCompound=*/false, \
/*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \
CHECK_PARSE( \
- #FIELD ": AcrossEmptyLinesAndComments", FIELD, \
+ #FIELD ": AcrossComments", FIELD, \
FormatStyle::AlignConsecutiveStyle( \
- {/*Enabled=*/true, /*AcrossEmptyLines=*/true, \
+ {/*Enabled=*/true, /*AcrossEmptyLines=*/false, \
/*AcrossComments=*/true, /*AlignCompound=*/false, \
/*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \
- /* For backwards compability, false / true should still parse */ \
CHECK_PARSE( \
- #FIELD ": false", FIELD, \
+ #FIELD ": AcrossEmptyLinesAndComments", FIELD, \
FormatStyle::AlignConsecutiveStyle( \
- {/*Enabled=*/false, /*AcrossEmptyLines=*/false, \
- /*AcrossComments=*/false, /*AlignCompound=*/false, \
+ {/*Enabled=*/true, /*AcrossEmptyLines=*/true, \
+ /*AcrossComments=*/true, /*AlignCompound=*/false, \
/*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \
+ /* For backwards compability, false / true should still parse */ \
+ CHECK_PARSE(#FIELD ": false", FIELD, \
+ FormatStyle::AlignConsecutiveStyle({})); \
CHECK_PARSE( \
#FIELD ": true", FIELD, \
FormatStyle::AlignConsecutiveStyle( \
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 5d386c1bbdbcd9..72350a50c4a80b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -20261,10 +20261,7 @@ TEST_F(FormatTest, AlignWithLineBreaks) {
auto Style = getLLVMStyleWithColumns(120);
EXPECT_EQ(Style.AlignConsecutiveAssignments,
- FormatStyle::AlignConsecutiveStyle(
- {/*Enabled=*/false, /*AcrossEmptyLines=*/false,
- /*AcrossComments=*/false, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ FormatStyle::AlignConsecutiveStyle({}));
EXPECT_EQ(Style.AlignConsecutiveDeclarations,
FormatStyle::AlignConsecutiveStyle({}));
verifyFormat("void foo() {\n"
diff --git a/clang/unittests/Format/FormatTestVerilog.cpp b/clang/unittests/Format/FormatTestVerilog.cpp
index fbaf289fbc4d6d..f719fcebb2f55a 100644
--- a/clang/unittests/Format/FormatTestVerilog.cpp
+++ b/clang/unittests/Format/FormatTestVerilog.cpp
@@ -56,6 +56,7 @@ TEST_F(FormatTestVerilog, Align) {
"sfdbddfbdfbb <= x;",
Style);
Style.AlignConsecutiveAssignments.AlignCompound = true;
+ Style.AlignConsecutiveAssignments.PadOperators = true;
verifyFormat("x <= x;\n"
"sfdbddfbdfbb <= x;",
Style);
|
7745a5d
to
b1bcd59
Compare
bradh352
added a commit
to bradh352/llvm-project
that referenced
this pull request
Oct 6, 2024
* Changes requested to some existing code that is also part of PR llvm#111285. * Removal of redundant test case * Add of boolean check for AlignFunctionDeclarations
mydeveloperday
approved these changes
Oct 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CHECK_PARSE
forAcrossComments
.CHECK_PARSE_NESTED_BOOL
forAlignFunctionPointers
.