Adapt %var%|%num% changes with Tokenizer, part 3.
This commit is contained in:
parent
bd63db62af
commit
f8e4af9ce2
|
@ -4820,10 +4820,8 @@ bool Tokenizer::simplifyFunctionReturn()
|
||||||
if (tok->str() == "{")
|
if (tok->str() == "{")
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
|
|
||||||
else if (Token::Match(tok, "%var% ( ) { return %any% ; }")) {
|
else if (Token::Match(tok, "%var% ( ) { return %bool%|%char%|%num%|%str% ; }")) {
|
||||||
const Token* const any = tok->tokAt(5);
|
const Token* const any = tok->tokAt(5);
|
||||||
if (!any->isNumber() && !any->isBoolean() && any->str()[0] != '"')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const std::string pattern("(|[|=|%op% " + tok->str() + " ( ) ;|]|)|%op%");
|
const std::string pattern("(|[|=|%op% " + tok->str() + " ( ) ;|]|)|%op%");
|
||||||
for (Token *tok2 = list.front(); tok2; tok2 = tok2->next()) {
|
for (Token *tok2 = list.front(); tok2; tok2 = tok2->next()) {
|
||||||
|
@ -5464,8 +5462,7 @@ void Tokenizer::simplifyIfAssign()
|
||||||
void Tokenizer::simplifyVariableMultipleAssign()
|
void Tokenizer::simplifyVariableMultipleAssign()
|
||||||
{
|
{
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "%var% = %var% = %num% ;") ||
|
if (Token::Match(tok, "%var% = %var% = %num%|%var% ;")) {
|
||||||
Token::Match(tok, "%var% = %var% = %var% ;")) {
|
|
||||||
// skip intermediate assignments
|
// skip intermediate assignments
|
||||||
Token *tok2 = tok->previous();
|
Token *tok2 = tok->previous();
|
||||||
while (tok2 &&
|
while (tok2 &&
|
||||||
|
@ -5807,7 +5804,7 @@ bool Tokenizer::simplifyKnownVariables()
|
||||||
|
|
||||||
const Token * const vartok = (tok->next() && tok->next()->str() == "const") ? tok->tokAt(2) : tok->next();
|
const Token * const vartok = (tok->next() && tok->next()->str() == "const") ? tok->tokAt(2) : tok->next();
|
||||||
const Token * const valuetok = vartok->tokAt(2);
|
const Token * const valuetok = vartok->tokAt(2);
|
||||||
if (valuetok->isNumber() || Token::Match(valuetok, "%str% ;")) {
|
if (Token::Match(valuetok, "%bool%|%char%|%num%|%str% ;")) {
|
||||||
constantValues[vartok->varId()] = valuetok->str();
|
constantValues[vartok->varId()] = valuetok->str();
|
||||||
|
|
||||||
// remove statement
|
// remove statement
|
||||||
|
@ -5853,13 +5850,9 @@ bool Tokenizer::simplifyKnownVariables()
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (tok2->previous()->str() != "*" &&
|
else if (tok2->previous()->str() != "*" &&
|
||||||
(Token::Match(tok2, "%var% = %num% ;") ||
|
(Token::Match(tok2, "%var% = %bool%|%char%|%num%|%str%|%var% ;") ||
|
||||||
Token::Match(tok2, "%var% = %str% ;") ||
|
|
||||||
Token::Match(tok2, "%var% = %char% ;") ||
|
|
||||||
Token::Match(tok2, "%var% [ ] = %str% ;") ||
|
Token::Match(tok2, "%var% [ ] = %str% ;") ||
|
||||||
Token::Match(tok2, "%var% [ %num% ] = %str% ;") ||
|
Token::Match(tok2, "%var% [ %num% ] = %str% ;") ||
|
||||||
Token::Match(tok2, "%var% = %bool% ;") ||
|
|
||||||
Token::Match(tok2, "%var% = %var% ;") ||
|
|
||||||
Token::Match(tok2, "%var% = & %var% ;") ||
|
Token::Match(tok2, "%var% = & %var% ;") ||
|
||||||
Token::Match(tok2, "%var% = & %var% [ 0 ] ;"))) {
|
Token::Match(tok2, "%var% = & %var% [ 0 ] ;"))) {
|
||||||
const unsigned int varid = tok2->varId();
|
const unsigned int varid = tok2->varId();
|
||||||
|
|
Loading…
Reference in New Issue