Skip to content

Commit 7745a5d

Browse files
committed
[clang-format][NFC] Clean up AlignConsecutiveStyle
1 parent b5f6689 commit 7745a5d

File tree

4 files changed

+14
-32
lines changed

4 files changed

+14
-32
lines changed

clang/lib/Format/Format.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ struct ScalarEnumerationTraits<FormatStyle::BreakBeforeNoexceptSpecifierStyle> {
4444

4545
template <> struct MappingTraits<FormatStyle::AlignConsecutiveStyle> {
4646
static void enumInput(IO &IO, FormatStyle::AlignConsecutiveStyle &Value) {
47-
IO.enumCase(Value, "None",
48-
FormatStyle::AlignConsecutiveStyle(
49-
{/*Enabled=*/false, /*AcrossEmptyLines=*/false,
50-
/*AcrossComments=*/false, /*AlignCompound=*/false,
51-
/*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
47+
IO.enumCase(Value, "None", FormatStyle::AlignConsecutiveStyle({}));
5248
IO.enumCase(Value, "Consecutive",
5349
FormatStyle::AlignConsecutiveStyle(
5450
{/*Enabled=*/true, /*AcrossEmptyLines=*/false,
@@ -76,11 +72,7 @@ template <> struct MappingTraits<FormatStyle::AlignConsecutiveStyle> {
7672
{/*Enabled=*/true, /*AcrossEmptyLines=*/false,
7773
/*AcrossComments=*/false, /*AlignCompound=*/false,
7874
/*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
79-
IO.enumCase(Value, "false",
80-
FormatStyle::AlignConsecutiveStyle(
81-
{/*Enabled=*/false, /*AcrossEmptyLines=*/false,
82-
/*AcrossComments=*/false, /*AlignCompound=*/false,
83-
/*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
75+
IO.enumCase(Value, "false", FormatStyle::AlignConsecutiveStyle({}));
8476
}
8577

8678
static void mapping(IO &IO, FormatStyle::AlignConsecutiveStyle &Value) {
@@ -1441,12 +1433,6 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
14411433
LLVMStyle.AlignAfterOpenBracket = FormatStyle::BAS_Align;
14421434
LLVMStyle.AlignArrayOfStructures = FormatStyle::AIAS_None;
14431435
LLVMStyle.AlignConsecutiveAssignments = {};
1444-
LLVMStyle.AlignConsecutiveAssignments.AcrossComments = false;
1445-
LLVMStyle.AlignConsecutiveAssignments.AcrossEmptyLines = false;
1446-
LLVMStyle.AlignConsecutiveAssignments.AlignCompound = false;
1447-
LLVMStyle.AlignConsecutiveAssignments.AlignFunctionPointers = false;
1448-
LLVMStyle.AlignConsecutiveAssignments.Enabled = false;
1449-
LLVMStyle.AlignConsecutiveAssignments.PadOperators = true;
14501436
LLVMStyle.AlignConsecutiveBitFields = {};
14511437
LLVMStyle.AlignConsecutiveDeclarations = {};
14521438
LLVMStyle.AlignConsecutiveMacros = {};

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,8 @@ TEST(ConfigParseTest, ParsesConfiguration) {
300300
#define CHECK_ALIGN_CONSECUTIVE(FIELD) \
301301
do { \
302302
Style.FIELD.Enabled = true; \
303-
CHECK_PARSE( \
304-
#FIELD ": None", FIELD, \
305-
FormatStyle::AlignConsecutiveStyle( \
306-
{/*Enabled=*/false, /*AcrossEmptyLines=*/false, \
307-
/*AcrossComments=*/false, /*AlignCompound=*/false, \
308-
/*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \
303+
CHECK_PARSE(#FIELD ": None", FIELD, \
304+
FormatStyle::AlignConsecutiveStyle({})); \
309305
CHECK_PARSE( \
310306
#FIELD ": Consecutive", FIELD, \
311307
FormatStyle::AlignConsecutiveStyle( \
@@ -319,18 +315,20 @@ TEST(ConfigParseTest, ParsesConfiguration) {
319315
/*AcrossComments=*/false, /*AlignCompound=*/false, \
320316
/*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \
321317
CHECK_PARSE( \
322-
#FIELD ": AcrossEmptyLinesAndComments", FIELD, \
318+
#FIELD ": AcrossComments", FIELD, \
323319
FormatStyle::AlignConsecutiveStyle( \
324-
{/*Enabled=*/true, /*AcrossEmptyLines=*/true, \
320+
{/*Enabled=*/true, /*AcrossEmptyLines=*/false, \
325321
/*AcrossComments=*/true, /*AlignCompound=*/false, \
326322
/*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \
327-
/* For backwards compability, false / true should still parse */ \
328323
CHECK_PARSE( \
329-
#FIELD ": false", FIELD, \
324+
#FIELD ": AcrossEmptyLinesAndComments", FIELD, \
330325
FormatStyle::AlignConsecutiveStyle( \
331-
{/*Enabled=*/false, /*AcrossEmptyLines=*/false, \
332-
/*AcrossComments=*/false, /*AlignCompound=*/false, \
326+
{/*Enabled=*/true, /*AcrossEmptyLines=*/true, \
327+
/*AcrossComments=*/true, /*AlignCompound=*/false, \
333328
/*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \
329+
/* For backwards compability, false / true should still parse */ \
330+
CHECK_PARSE(#FIELD ": false", FIELD, \
331+
FormatStyle::AlignConsecutiveStyle({})); \
334332
CHECK_PARSE( \
335333
#FIELD ": true", FIELD, \
336334
FormatStyle::AlignConsecutiveStyle( \

clang/unittests/Format/FormatTest.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20261,10 +20261,7 @@ TEST_F(FormatTest, AlignWithLineBreaks) {
2026120261
auto Style = getLLVMStyleWithColumns(120);
2026220262

2026320263
EXPECT_EQ(Style.AlignConsecutiveAssignments,
20264-
FormatStyle::AlignConsecutiveStyle(
20265-
{/*Enabled=*/false, /*AcrossEmptyLines=*/false,
20266-
/*AcrossComments=*/false, /*AlignCompound=*/false,
20267-
/*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
20264+
FormatStyle::AlignConsecutiveStyle({}));
2026820265
EXPECT_EQ(Style.AlignConsecutiveDeclarations,
2026920266
FormatStyle::AlignConsecutiveStyle({}));
2027020267
verifyFormat("void foo() {\n"

clang/unittests/Format/FormatTestVerilog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ TEST_F(FormatTestVerilog, Align) {
5656
"sfdbddfbdfbb <= x;",
5757
Style);
5858
Style.AlignConsecutiveAssignments.AlignCompound = true;
59+
Style.AlignConsecutiveAssignments.PadOperators = true;
5960
verifyFormat("x <= x;\n"
6061
"sfdbddfbdfbb <= x;",
6162
Style);

0 commit comments

Comments
 (0)