summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp4
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 758f8193ca4..07ad7a7489e 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -404,7 +404,8 @@ void UnwrappedLineParser::parseParens() {
void UnwrappedLineParser::parseIfThenElse() {
assert(FormatTok.Tok.is(tok::kw_if) && "'if' expected");
nextToken();
- parseParens();
+ if (FormatTok.Tok.is(tok::l_paren))
+ parseParens();
bool NeedsUnwrappedLine = false;
if (FormatTok.Tok.is(tok::l_brace)) {
parseBlock();
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 71fa83ccb14..6beee3186b7 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -1108,6 +1108,10 @@ TEST_F(FormatTest, IncorrectCodeDoNoWhile) {
"}");
}
+TEST_F(FormatTest, IncorrectIf) {
+ verifyFormat("if {\n foo;\n foo();\n}");
+}
+
TEST_F(FormatTest, DoesNotTouchUnwrappedLinesWithErrors) {
verifyFormat("namespace {\n"
"class Foo { Foo ( }; } // comment");
OpenPOWER on IntegriCloud