Uninitialized variables: minor refactorings
This commit is contained in:
parent
ea40fb60d1
commit
04ceae7ea7
|
@ -1043,13 +1043,12 @@ void CheckUninitVar::executionPaths()
|
||||||
void CheckUninitVar::check()
|
void CheckUninitVar::check()
|
||||||
{
|
{
|
||||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
std::list<Scope>::const_iterator func_scope;
|
std::list<Scope>::const_iterator scope;
|
||||||
|
|
||||||
// scan every function
|
// check every executable scope
|
||||||
for (func_scope = symbolDatabase->scopeList.begin(); func_scope != symbolDatabase->scopeList.end(); ++func_scope) {
|
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
|
||||||
// only check functions
|
if (scope->isExecutable()) {
|
||||||
if (func_scope->type == Scope::eFunction) {
|
checkScope(&*scope);
|
||||||
checkScope(&*func_scope);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1067,7 +1066,7 @@ void CheckUninitVar::checkScope(const Scope* scope)
|
||||||
if (tok->str() == "(") {
|
if (tok->str() == "(") {
|
||||||
forHead = true;
|
forHead = true;
|
||||||
break;
|
break;
|
||||||
} else if (tok->str() == "{" || tok->str() == ";" || tok->str() == "}")
|
} else if (Token::Match(tok, "[{};]"))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (forHead)
|
if (forHead)
|
||||||
|
@ -1095,11 +1094,6 @@ void CheckUninitVar::checkScope(const Scope* scope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::list<Scope*>::const_iterator i = scope->nestedList.begin(); i != scope->nestedList.end(); ++i) {
|
|
||||||
if (!(*i)->isClassOrStruct())
|
|
||||||
checkScope(*i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void conditionAlwaysTrueOrFalse(const Token *tok, const std::map<unsigned int, int> &variableValue, bool *alwaysTrue, bool *alwaysFalse)
|
static void conditionAlwaysTrueOrFalse(const Token *tok, const std::map<unsigned int, int> &variableValue, bool *alwaysTrue, bool *alwaysFalse)
|
||||||
|
|
Loading…
Reference in New Issue