forked from OSchip/llvm-project
clang-format: Don't hang forever when encountering a stray "}" in an @implementation block.
PR18406. llvm-svn: 198770
This commit is contained in:
parent
7620b6628b
commit
e21cb74224
|
@ -1255,6 +1255,10 @@ void UnwrappedLineParser::parseObjCUntilAtEnd() {
|
||||||
parseBlock(/*MustBeDeclaration=*/false);
|
parseBlock(/*MustBeDeclaration=*/false);
|
||||||
// In ObjC interfaces, nothing should be following the "}".
|
// In ObjC interfaces, nothing should be following the "}".
|
||||||
addUnwrappedLine();
|
addUnwrappedLine();
|
||||||
|
} else if (FormatTok->is(tok::r_brace)) {
|
||||||
|
// Ignore stray "}". parseStructuralElement doesn't consume them.
|
||||||
|
nextToken();
|
||||||
|
addUnwrappedLine();
|
||||||
} else {
|
} else {
|
||||||
parseStructuralElement();
|
parseStructuralElement();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5596,6 +5596,10 @@ TEST_F(FormatTest, FormatObjCProtocol) {
|
||||||
" int *looooooooooooooooooooooooooooongNumber;\n"
|
" int *looooooooooooooooooooooooooooongNumber;\n"
|
||||||
"@property(nonatomic, assign, readonly)\n"
|
"@property(nonatomic, assign, readonly)\n"
|
||||||
" NSString *looooooooooooooooooooooooooooongName;");
|
" NSString *looooooooooooooooooooooooooooongName;");
|
||||||
|
|
||||||
|
verifyFormat("@implementation PR18406\n"
|
||||||
|
"}\n"
|
||||||
|
"@end");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FormatTest, FormatObjCMethodDeclarations) {
|
TEST_F(FormatTest, FormatObjCMethodDeclarations) {
|
||||||
|
|
Loading…
Reference in New Issue