summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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