summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp1
2 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 8becd00897a..a41992679ad 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -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;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index aad0cb19fb2..bd7e23f60b8 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -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();");
OpenPOWER on IntegriCloud