diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 685bfe39f2418c0357d09321bebb6663218398e2..d8de4c68f3072901e27d5c700cd9a3676800ff37 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1493,7 +1493,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, + tok::r_paren) || Left.isSimpleTypeSpecifier()) && Right.is(tok::l_brace) && Right.getNextNonComment() && Right.BlockKind != BK_Block) diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 19abd37c33c05c4fac98b14bcbe066bd2aff31a0..2718a8992cda140a72193a6a911636b7b5fd44fb 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4798,8 +4798,8 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyFormat("STATIC_ASSERT((a & b) == 0);"); verifyFormat("STATIC_ASSERT(0 == (a & b));"); verifyFormat("template <bool a, bool b> " - "typename t::if<x && y>::type f() {};"); - verifyFormat("template <int *y> f() {};"); + "typename t::if<x && y>::type f() {}"); + verifyFormat("template <int *y> f() {}"); verifyFormat("vector<int *> v;"); verifyFormat("vector<int *const> v;"); verifyFormat("vector<int *const **const *> v;"); @@ -5256,7 +5256,7 @@ TEST_F(FormatTest, LayoutCallsInsideBraceInitializers) { } TEST_F(FormatTest, LayoutBraceInitializersInReturnStatement) { - verifyFormat("return (a)(b) {1, 2, 3};"); + verifyFormat("return (a)(b){1, 2, 3};"); } TEST_F(FormatTest, LayoutCxx11BraceInitializers) { @@ -5286,6 +5286,7 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) { verifyFormat("int foo(int i) { return fo1{}(i); }"); verifyFormat("int foo(int i) { return fo1{}(i); }"); + verifyFormat("auto i = decltype(x){};"); // In combination with BinPackParameters = false. FormatStyle NoBinPacking = getLLVMStyle(); @@ -7072,7 +7073,7 @@ TEST_F(FormatTest, DoNotCreateUnreasonableUnwrappedLines) { verifyFormat("void f() {\n" " return g() {}\n" " void h() {}"); - verifyFormat("int a[] = {void forgot_closing_brace() {f();\n" + verifyFormat("int a[] = {void forgot_closing_brace(){f();\n" "g();\n" "}"); }