From 4afc6b3e16c60b2a74f9b1938949bc72efe6b2a3 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 2 Jun 2014 10:57:55 +0000 Subject: [PATCH] clang-format: No space between ")" and braced init list. Before: auto j = decltype(i) {}; After: auto j = decltype(i){}; This fixes llvm.org/PR19892. llvm-svn: 210013 --- clang/lib/Format/TokenAnnotator.cpp | 3 ++- clang/unittests/Format/FormatTest.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 685bfe3..d8de4c6 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 19abd37..2718a89 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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 " - "typename t::if::type f() {};"); - verifyFormat("template f() {};"); + "typename t::if::type f() {}"); + verifyFormat("template f() {}"); verifyFormat("vector v;"); verifyFormat("vector v;"); verifyFormat("vector 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" "}"); } -- 2.7.4