Uninitialized variables: minor refactorings

This commit is contained in:
Daniel Marjamki 2013-01-26 07:28:11 +01:00
parent ea40fb60d1
commit 04ceae7ea7
1 changed files with 6 additions and 12 deletions

View File

@ -1043,13 +1043,12 @@ void CheckUninitVar::executionPaths()
void CheckUninitVar::check()
{
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
std::list<Scope>::const_iterator func_scope;
std::list<Scope>::const_iterator scope;
// scan every function
for (func_scope = symbolDatabase->scopeList.begin(); func_scope != symbolDatabase->scopeList.end(); ++func_scope) {
// only check functions
if (func_scope->type == Scope::eFunction) {
checkScope(&*func_scope);
// check every executable scope
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
if (scope->isExecutable()) {
checkScope(&*scope);
}
}
}
@ -1067,7 +1066,7 @@ void CheckUninitVar::checkScope(const Scope* scope)
if (tok->str() == "(") {
forHead = true;
break;
} else if (tok->str() == "{" || tok->str() == ";" || tok->str() == "}")
} else if (Token::Match(tok, "[{};]"))
break;
}
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)