clang-format: [ObjC] Fix spacing in block variable parameters.
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
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 02a12bd..7fbd2f2 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -127,6 +127,9 @@
// 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) {
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 4f45136..05e0fc5 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -9162,6 +9162,7 @@
verifyFormat("foo(^{ bar(); });");
verifyFormat("foo(a, ^{ bar(); });");
+ verifyFormat("{ void (^block)(Object *x); }");
verifyFormat("[operation setCompletionBlock:^{ [self onOperationDone]; }];");
verifyFormat("int i = {[operation setCompletionBlock:^{ [self "