]> granicus.if.org Git - clang/commitdiff
clang-format: Fix endless loop on incomplete try-catch-block.
authorDaniel Jasper <djasper@google.com>
Mon, 19 Jan 2015 10:50:51 +0000 (10:50 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 19 Jan 2015 10:50:51 +0000 (10:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226447 91177308-0d34-0410-b5e6-96231b3b80d8

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

index ec04af5231be785db5bd541d4e46dd2da6fd285b..00dc1bda5382b1e6e6344166cce853d0f9267f13 100644 (file)
@@ -1198,7 +1198,7 @@ void UnwrappedLineParser::parseTryCatch() {
         parseParens();
         continue;
       }
-      if (FormatTok->isOneOf(tok::semi, tok::r_brace))
+      if (FormatTok->isOneOf(tok::semi, tok::r_brace, tok::eof))
         return;
       nextToken();
     }
index e1484b7239cd093263d1ff90e9f5aaa34400d3e3..5f8fba26e5a4922e745a42e3f23558d188a5c6e7 100644 (file)
@@ -2230,6 +2230,9 @@ TEST_F(FormatTest, FormatTryCatch) {
                "    throw;\n"
                "  }\n"
                "};\n");
+
+  // Incomplete try-catch blocks.
+  verifyFormat("try {} catch (");
 }
 
 TEST_F(FormatTest, IncompleteTryCatchBlocks) {