clang-format: Don't hang forever when encountering a stray "}" in an @implementation block.

PR18406.

llvm-svn: 198770
This commit is contained in:
Benjamin Kramer 2014-01-08 15:59:42 +00:00
parent 7620b6628b
commit e21cb74224
2 changed files with 8 additions and 0 deletions

View File

@ -1255,6 +1255,10 @@ void UnwrappedLineParser::parseObjCUntilAtEnd() {
parseBlock(/*MustBeDeclaration=*/false);
// In ObjC interfaces, nothing should be following the "}".
addUnwrappedLine();
} else if (FormatTok->is(tok::r_brace)) {
// Ignore stray "}". parseStructuralElement doesn't consume them.
nextToken();
addUnwrappedLine();
} else {
parseStructuralElement();
}

View File

@ -5596,6 +5596,10 @@ TEST_F(FormatTest, FormatObjCProtocol) {
" int *looooooooooooooooooooooooooooongNumber;\n"
"@property(nonatomic, assign, readonly)\n"
" NSString *looooooooooooooooooooooooooooongName;");
verifyFormat("@implementation PR18406\n"
"}\n"
"@end");
}
TEST_F(FormatTest, FormatObjCMethodDeclarations) {