Refactoring, use early continue

This commit is contained in:
Daniel Marjamäki 2018-04-05 08:21:43 +02:00
parent 67a71fa362
commit 3ad6c7ebce
4 changed files with 131 additions and 131 deletions

View File

@ -1324,7 +1324,8 @@ void CheckBufferOverrun::checkStructVariable()
const Scope * scope = symbolDatabase->classAndStructScopes[i];
for (std::list<Variable>::const_iterator var = scope->varlist.begin(); var != scope->varlist.end(); ++var) {
if (var->isArray()) {
if (!var->isArray())
continue;
// create ArrayInfo from the array variable
ArrayInfo arrayInfo(&*var, symbolDatabase);
@ -1471,7 +1472,6 @@ void CheckBufferOverrun::checkStructVariable()
}
}
}
}
}
//---------------------------------------------------------------------------

View File

@ -2701,7 +2701,7 @@ void CheckMemoryLeakNoVar::checkForUnusedReturnValue(const Scope *scope)
if (!parent) {
// Check if we are in a C++11 constructor
const Token * closingBrace = Token::findmatch(tok, "}|;");
if(closingBrace->str() == "}" && Token::Match(closingBrace->link()->tokAt(-1), "%name%"))
if (closingBrace->str() == "}" && Token::Match(closingBrace->link()->tokAt(-1), "%name%"))
continue;
returnValueNotUsedError(tok, tok->str());
} else if (Token::Match(parent, "%comp%|!")) {

View File

@ -2421,11 +2421,11 @@ static void valueFlowAfterCondition(TokenList *tokenlist, SymbolDatabase* symbol
continue;
}
if(numtok && !numtok->hasKnownIntValue())
if (numtok && !numtok->hasKnownIntValue())
continue;
if(lowertok && !lowertok->hasKnownIntValue())
if (lowertok && !lowertok->hasKnownIntValue())
continue;
if(uppertok && !uppertok->hasKnownIntValue())
if (uppertok && !uppertok->hasKnownIntValue())
continue;
const unsigned int varid = vartok->varId();
@ -2441,13 +2441,13 @@ static void valueFlowAfterCondition(TokenList *tokenlist, SymbolDatabase* symbol
}
std::list<ValueFlow::Value> values;
// TODO: We should add all known values
if(numtok) {
if (numtok) {
values.push_back(ValueFlow::Value(tok, numtok->values().front().intvalue));
} else if(lowertok) {
} else if (lowertok) {
long long v = lowertok->values().front().intvalue;
values.push_back(ValueFlow::Value(tok, v+1));
} else if(uppertok) {
} else if (uppertok) {
long long v = uppertok->values().front().intvalue;
values.push_back(ValueFlow::Value(tok, v-1));