clang-format: Fix regression in formatting of braced initializers.

Before:
  Node n{1, Node{1000}, //
                2};

After:
  Node n{1, Node{1000}, //
         2};

llvm-svn: 216540
This commit is contained in:
Daniel Jasper 2014-08-27 11:53:26 +00:00
parent 870d951bda
commit 168c8aa679
2 changed files with 5 additions and 1 deletions

View File

@ -313,7 +313,9 @@ private:
updateParameterCount(Left, CurrentToken);
if (CurrentToken->isOneOf(tok::colon, tok::l_brace)) {
FormatToken *Previous = CurrentToken->getPreviousNonComment();
if (Previous->is(tok::identifier))
if ((CurrentToken->is(tok::colon) ||
Style.Language == FormatStyle::LK_Proto) &&
Previous->is(tok::identifier))
Previous->Type = TT_SelectorName;
if (CurrentToken->is(tok::colon))
Left->Type = TT_DictLiteral;

View File

@ -5466,6 +5466,8 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
verifyFormat("int foo(int i) { return fo1{}(i); }");
verifyFormat("auto i = decltype(x){};");
verifyFormat("std::vector<int> v = {1, 0 /* comment */};");
verifyFormat("Node n{1, Node{1000}, //\n"
" 2};");
// In combination with BinPackParameters = false.
FormatStyle NoBinPacking = getLLVMStyle();