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,7 +404,8 @@ void UnwrappedLineParser::parseParens() {
|
||||||
void UnwrappedLineParser::parseIfThenElse() {
|
void UnwrappedLineParser::parseIfThenElse() {
|
||||||
assert(FormatTok.Tok.is(tok::kw_if) && "'if' expected");
|
assert(FormatTok.Tok.is(tok::kw_if) && "'if' expected");
|
||||||
nextToken();
|
nextToken();
|
||||||
parseParens();
|
if (FormatTok.Tok.is(tok::l_paren))
|
||||||
|
parseParens();
|
||||||
bool NeedsUnwrappedLine = false;
|
bool NeedsUnwrappedLine = false;
|
||||||
if (FormatTok.Tok.is(tok::l_brace)) {
|
if (FormatTok.Tok.is(tok::l_brace)) {
|
||||||
parseBlock();
|
parseBlock();
|
||||||
|
|
|
@ -1108,6 +1108,10 @@ TEST_F(FormatTest, IncorrectCodeDoNoWhile) {
|
||||||
"}");
|
"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(FormatTest, IncorrectIf) {
|
||||||
|
verifyFormat("if {\n foo;\n foo();\n}");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(FormatTest, DoesNotTouchUnwrappedLinesWithErrors) {
|
TEST_F(FormatTest, DoesNotTouchUnwrappedLinesWithErrors) {
|
||||||
verifyFormat("namespace {\n"
|
verifyFormat("namespace {\n"
|
||||||
"class Foo { Foo ( }; } // comment");
|
"class Foo { Foo ( }; } // comment");
|
||||||
|
|
Loading…
Reference in New Issue