]> granicus.if.org Git - clang/commitdiff
clang-format: Fix regression introduced by r237565.
authorDaniel Jasper <djasper@google.com>
Mon, 18 May 2015 14:12:24 +0000 (14:12 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 18 May 2015 14:12:24 +0000 (14:12 +0000)
Before:
  class C : public D {
    SomeClass SC { 2 };
  };

After:
  class C : public D {
    SomeClass SC{2};
  };

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237568 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTest.cpp

index d0a8cfbe69f7e5946b64e4a9f435e64ec200c4c6..2331305cc5397715f46f240971cbe5eae903a183 100644 (file)
@@ -351,7 +351,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
                 NextTok->isOneOf(tok::comma, tok::period, tok::colon,
                                  tok::r_paren, tok::r_square, tok::l_brace,
                                  tok::l_paren, tok::ellipsis) ||
-                (NextTok->is(tok::semi) && !ExpectClassBody) ||
+                (NextTok->is(tok::semi) &&
+                 (!ExpectClassBody || LBraceStack.size() != 1)) ||
                 (NextTok->isBinaryOperator() && !NextIsObjCMethod);
           }
           if (ProbablyBracedList) {
index 00c23b5bcc10c20a3312eec5243d896c256158bc..0bb1bc151a0b12514f08be0a7b91e57202183fce 100644 (file)
@@ -6192,6 +6192,9 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
                "        aaaa,\n"
                "    },\n"
                "};");
+  verifyFormat("class C : public D {\n"
+               "  SomeClass SC{2};\n"
+               "};");
 
   // In combination with BinPackParameters = false.
   FormatStyle NoBinPacking = getLLVMStyle();