]> granicus.if.org Git - clang/commitdiff
clang-format: Prevent ObjC code from confusing the braced-init detection
authorDaniel Jasper <djasper@google.com>
Thu, 13 Mar 2014 10:11:17 +0000 (10:11 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 13 Mar 2014 10:11:17 +0000 (10:11 +0000)
This was leading to bad formatting, e.g.:
Before:
  f(^{
      @autoreleasepool {
        if (a) {
          g();
  }
  }
  });

After:
  f(^{
      @autoreleasepool {
        if (a) {
          g();
        }
      }
  });

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

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

index daf185be519e3307e0270c02e2318a628b7de6d8..a3087ed98454208f4dedde071adcc767fd552107 100644 (file)
@@ -357,6 +357,7 @@ void UnwrappedLineParser::calculateBraceTypes() {
         LBraceStack.pop_back();
       }
       break;
+    case tok::at:
     case tok::semi:
     case tok::kw_if:
     case tok::kw_while:
index 44e8bf849d38e3de51ade4d9e73e7b609bf50ea4..5d4c1172c136fda40395d770896655d3012485e4 100644 (file)
@@ -8062,6 +8062,14 @@ TEST_F(FormatTest, FormatsBlocks) {
                "        // ...\n"
                "        int i;\n"
                "    }];");
+
+  verifyFormat("f(^{\n"
+               "    @autoreleasepool {\n"
+               "      if (a) {\n"
+               "        g();\n"
+               "      }\n"
+               "    }\n"
+               "});");
 }
 
 TEST_F(FormatTest, SupportsCRLF) {