]> granicus.if.org Git - clang/commitdiff
clang-format: Fix incorrect multi-block-parameter computation.
authorDaniel Jasper <djasper@google.com>
Tue, 8 Apr 2014 14:04:31 +0000 (14:04 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 8 Apr 2014 14:04:31 +0000 (14:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205763 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index f890af33debb306d054825a66dcd66f91dcd2f2a..a7536d2d244dd8823b8f3d82c174f4aebe0e3589 100644 (file)
@@ -727,10 +727,9 @@ private:
                                   Contexts.back().InTemplateArgument);
       } else if (Current.isOneOf(tok::minus, tok::plus, tok::caret)) {
         Current.Type = determinePlusMinusCaretUsage(Current);
-        if (Current.Type == TT_UnaryOperator) {
+        if (Current.Type == TT_UnaryOperator && Current.is(tok::caret)) {
           ++Contexts.back().NumBlockParameters;
-          if (Current.is(tok::caret))
-            Contexts.back().CaretFound = true;
+          Contexts.back().CaretFound = true;
         }
       } else if (Current.isOneOf(tok::minusminus, tok::plusplus)) {
         Current.Type = determineIncrementUsage(Current);
index c7bd44c12d2931c0eecbc4c724d00cf570c1bf54..975f9c6939b65a48c48ede0c2da46ca034716528 100644 (file)
@@ -8249,6 +8249,12 @@ TEST_F(FormatTest, FormatsBlocks) {
                "        // ...\n"
                "        int i;\n"
                "    }];");
+  verifyFormat("[myObject doSomethingWith:arg1\n"
+               "               firstBlock:-1\n"
+               "              secondBlock:^(Bar *b) {\n"
+               "                  // ...\n"
+               "                  int i;\n"
+               "              }];");
 
   verifyFormat("f(^{\n"
                "    @autoreleasepool {\n"