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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189453
91177308-0d34-0410-b5e6-
96231b3b80d8
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());
}
verifyFormat("@implementation Foo (HackStuff)\n"
"+ (id)init {\n}\n"
"@end");
+ verifyFormat("@implementation ObjcClass\n"
+ "- (void)method;\n"
+ "{}\n"
+ "@end");
}
TEST_F(FormatTest, FormatObjCProtocol) {