From 504432e5526a6183f20d19d82d0b7f12144e7a38 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 21 Oct 2014 07:57:50 +0000 Subject: [PATCH] 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 --- lib/Format/TokenAnnotator.cpp | 3 +++ unittests/Format/FormatTest.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 02a12bd945..7fbd2f29d5 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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) { diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 4f451361fa..05e0fc5aa8 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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 " -- 2.50.1