summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-01-19 10:50:51 +0000
committerDaniel Jasper <djasper@google.com>2015-01-19 10:50:51 +0000
commit2bd7a64d127785d9ee4b5644f92f0d1eabf603e0 (patch)
treec8aac2757dd026e5badfb65a3ab469a8fa61b5b1
parentb1567c106f6baa4f34174c09bf8adf03d2c28cef (diff)
downloadbcm5719-llvm-2bd7a64d127785d9ee4b5644f92f0d1eabf603e0.tar.gz
bcm5719-llvm-2bd7a64d127785d9ee4b5644f92f0d1eabf603e0.zip
clang-format: Fix endless loop on incomplete try-catch-block.
llvm-svn: 226447
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp3
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index ec04af5231b..00dc1bda538 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -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();
}
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index e1484b7239c..5f8fba26e5a 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2230,6 +2230,9 @@ TEST_F(FormatTest, FormatTryCatch) {
" throw;\n"
" }\n"
"};\n");
+
+ // Incomplete try-catch blocks.
+ verifyFormat("try {} catch (");
}
TEST_F(FormatTest, IncompleteTryCatchBlocks) {
OpenPOWER on IntegriCloud