r210013 - clang-format: No space between ")" and braced init list.

Daniel Jasper djasper at google.com
Mon Jun 2 03:57:56 PDT 2014


Author: djasper
Date: Mon Jun  2 05:57:55 2014
New Revision: 210013

URL: http://llvm.org/viewvc/llvm-project?rev=210013&view=rev
Log:
clang-format: No space between ")" and braced init list.

Before:
  auto j = decltype(i) {};

After:
  auto j = decltype(i){};

This fixes llvm.org/PR19892.

Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=210013&r1=210012&r2=210013&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jun  2 05:57:55 2014
@@ -1493,7 +1493,8 @@ bool TokenAnnotator::spaceRequiredBetwee
   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)

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=210013&r1=210012&r2=210013&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jun  2 05:57:55 2014
@@ -4798,8 +4798,8 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
   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, LayoutCallsInsideBrac
 }
 
 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, LayoutCxx11BraceIniti
 
   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, DoNotCreateUnreasonab
   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"
                "}");
 }





More information about the cfe-commits mailing list