simplify known value: insert known variable value into calculations
This commit is contained in:
parent
881460f71b
commit
17fbab018c
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue