clang-format: Recognize more ObjC blocks with parameters/return type.

llvm-svn: 204990
This commit is contained in:
Daniel Jasper 2014-03-28 07:48:59 +00:00
parent ba539d8dc8
commit 395193c7a0
2 changed files with 10 additions and 2 deletions

View File

@ -694,9 +694,13 @@ void UnwrappedLineParser::parseStructuralElement() {
break;
case tok::caret:
nextToken();
if (FormatTok->is(tok::l_brace)) {
if (FormatTok->Tok.isAnyIdentifier() ||
FormatTok->isSimpleTypeSpecifier())
nextToken();
if (FormatTok->is(tok::l_paren))
parseParens();
if (FormatTok->is(tok::l_brace))
parseChildBlock();
}
break;
case tok::l_brace:
if (!tryToParseBracedList()) {

View File

@ -8125,6 +8125,10 @@ TEST_F(FormatTest, FormatsLambdas) {
TEST_F(FormatTest, FormatsBlocks) {
verifyFormat("int (^Block)(int, int);");
verifyFormat("int (^Block1)(int, int) = ^(int i, int j)");
verifyFormat("void (^block)(int) = ^(id test) { int i; };");
verifyFormat("void (^block)(int) = ^(int test) { int i; };");
verifyFormat("void (^block)(int) = ^id(int test) { int i; };");
verifyFormat("void (^block)(int) = ^int(int test) { int i; };");
verifyFormat("foo(^{ bar(); });");
verifyFormat("foo(a, ^{ bar(); });");