Move the simplification of 'strlen' in simplifyTokenList.

This way it's possible to omit the call to simplifyKnownVariables before 'strlen'.
This commit is contained in:
Edoardo Prezioso 2011-10-27 01:24:35 +02:00
parent aa74761e8d
commit 1be1af4afb
1 changed files with 12 additions and 13 deletions

View File

@ -3992,19 +3992,6 @@ bool Tokenizer::simplifyTokenList()
simplifySizeof();
// replace strlen(str)
simplifyKnownVariables();
for (Token *tok = _tokens; tok; tok = tok->next()) {
if (Token::Match(tok, "strlen ( %str% )")) {
std::ostringstream ostr;
ostr << Token::getStrLength(tok->tokAt(2));
tok->str(ostr.str());
tok->deleteNext();
tok->deleteNext();
tok->deleteNext();
}
}
// change array to pointer..
for (Token *tok = _tokens; tok; tok = tok->next()) {
if (Token::Match(tok, "%type% %var% [ ] [,;=]")) {
@ -4155,6 +4142,18 @@ bool Tokenizer::simplifyTokenList()
modified |= simplifyCalculations();
}
// replace strlen(str)
for (Token *tok = _tokens; tok; tok = tok->next()) {
if (Token::Match(tok, "strlen ( %str% )")) {
std::ostringstream ostr;
ostr << Token::getStrLength(tok->tokAt(2));
tok->str(ostr.str());
tok->deleteNext();
tok->deleteNext();
tok->deleteNext();
}
}
// simplify redundant for
removeRedundantFor();