Refactoring; Use range for loops
This commit is contained in:
parent
486697fc7d
commit
c7993df4ff
|
@ -1378,18 +1378,17 @@ Check::FileInfo *CheckUninitVar::getFileInfo(const Tokenizer *tokenizer, const S
|
|||
Check::FileInfo *CheckUninitVar::getFileInfo() const
|
||||
{
|
||||
const SymbolDatabase * const symbolDatabase = mTokenizer->getSymbolDatabase();
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
MyFileInfo *fileInfo = new MyFileInfo;
|
||||
|
||||
// Parse all functions in TU
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
|
||||
if (!scope->isExecutable() || scope->type != Scope::eFunction || !scope->function)
|
||||
for (const Scope &scope : symbolDatabase->scopeList) {
|
||||
if (!scope.isExecutable() || scope.type != Scope::eFunction || !scope.function)
|
||||
continue;
|
||||
const Function *const function = scope->function;
|
||||
const Function *const function = scope.function;
|
||||
|
||||
// function calls where uninitialized data is passed by address
|
||||
for (const Token *tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) {
|
||||
for (const Token *tok = scope.bodyStart; tok != scope.bodyEnd; tok = tok->next()) {
|
||||
if (tok->str() != "(" || !tok->astOperand1() || !tok->astOperand2())
|
||||
continue;
|
||||
if (!tok->astOperand1()->function())
|
||||
|
@ -1424,18 +1423,18 @@ Check::FileInfo *CheckUninitVar::getFileInfo() const
|
|||
CheckNullPointer checkNullPointer(mTokenizer, mSettings, mErrorLogger);
|
||||
for (int argnr = 0; argnr < function->argCount(); ++argnr) {
|
||||
const Token *tok;
|
||||
if (isUnsafeFunction(&*scope, argnr, &tok))
|
||||
fileInfo->readData.push_back(MyFileInfo::FunctionArg(mTokenizer, &*scope, argnr+1, tok));
|
||||
if (checkNullPointer.isUnsafeFunction(&*scope, argnr, &tok))
|
||||
fileInfo->dereferenced.push_back(MyFileInfo::FunctionArg(mTokenizer, &*scope, argnr+1, tok));
|
||||
if (isUnsafeFunction(&scope, argnr, &tok))
|
||||
fileInfo->readData.push_back(MyFileInfo::FunctionArg(mTokenizer, &scope, argnr+1, tok));
|
||||
if (checkNullPointer.isUnsafeFunction(&scope, argnr, &tok))
|
||||
fileInfo->dereferenced.push_back(MyFileInfo::FunctionArg(mTokenizer, &scope, argnr+1, tok));
|
||||
}
|
||||
|
||||
// Nested function calls
|
||||
for (int argnr = 0; argnr < function->argCount(); ++argnr) {
|
||||
const Token *tok;
|
||||
int argnr2 = isCallFunction(&*scope, argnr, &tok);
|
||||
int argnr2 = isCallFunction(&scope, argnr, &tok);
|
||||
if (argnr2 > 0) {
|
||||
MyFileInfo::FunctionArg fa(mTokenizer, &*scope, argnr+1, tok);
|
||||
MyFileInfo::FunctionArg fa(mTokenizer, &scope, argnr+1, tok);
|
||||
fa.id = FUNCTION_ID(function);
|
||||
fa.id2 = FUNCTION_ID(tok->function());
|
||||
fa.argnr2 = argnr2;
|
||||
|
|
|
@ -553,23 +553,23 @@ void CppCheck::checkRawTokens(const Tokenizer &tokenizer)
|
|||
void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
|
||||
{
|
||||
// call all "runChecks" in all registered Check classes
|
||||
for (std::list<Check *>::const_iterator it = Check::instances().begin(); it != Check::instances().end(); ++it) {
|
||||
for (Check *check : Check::instances()) {
|
||||
if (mSettings.terminated())
|
||||
return;
|
||||
|
||||
if (tokenizer.isMaxTime())
|
||||
return;
|
||||
|
||||
Timer timerRunChecks((*it)->name() + "::runChecks", mSettings.showtime, &S_timerResults);
|
||||
(*it)->runChecks(&tokenizer, &mSettings, this);
|
||||
Timer timerRunChecks(check->name() + "::runChecks", mSettings.showtime, &S_timerResults);
|
||||
check->runChecks(&tokenizer, &mSettings, this);
|
||||
}
|
||||
|
||||
// Analyse the tokens..
|
||||
for (std::list<Check *>::const_iterator it = Check::instances().begin(); it != Check::instances().end(); ++it) {
|
||||
Check::FileInfo *fi = (*it)->getFileInfo(&tokenizer, &mSettings);
|
||||
for (const Check *check : Check::instances()) {
|
||||
Check::FileInfo *fi = check->getFileInfo(&tokenizer, &mSettings);
|
||||
if (fi != nullptr) {
|
||||
mFileInfo.push_back(fi);
|
||||
mAnalyzerInformation.setFileInfo((*it)->name(), fi->toString());
|
||||
mAnalyzerInformation.setFileInfo(check->name(), fi->toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue