diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -362,6 +362,11 @@ Changes[i].Tok->Previous->is(TT_ConditionalExpr)) return true; + // Continued braced list. + if (Changes[ScopeStart - 1].Tok->is(tok::l_brace) && + Changes[i].Tok->isNot(tok::r_brace)) + return true; + return false; }; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -15170,9 +15170,9 @@ "int i = 0;\n" "float i2 = 0;\n" "auto v = type{\n" - " i = 1, //\n" - " (i = 2), //\n" - " i = 3 //\n" + " i = 1, //\n" + " (i = 2), //\n" + " i = 3 //\n" "};", Style); @@ -16402,6 +16402,11 @@ " double bar();\n" "};\n", Alignment); + // http://llvm.org/PR52914 + verifyFormat("char *a[] = {\"a\", // comment\n" + " \"bb\"};\n" + "int bbbbbbb = 0;", + Alignment); // PAS_Right EXPECT_EQ("void SomeFunction(int parameter = 0) {\n" @@ -16660,9 +16665,9 @@ "int i = 0;\n" "float i2 = 0;\n" "auto v = type{\n" - " i = 1, //\n" - " (i = 2), //\n" - " i = 3 //\n" + " i = 1, //\n" + " (i = 2), //\n" + " i = 3 //\n" "};", Alignment); Alignment.AlignConsecutiveAssignments = FormatStyle::ACS_None;