clang-format: Fix bad space before braced initializer.

Before:
  new int {1};

After:
  new int{1};

llvm-svn: 208168
This commit is contained in:
Daniel Jasper 2014-05-07 07:59:03 +00:00
parent 3819f02819
commit 7a2d60e328
2 changed files with 3 additions and 1 deletions

View File

@ -1483,7 +1483,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
if (Right.Type == TT_UnaryOperator)
return !Left.isOneOf(tok::l_paren, tok::l_square, tok::at) &&
(Left.isNot(tok::colon) || Left.Type != TT_ObjCMethodExpr);
if (Left.isOneOf(tok::identifier, tok::greater, tok::r_square) &&
if ((Left.isOneOf(tok::identifier, tok::greater, tok::r_square) ||
Left.isSimpleTypeSpecifier()) &&
Right.is(tok::l_brace) && Right.getNextNonComment() &&
Right.BlockKind != BK_Block)
return false;

View File

@ -5093,6 +5093,7 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
verifyFormat("Class::Class : member{1, 2, 3} {}");
verifyFormat("new vector<int>{1, 2, 3};");
verifyFormat("new int[3]{1, 2, 3};");
verifyFormat("new int{1};");
verifyFormat("return {arg1, arg2};");
verifyFormat("return {arg1, SomeType{parameter}};");
verifyFormat("int count = set<int>{f(), g(), h()}.size();");