forked from OSchip/llvm-project
Fix crash on invalid.
if { foo; } would previously crash clang-format. llvm-svn: 172232
This commit is contained in:
parent
d5e5f8f2a4
commit
adededff26
|
@ -404,6 +404,7 @@ void UnwrappedLineParser::parseParens() {
|
|||
void UnwrappedLineParser::parseIfThenElse() {
|
||||
assert(FormatTok.Tok.is(tok::kw_if) && "'if' expected");
|
||||
nextToken();
|
||||
if (FormatTok.Tok.is(tok::l_paren))
|
||||
parseParens();
|
||||
bool NeedsUnwrappedLine = false;
|
||||
if (FormatTok.Tok.is(tok::l_brace)) {
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue