]> granicus.if.org Git - clang/commitdiff
clang-format: Don't hang forever when encountering a stray "}" in an @implementation...
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 8 Jan 2014 15:59:42 +0000 (15:59 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 8 Jan 2014 15:59:42 +0000 (15:59 +0000)
PR18406.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198770 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTest.cpp

index 0087e5eabe78f213f7d8aa10e1921c864dea96dd..ec7c5dd0eef37a1144abac8187048c31814fc7c1 100644 (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();
     }
index 756c71cf3c24a51c0e26587b80c697721e65ca4f..ea215ab75761ecd4f466d97e971de0f205d4a70e 100644 (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) {