tooBigBitwiseShift: check all calculations, not only in function bodies

This commit is contained in:
Daniel Marjamäki 2017-09-19 08:50:19 +02:00
parent 696c5b8100
commit 0cf551351b
1 changed files with 25 additions and 30 deletions

View File

@ -57,11 +57,7 @@ void CheckType::checkTooBigBitwiseShift()
if (_settings->platformType == Settings::Unspecified)
return;
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
const std::size_t functions = symbolDatabase->functionScopes.size();
for (std::size_t i = 0; i < functions; ++i) {
const Scope * scope = symbolDatabase->functionScopes[i];
for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
// C++ and macro: OUT(x<<y)
if (_tokenizer->isCPP() && Token::Match(tok, "[;{}] %name% (") && Token::simpleMatch(tok->linkAt(2), ") ;") && tok->next()->isUpperCaseName() && !tok->next()->function())
tok = tok->linkAt(2);
@ -91,7 +87,6 @@ void CheckType::checkTooBigBitwiseShift()
if (value && _settings->isEnabled(value, false))
tooBigBitwiseShiftError(tok, lhsbits, *value);
}
}
}
void CheckType::tooBigBitwiseShiftError(const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits)