forked from OSchip/llvm-project
clang-format: Recognize more ObjC blocks with parameters/return type.
llvm-svn: 204990
This commit is contained in:
parent
ba539d8dc8
commit
395193c7a0
|
@ -694,9 +694,13 @@ void UnwrappedLineParser::parseStructuralElement() {
|
||||||
break;
|
break;
|
||||||
case tok::caret:
|
case tok::caret:
|
||||||
nextToken();
|
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();
|
parseChildBlock();
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case tok::l_brace:
|
case tok::l_brace:
|
||||||
if (!tryToParseBracedList()) {
|
if (!tryToParseBracedList()) {
|
||||||
|
|
|
@ -8125,6 +8125,10 @@ TEST_F(FormatTest, FormatsLambdas) {
|
||||||
TEST_F(FormatTest, FormatsBlocks) {
|
TEST_F(FormatTest, FormatsBlocks) {
|
||||||
verifyFormat("int (^Block)(int, int);");
|
verifyFormat("int (^Block)(int, int);");
|
||||||
verifyFormat("int (^Block1)(int, int) = ^(int i, int j)");
|
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(^{ bar(); });");
|
||||||
verifyFormat("foo(a, ^{ bar(); });");
|
verifyFormat("foo(a, ^{ bar(); });");
|
||||||
|
|
Loading…
Reference in New Issue