r220270 - clang-format: [ObjC] Fix spacing in block variable parameters.

Daniel Jasper djasper at google.com
Tue Oct 21 00:57:51 PDT 2014


Author: djasper
Date: Tue Oct 21 02:57:50 2014
New Revision: 220270

URL: http://llvm.org/viewvc/llvm-project?rev=220270&view=rev
Log:
clang-format: [ObjC] Fix spacing in block variable parameters.

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

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

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=220270&r1=220269&r2=220270&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Oct 21 02:57:50 2014
@@ -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) {

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=220270&r1=220269&r2=220270&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Oct 21 02:57:50 2014
@@ -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 "





More information about the cfe-commits mailing list