summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-01-19 07:46:32 +0000
committerDaniel Jasper <djasper@google.com>2014-01-19 07:46:32 +0000
commit31745731e86f09c4019844733af5a40f3ca701f7 (patch)
tree9532c55f92d637b1353ac0a7ef2a568e94df68d5
parent62fd6778f535683299de4866f11766a5d10f03cf (diff)
downloadbcm5719-llvm-31745731e86f09c4019844733af5a40f3ca701f7.tar.gz
bcm5719-llvm-31745731e86f09c4019844733af5a40f3ca701f7.zip
clang-format: Fix ObjC block as first call parameter formatting.
Before: foo (^{ bar(); }); After: foo(^{ bar(); }); llvm-svn: 199573
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp11
2 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index d80e5504949..45d60726dcb 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -171,6 +171,8 @@ private:
}
if (CurrentToken->isOneOf(tok::r_square, tok::r_brace))
return false;
+ else if (CurrentToken->is(tok::l_brace))
+ Left->Type = TT_Unknown; // Not TT_ObjCBlockLParen
updateParameterCount(Left, CurrentToken);
if (CurrentToken->is(tok::comma) && CurrentToken->Next &&
!CurrentToken->Next->HasUnescapedNewline &&
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 0fade5b42f0..cff28d456ce 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5404,11 +5404,6 @@ TEST_F(FormatTest, FormatForObjectiveCMethodDecls) {
verifyGoogleFormat("- foo:(int)foo;");
}
-TEST_F(FormatTest, FormatObjCBlocks) {
- verifyFormat("int (^Block)(int, int);");
- verifyFormat("int (^Block1)(int, int) = ^(int i, int j)");
-}
-
TEST_F(FormatTest, FormatObjCInterface) {
verifyFormat("@interface Foo : NSObject <NSSomeDelegate> {\n"
"@public\n"
@@ -7905,6 +7900,12 @@ TEST_F(FormatTest, FormatsLambdas) {
}
TEST_F(FormatTest, FormatsBlocks) {
+ verifyFormat("int (^Block)(int, int);");
+ verifyFormat("int (^Block1)(int, int) = ^(int i, int j)");
+
+ verifyFormat("foo(^{ bar(); });");
+ verifyFormat("foo(a, ^{ bar(); });");
+
// FIXME: Make whitespace formatting consistent. Ask a ObjC dev how
// it would ideally look.
verifyFormat("[operation setCompletionBlock:^{ [self onOperationDone]; }];");
OpenPOWER on IntegriCloud