forked from OSchip/llvm-project
clang-format: Fix corner case in ObjC interface definitions.
In @implementation ObjcClass - (void)method; { } @end the ObjC compiler seems to accept the superfluous comma after "method", but clang-format used to assert on the subsequent "{". This fixes llvm.org/PR16604. llvm-svn: 189453
This commit is contained in:
parent
fce1b03ee7
commit
a15da3068d
|
@ -1030,7 +1030,13 @@ void UnwrappedLineParser::parseObjCUntilAtEnd() {
|
|||
addUnwrappedLine();
|
||||
break;
|
||||
}
|
||||
parseStructuralElement();
|
||||
if (FormatTok->is(tok::l_brace)) {
|
||||
parseBlock(/*MustBeDeclaration=*/false);
|
||||
// In ObjC interfaces, nothing should be following the "}".
|
||||
addUnwrappedLine();
|
||||
} else {
|
||||
parseStructuralElement();
|
||||
}
|
||||
} while (!eof());
|
||||
}
|
||||
|
||||
|
|
|
@ -4791,6 +4791,10 @@ TEST_F(FormatTest, FormatObjCImplementation) {
|
|||
verifyFormat("@implementation Foo (HackStuff)\n"
|
||||
"+ (id)init {\n}\n"
|
||||
"@end");
|
||||
verifyFormat("@implementation ObjcClass\n"
|
||||
"- (void)method;\n"
|
||||
"{}\n"
|
||||
"@end");
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, FormatObjCProtocol) {
|
||||
|
|
Loading…
Reference in New Issue