diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-01-08 15:59:42 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-01-08 15:59:42 +0000 |
commit | e21cb742249979c7e4584fded47e9da2445ebcd9 (patch) | |
tree | 9be6317efb0c58725ce153bd80a2f81afbd56c09 | |
parent | 7620b6628b5d99d8a0915c85814ba22b10cd305d (diff) | |
download | bcm5719-llvm-e21cb742249979c7e4584fded47e9da2445ebcd9.tar.gz bcm5719-llvm-e21cb742249979c7e4584fded47e9da2445ebcd9.zip |
clang-format: Don't hang forever when encountering a stray "}" in an @implementation block.
PR18406.
llvm-svn: 198770
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 0087e5eabe7..ec7c5dd0eef 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -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(); } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 756c71cf3c2..ea215ab7576 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -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) { |