]> granicus.if.org Git - clang/commitdiff
clang-format: [ObjC] Fix spacing in block variable parameters.
authorDaniel Jasper <djasper@google.com>
Tue, 21 Oct 2014 07:57:50 +0000 (07:57 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 21 Oct 2014 07:57:50 +0000 (07:57 +0000)
Before:
  { void (^block)(Object * x); }

After:
  { void (^block)(Object *x); }

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

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

index 02a12bd945866c58b00e21eaea16a5059b101153..7fbd2f29d5fe9c3c3e05794275ed946564ec58ba 100644 (file)
@@ -127,6 +127,9 @@ private:
       // The first argument to a foreach macro is a declaration.
       Contexts.back().IsForEachMacro = true;
       Contexts.back().IsExpression = false;
+    } else if (Left->Previous && Left->Previous->MatchingParen &&
+               Left->Previous->MatchingParen->Type == TT_ObjCBlockLParen) {
+      Contexts.back().IsExpression = false;
     }
 
     if (StartsObjCMethodExpr) {
index 4f451361facb015c414b2cce94ec503709fc0503..05e0fc5aa89db1623960a3653d14dd9917139572 100644 (file)
@@ -9162,6 +9162,7 @@ TEST_F(FormatTest, FormatsBlocks) {
 
   verifyFormat("foo(^{ bar(); });");
   verifyFormat("foo(a, ^{ bar(); });");
+  verifyFormat("{ void (^block)(Object *x); }");
 
   verifyFormat("[operation setCompletionBlock:^{ [self onOperationDone]; }];");
   verifyFormat("int i = {[operation setCompletionBlock:^{ [self "