From d8032001b32ca849ecd02cff3053bb62134e098e Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 28 Mar 2014 07:48:59 +0000 Subject: [PATCH] clang-format: Recognize more ObjC blocks with parameters/return type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204990 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 8 ++++++-- unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index d863b5db0c..204132daae 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -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()) { diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 3d1e5a5d8e..2bf5512576 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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(); });"); -- 2.50.1