Support lambdas in "else if" simplification (#6860)
This commit is contained in:
parent
8d8c03dad8
commit
6485339d66
|
@ -6899,12 +6899,9 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign
|
|||
void Tokenizer::elseif()
|
||||
{
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "(|[") ||
|
||||
(tok->str() == "{" && tok->previous() && tok->previous()->str() == "="))
|
||||
tok = tok->link();
|
||||
|
||||
if (!Token::simpleMatch(tok, "else if"))
|
||||
continue;
|
||||
|
||||
for (Token *tok2 = tok; tok2; tok2 = tok2->next()) {
|
||||
if (Token::Match(tok2, "(|{|["))
|
||||
tok2 = tok2->link();
|
||||
|
|
|
@ -833,6 +833,23 @@ private:
|
|||
"}";
|
||||
ASSERT_EQUALS(tok(expected), tok(src));
|
||||
}
|
||||
|
||||
// Ticket #6860 - lambdas
|
||||
{
|
||||
const char src[] = "( []{if (ab) {cd}else if(ef) { gh } else { ij }kl}() )";
|
||||
const char expected[] = "\n\n##file 0\n1: ( [ ] { if ( ab ) { cd } else { if ( ef ) { gh } else { ij } } kl } ( ) )\n";
|
||||
ASSERT_EQUALS(expected, elseif(src));
|
||||
}
|
||||
{
|
||||
const char src[] = "[ []{if (ab) {cd}else if(ef) { gh } else { ij }kl}() ]";
|
||||
const char expected[] = "\n\n##file 0\n1: [ [ ] { if ( ab ) { cd } else { if ( ef ) { gh } else { ij } } kl } ( ) ]\n";
|
||||
ASSERT_EQUALS(expected, elseif(src));
|
||||
}
|
||||
{
|
||||
const char src[] = "= { []{if (ab) {cd}else if(ef) { gh } else { ij }kl}() }";
|
||||
const char expected[] = "\n\n##file 0\n1: = { [ ] { if ( ab ) { cd } else { if ( ef ) { gh } else { ij } } kl } ( ) }\n";
|
||||
ASSERT_EQUALS(expected, elseif(src));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue