release/20.x: [clang-format] Fix a crash on formatting missing r_paren/r_brace (#138230)
Backport 79210feb2993ff9a79ef11f8a7016a527d4fcf22
This commit is contained in:
parent
2cacf46f35
commit
2d079b96a5
@ -1837,8 +1837,8 @@ void UnwrappedLineParser::parseStructuralElement(
|
||||
nextToken();
|
||||
if (FormatTok->is(tok::l_paren)) {
|
||||
parseParens();
|
||||
assert(FormatTok->Previous);
|
||||
if (FormatTok->Previous->endsSequence(tok::r_paren, tok::kw_auto,
|
||||
if (FormatTok->Previous &&
|
||||
FormatTok->Previous->endsSequence(tok::r_paren, tok::kw_auto,
|
||||
tok::l_paren)) {
|
||||
Line->SeenDecltypeAuto = true;
|
||||
}
|
||||
|
||||
@ -13962,6 +13962,8 @@ TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) {
|
||||
verifyNoCrash("struct Foo {\n"
|
||||
" operator foo(bar\n"
|
||||
"};");
|
||||
verifyNoCrash("decltype( {\n"
|
||||
" {");
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, IncorrectUnbalancedBracesInMacrosWithUnicode) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user