Adapt %var%|%num% changes with Tokenizer, part 2.
This commit is contained in:
parent
2b4215ea7a
commit
bd63db62af
|
@ -3287,11 +3287,8 @@ bool Tokenizer::simplifyTokenList()
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (!Token::Match(tok, "%var%")
|
if (!Token::Match(tok, "%num%|%var%") && !Token::Match(tok, "]|)") &&
|
||||||
&& !Token::Match(tok, "%num%")
|
(Token::Match(tok->next(), "& %var% [ %num%|%var% ]"))) {
|
||||||
&& !Token::Match(tok, "]|)")
|
|
||||||
&& (Token::Match(tok->next(), "& %var% [ %num% ]") ||
|
|
||||||
Token::Match(tok->next(), "& %var% [ %var% ]"))) {
|
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
|
||||||
if (tok->next()->varId()) {
|
if (tok->next()->varId()) {
|
||||||
|
@ -3506,9 +3503,7 @@ void Tokenizer::removeRedundantAssignment()
|
||||||
tok2 = tok2->tokAt(2);
|
tok2 = tok2->tokAt(2);
|
||||||
localvars.insert(tok2->varId());
|
localvars.insert(tok2->varId());
|
||||||
} else if (tok2->varId() &&
|
} else if (tok2->varId() &&
|
||||||
!Token::Match(tok2->previous(), "[;{}] %var% = %var% ;") &&
|
!Token::Match(tok2->previous(), "[;{}] %var% = %char%|%num%|%var% ;")) {
|
||||||
!Token::Match(tok2->previous(), "[;{}] %var% = %num% ;") &&
|
|
||||||
!Token::Match(tok2->previous(), "[;{}] %var% = %char% ;")) {
|
|
||||||
localvars.erase(tok2->varId());
|
localvars.erase(tok2->varId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4231,7 +4226,7 @@ bool Tokenizer::simplifyConditions()
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "! %num%") || Token::Match(tok, "! %bool%")) {
|
if (Token::Match(tok, "! %bool%|%num%")) {
|
||||||
tok->deleteThis();
|
tok->deleteThis();
|
||||||
if (tok->str() == "0" || tok->str() == "false")
|
if (tok->str() == "0" || tok->str() == "false")
|
||||||
tok->str("true");
|
tok->str("true");
|
||||||
|
@ -4381,13 +4376,13 @@ bool Tokenizer::simplifyConstTernaryOp()
|
||||||
if (tok->str() != "?")
|
if (tok->str() != "?")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!Token::Match(tok->tokAt(-2), "=|,|(|[|{|}|;|case|return %any%") &&
|
if (!Token::Match(tok->tokAt(-2), "<|=|,|(|[|{|}|;|case|return %bool%|%num%") &&
|
||||||
!Token::Match(tok->tokAt(-4), "=|,|(|[|{|}|;|case|return ( %any% )"))
|
!Token::Match(tok->tokAt(-4), "<|=|,|(|[|{|}|;|case|return ( %bool%|%num% )"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const unsigned int offset = (tok->previous()->str() == ")") ? 2 : 1;
|
const unsigned int offset = (tok->previous()->str() == ")") ? 2 : 1;
|
||||||
|
|
||||||
if (!tok->tokAt(-offset)->isBoolean() && !tok->tokAt(-offset)->isNumber())
|
if (tok->strAt(-2*offset) == "<" && !TemplateSimplifier::templateParameters(tok->tokAt(-2*offset)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Find the token ":" then go to the next token
|
// Find the token ":" then go to the next token
|
||||||
|
|
Loading…
Reference in New Issue