Index: lib/Format/WhitespaceManager.cpp =================================================================== --- lib/Format/WhitespaceManager.cpp +++ lib/Format/WhitespaceManager.cpp @@ -255,8 +255,14 @@ Changes[ScopeStack.back()].indentAndNestingLevel()) ScopeStack.pop_back(); + // Compare current token to previous non-comment token to ensure whether + // it is in a deeper scope or not. + unsigned PreviousNonComment = i - 1; + while (PreviousNonComment > Start && + Changes[PreviousNonComment].Tok->is(tok::comment)) + PreviousNonComment--; if (i != Start && Changes[i].indentAndNestingLevel() > - Changes[i - 1].indentAndNestingLevel()) + Changes[PreviousNonComment].indentAndNestingLevel()) ScopeStack.push_back(i); bool InsideNestedScope = ScopeStack.size() != 0; Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -9449,6 +9449,14 @@ "});\n", Alignment); Alignment.PointerAlignment = FormatStyle::PAS_Right; + + // Bug 35641 + Alignment.AlignConsecutiveDeclarations = true; + verifyFormat("int func() { //\n" + " int b;\n" + " int c;\n" + "}", + Alignment); } TEST_F(FormatTest, LinuxBraceBreaking) {