Partial fix for #9384 varid 0 with lambda (II) (#3889)

* Partial fix for #9384 varid 0 with lamba

* Format

* Undo

* Undo

* Partial fix for #9384 varid 0 with lambda (II)
This commit is contained in:
chrchr-github 2022-03-12 06:17:37 +01:00 committed by GitHub
parent 4c85ac0d7b
commit d1f740a289
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -3512,7 +3512,7 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map<std::stri
if (Token::Match(tok2, "> %name% )")) {
if (Token::Match(tok2->linkAt(2)->previous(), "if|for|while ("))
return false;
if (!Token::Match(tok2->linkAt(2)->previous(), "%name% ("))
if (!Token::Match(tok2->linkAt(2)->previous(), "%name%|] ("))
return false;
}
} else if (Token::Match(tok2, "&|&&")) {
@ -5232,6 +5232,14 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
// Link < with >
createLinks2();
if (mTimerResults) {
Timer t("Tokenizer::tokenize::setVarId (2)", mSettings->showtime, mTimerResults);
setVarId();
}
else {
setVarId();
}
// Mark C++ casts
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (Token::Match(tok, "const_cast|dynamic_cast|reinterpret_cast|static_cast <") && Token::simpleMatch(tok->linkAt(1), "> (")) {

View File

@ -2636,7 +2636,7 @@ private:
{
const char code[] = "auto g = [](std::function<void()> p) {};\n";
const char exp[] = "1: auto g@1 ; g@1 = [ ] ( std :: function < void ( ) > p@2 ) { } ;\n";
TODO_ASSERT_EQUALS(exp, "1: auto g@1 ; g@1 = [ ] ( std :: function < void ( ) > p ) { } ;\n", tokenize(code));
ASSERT_EQUALS(exp, tokenize(code));
}
}