clang-format: Fix corner case for brace alignment.

Before:
  Constructor::Constructor()
      : some_value{ //
            aaaaaaa //
  } {}

After:
  Constructor::Constructor()
      : some_value{ //
            aaaaaaa //
        } {}

llvm-svn: 194204
This commit is contained in:
Daniel Jasper 2013-11-07 14:02:28 +00:00
parent 29c3b55897
commit 6b6e7c37ea
2 changed files with 8 additions and 1 deletions

View File

@ -337,7 +337,9 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
if (Current.is(tok::l_brace) && Current.BlockKind == BK_Block) {
State.Column = State.FirstIndent;
} else if (Current.isOneOf(tok::r_brace, tok::r_square)) {
if (Current.closesBlockTypeList(Style))
if (Current.closesBlockTypeList(Style) ||
(Current.MatchingParen &&
Current.MatchingParen->BlockKind == BK_BracedInit))
State.Column = State.Stack[State.Stack.size() - 2].LastSpace;
else
State.Column = State.FirstIndent;

View File

@ -4543,6 +4543,11 @@ TEST_F(FormatTest, LayoutCxx11ConstructorBraceInitializers) {
" T member = {arg1, arg2};\n"
"};",
NoSpaces);
verifyFormat("Constructor::Constructor()\n"
" : some_value{ //\n"
" aaaaaaa //\n"
" } {}",
NoSpaces);
}
TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {