simplify known value: insert known variable value into calculations

This commit is contained in:
Daniel Marjamäki 2009-02-14 06:11:37 +00:00
parent 881460f71b
commit 17fbab018c
2 changed files with 12 additions and 0 deletions

View File

@ -37,6 +37,7 @@
#include <cstring>
#include <fstream>
#include <map>
#include <iomanip>
//---------------------------------------------------------------------------
@ -333,6 +334,9 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
_tokenizer.simplifyTokenList();
// Write simplified token list to a file..
std::cout << _tokenizer.tokens()->stringifyList(true) << std::endl;
if (_settings._unusedFunctions)
_checkFunctionUsage.parseTokens(_tokenizer);

View File

@ -1570,6 +1570,14 @@ bool Tokenizer::simplifyKnownVariables()
tok3->str(tok2->strAt(2));
ret = true;
}
// Variable is used in calculation..
if (Token::Match(tok3, "[=+-*/] %varid% [+-*/;]", varid))
{
tok3 = tok3->next();
tok3->str(tok2->strAt(2));
ret = true;
}
}
}
}