Implement parsing of blocks (^{ ... }) in the unwrapped line parser.
This patch makes sure we produce the right number of unwrapped lines,
a follow-up patch will make the whitespace formatting consistent.
Before:
void f() {
int i = {[operation setCompletionBlock : ^{ [self onOperationDone];
}]
}
;
}
After:
void f() {
int i = {[operation setCompletionBlock : ^{
[self onOperationDone];
}] };
}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189932 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index d2b2dfd..32226fc 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -6311,5 +6311,16 @@
"}\n");
}
+TEST_F(FormatTest, FormatsBlocks) {
+ // FIXME: Make whitespace formatting consistent. Ask a ObjC dev how
+ // it would ideally look.
+ verifyFormat("[operation setCompletionBlock:^{\n"
+ " [self onOperationDone];\n"
+ "}];\n");
+ verifyFormat("int i = {[operation setCompletionBlock : ^{\n"
+ " [self onOperationDone];\n"
+ "}] };\n");
+}
+
} // end namespace tooling
} // end namespace clang