Refactoring: Use range for loops
This commit is contained in:
parent
0f3cc56c59
commit
1e824330c0
|
@ -1025,10 +1025,10 @@ static void valueFlowBitAnd(TokenList *tokenlist)
|
||||||
|
|
||||||
static void valueFlowOppositeCondition(SymbolDatabase *symboldatabase, const Settings *settings)
|
static void valueFlowOppositeCondition(SymbolDatabase *symboldatabase, const Settings *settings)
|
||||||
{
|
{
|
||||||
for (std::list<Scope>::iterator scope = symboldatabase->scopeList.begin(); scope != symboldatabase->scopeList.end(); ++scope) {
|
for (const Scope &scope : symboldatabase->scopeList) {
|
||||||
if (scope->type != Scope::eIf)
|
if (scope.type != Scope::eIf)
|
||||||
continue;
|
continue;
|
||||||
Token *tok = const_cast<Token *>(scope->classDef);
|
Token *tok = const_cast<Token *>(scope.classDef);
|
||||||
if (!Token::simpleMatch(tok, "if ("))
|
if (!Token::simpleMatch(tok, "if ("))
|
||||||
continue;
|
continue;
|
||||||
const Token *cond1 = tok->next()->astOperand2();
|
const Token *cond1 = tok->next()->astOperand2();
|
||||||
|
@ -1322,9 +1322,7 @@ static void valueFlowReverse(TokenList *tokenlist,
|
||||||
|
|
||||||
static void valueFlowBeforeCondition(TokenList *tokenlist, SymbolDatabase *symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
static void valueFlowBeforeCondition(TokenList *tokenlist, SymbolDatabase *symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
||||||
{
|
{
|
||||||
const std::size_t functions = symboldatabase->functionScopes.size();
|
for (const Scope * scope : symboldatabase->functionScopes) {
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
|
||||||
const Scope * scope = symboldatabase->functionScopes[i];
|
|
||||||
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
|
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
|
||||||
MathLib::bigint num = 0;
|
MathLib::bigint num = 0;
|
||||||
const Token *vartok = nullptr;
|
const Token *vartok = nullptr;
|
||||||
|
@ -1423,8 +1421,8 @@ static void removeValues(std::list<ValueFlow::Value> &values, const std::list<Va
|
||||||
{
|
{
|
||||||
for (std::list<ValueFlow::Value>::iterator it = values.begin(); it != values.end();) {
|
for (std::list<ValueFlow::Value>::iterator it = values.begin(); it != values.end();) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (std::list<ValueFlow::Value>::const_iterator it2 = valuesToRemove.begin(); it2 != valuesToRemove.end(); ++it2) {
|
for (const ValueFlow::Value &v2 : valuesToRemove) {
|
||||||
if (it->intvalue == it2->intvalue) {
|
if (it->intvalue == v2.intvalue) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1451,8 +1449,8 @@ static void valueFlowAST(Token *tok, unsigned int varid, const ValueFlow::Value
|
||||||
} else if (tok->str() == "||" && tok->astOperand1()) {
|
} else if (tok->str() == "||" && tok->astOperand1()) {
|
||||||
const std::list<ValueFlow::Value> &values = tok->astOperand1()->values();
|
const std::list<ValueFlow::Value> &values = tok->astOperand1()->values();
|
||||||
bool nonzero = false;
|
bool nonzero = false;
|
||||||
for (std::list<ValueFlow::Value>::const_iterator it = values.begin(); it != values.end(); ++it) {
|
for (const ValueFlow::Value &v : values) {
|
||||||
if (it->intvalue != 0) {
|
if (v.intvalue != 0) {
|
||||||
nonzero = true;
|
nonzero = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1635,8 +1633,8 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
const Token *condition = tok2->linkAt(-1);
|
const Token *condition = tok2->linkAt(-1);
|
||||||
condition = condition ? condition->linkAt(-1) : nullptr;
|
condition = condition ? condition->linkAt(-1) : nullptr;
|
||||||
condition = condition ? condition->astOperand2() : nullptr;
|
condition = condition ? condition->astOperand2() : nullptr;
|
||||||
for (std::list<ValueFlow::Value>::iterator it = values.begin(); it != values.end(); ++it) {
|
for (const ValueFlow::Value &v : values) {
|
||||||
if (conditionIsTrue(condition, getProgramMemory(tok2, varid, *it))) {
|
if (conditionIsTrue(condition, getProgramMemory(tok2, varid, v))) {
|
||||||
skipelse = true;
|
skipelse = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1678,8 +1676,8 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
// Set values in condition
|
// Set values in condition
|
||||||
for (Token* tok3 = tok2->tokAt(2); tok3 != tok2->next()->link(); tok3 = tok3->next()) {
|
for (Token* tok3 = tok2->tokAt(2); tok3 != tok2->next()->link(); tok3 = tok3->next()) {
|
||||||
if (tok3->varId() == varid) {
|
if (tok3->varId() == varid) {
|
||||||
for (std::list<ValueFlow::Value>::const_iterator it = values.begin(); it != values.end(); ++it)
|
for (const ValueFlow::Value &v : values)
|
||||||
setTokenValue(tok3, *it, settings);
|
setTokenValue(tok3, v, settings);
|
||||||
} else if (Token::Match(tok3, "%oror%|&&|?|;")) {
|
} else if (Token::Match(tok3, "%oror%|&&|?|;")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1692,26 +1690,26 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
// Should scope be skipped because variable value is checked?
|
// Should scope be skipped because variable value is checked?
|
||||||
std::list<ValueFlow::Value> truevalues;
|
std::list<ValueFlow::Value> truevalues;
|
||||||
std::list<ValueFlow::Value> falsevalues;
|
std::list<ValueFlow::Value> falsevalues;
|
||||||
for (std::list<ValueFlow::Value>::const_iterator it = values.begin(); it != values.end(); ++it) {
|
for (const ValueFlow::Value &v : values) {
|
||||||
if (condAlwaysTrue) {
|
if (condAlwaysTrue) {
|
||||||
truevalues.push_back(*it);
|
truevalues.push_back(v);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (condAlwaysFalse) {
|
if (condAlwaysFalse) {
|
||||||
falsevalues.push_back(*it);
|
falsevalues.push_back(v);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const ProgramMemory &programMemory = getProgramMemory(tok2, varid, *it);
|
const ProgramMemory &programMemory = getProgramMemory(tok2, varid, v);
|
||||||
if (subFunction && conditionIsTrue(condTok, programMemory))
|
if (subFunction && conditionIsTrue(condTok, programMemory))
|
||||||
truevalues.push_back(*it);
|
truevalues.push_back(v);
|
||||||
else if (!subFunction && !conditionIsFalse(condTok, programMemory))
|
else if (!subFunction && !conditionIsFalse(condTok, programMemory))
|
||||||
truevalues.push_back(*it);
|
truevalues.push_back(v);
|
||||||
if (condAlwaysFalse)
|
if (condAlwaysFalse)
|
||||||
falsevalues.push_back(*it);
|
falsevalues.push_back(v);
|
||||||
else if (conditionIsFalse(condTok, programMemory))
|
else if (conditionIsFalse(condTok, programMemory))
|
||||||
falsevalues.push_back(*it);
|
falsevalues.push_back(v);
|
||||||
else if (!subFunction && !conditionIsTrue(condTok, programMemory))
|
else if (!subFunction && !conditionIsTrue(condTok, programMemory))
|
||||||
falsevalues.push_back(*it);
|
falsevalues.push_back(v);
|
||||||
}
|
}
|
||||||
if (truevalues.size() != values.size() || condAlwaysTrue) {
|
if (truevalues.size() != values.size() || condAlwaysTrue) {
|
||||||
// '{'
|
// '{'
|
||||||
|
@ -1794,9 +1792,8 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
const Token * const condend = tok2->linkAt(1);
|
const Token * const condend = tok2->linkAt(1);
|
||||||
for (Token *condtok = tok2; condtok != condend; condtok = condtok->next()) {
|
for (Token *condtok = tok2; condtok != condend; condtok = condtok->next()) {
|
||||||
if (condtok->varId() == varid) {
|
if (condtok->varId() == varid) {
|
||||||
std::list<ValueFlow::Value>::const_iterator it;
|
for (const ValueFlow::Value &v : values)
|
||||||
for (it = values.begin(); it != values.end(); ++it)
|
setTokenValue(condtok, v, settings);
|
||||||
setTokenValue(condtok, *it, settings);
|
|
||||||
}
|
}
|
||||||
if (Token::Match(condtok, "%oror%|&&|?|;"))
|
if (Token::Match(condtok, "%oror%|&&|?|;"))
|
||||||
break;
|
break;
|
||||||
|
@ -1963,21 +1960,19 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
if (condition->hasKnownIntValue()) {
|
if (condition->hasKnownIntValue()) {
|
||||||
const ValueFlow::Value &condValue = condition->values().front();
|
const ValueFlow::Value &condValue = condition->values().front();
|
||||||
const Token *expr = (condValue.intvalue != 0) ? op2->astOperand1() : op2->astOperand2();
|
const Token *expr = (condValue.intvalue != 0) ? op2->astOperand1() : op2->astOperand2();
|
||||||
std::list<ValueFlow::Value>::const_iterator it;
|
for (const ValueFlow::Value &v : values)
|
||||||
for (it = values.begin(); it != values.end(); ++it)
|
valueFlowAST(const_cast<Token*>(expr), varid, v, settings);
|
||||||
valueFlowAST(const_cast<Token*>(expr), varid, *it, settings);
|
|
||||||
if (isVariableChangedByFunctionCall(expr, varid, settings, nullptr))
|
if (isVariableChangedByFunctionCall(expr, varid, settings, nullptr))
|
||||||
changeKnownToPossible(values);
|
changeKnownToPossible(values);
|
||||||
} else {
|
} else {
|
||||||
std::list<ValueFlow::Value>::const_iterator it;
|
for (const ValueFlow::Value &v : values) {
|
||||||
for (it = values.begin(); it != values.end(); ++it) {
|
const ProgramMemory programMemory(getProgramMemory(tok2, varid, v));
|
||||||
const ProgramMemory programMemory(getProgramMemory(tok2, varid, *it));
|
|
||||||
if (conditionIsTrue(condition, programMemory))
|
if (conditionIsTrue(condition, programMemory))
|
||||||
valueFlowAST(const_cast<Token*>(op2->astOperand1()), varid, *it, settings);
|
valueFlowAST(const_cast<Token*>(op2->astOperand1()), varid, v, settings);
|
||||||
else if (conditionIsFalse(condition, programMemory))
|
else if (conditionIsFalse(condition, programMemory))
|
||||||
valueFlowAST(const_cast<Token*>(op2->astOperand2()), varid, *it, settings);
|
valueFlowAST(const_cast<Token*>(op2->astOperand2()), varid, v, settings);
|
||||||
else
|
else
|
||||||
valueFlowAST(const_cast<Token*>(op2), varid, *it, settings);
|
valueFlowAST(const_cast<Token*>(op2), varid, v, settings);
|
||||||
}
|
}
|
||||||
if (isVariableChangedByFunctionCall(op2, varid, settings, nullptr))
|
if (isVariableChangedByFunctionCall(op2, varid, settings, nullptr))
|
||||||
changeKnownToPossible(values);
|
changeKnownToPossible(values);
|
||||||
|
@ -2048,9 +2043,8 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
if (Token::Match(rtok, "++|--|?|:|;|,"))
|
if (Token::Match(rtok, "++|--|?|:|;|,"))
|
||||||
continue;
|
continue;
|
||||||
if (rtok->varId() == varid) {
|
if (rtok->varId() == varid) {
|
||||||
std::list<ValueFlow::Value>::const_iterator it;
|
for (const ValueFlow::Value &v : values)
|
||||||
for (it = values.begin(); it != values.end(); ++it)
|
setTokenValue(rtok, v, settings);
|
||||||
setTokenValue(rtok, *it, settings);
|
|
||||||
}
|
}
|
||||||
rhs.push(const_cast<Token *>(rtok->astOperand1()));
|
rhs.push(const_cast<Token *>(rtok->astOperand1()));
|
||||||
rhs.push(const_cast<Token *>(rtok->astOperand2()));
|
rhs.push(const_cast<Token *>(rtok->astOperand2()));
|
||||||
|
@ -2090,10 +2084,9 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
}
|
}
|
||||||
const bool conditional = parent && (parent->str() == ":" || parent->astOperand2() == tok3);
|
const bool conditional = parent && (parent->str() == ":" || parent->astOperand2() == tok3);
|
||||||
|
|
||||||
std::list<ValueFlow::Value>::const_iterator it;
|
for (const ValueFlow::Value &v : values) {
|
||||||
for (it = values.begin(); it != values.end(); ++it) {
|
if (!conditional || !v.conditional)
|
||||||
if (!conditional || !it->conditional)
|
setTokenValue(tok2, v, settings);
|
||||||
setTokenValue(tok2, *it, settings);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2149,15 +2142,13 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (inconclusive) {
|
if (inconclusive) {
|
||||||
std::list<ValueFlow::Value>::iterator it;
|
for (ValueFlow::Value &v : values)
|
||||||
for (it = values.begin(); it != values.end(); ++it)
|
v.setInconclusive();
|
||||||
it->setInconclusive();
|
|
||||||
}
|
}
|
||||||
if (tok2->strAt(1) == "." && tok2->next()->originalName() != "->") {
|
if (tok2->strAt(1) == "." && tok2->next()->originalName() != "->") {
|
||||||
if (settings->inconclusive) {
|
if (settings->inconclusive) {
|
||||||
std::list<ValueFlow::Value>::iterator it;
|
for (ValueFlow::Value &v : values)
|
||||||
for (it = values.begin(); it != values.end(); ++it)
|
v.setInconclusive();
|
||||||
it->setInconclusive();
|
|
||||||
} else {
|
} else {
|
||||||
if (settings->debugwarnings)
|
if (settings->debugwarnings)
|
||||||
bailout(tokenlist, errorLogger, tok2, "possible assignment of " + tok2->str() + " by member function");
|
bailout(tokenlist, errorLogger, tok2, "possible assignment of " + tok2->str() + " by member function");
|
||||||
|
@ -2255,9 +2246,7 @@ static void valueFlowAfterMove(TokenList *tokenlist, SymbolDatabase* symboldatab
|
||||||
{
|
{
|
||||||
if (!tokenlist->isCPP() || settings->standards.cpp < Standards::CPP11)
|
if (!tokenlist->isCPP() || settings->standards.cpp < Standards::CPP11)
|
||||||
return;
|
return;
|
||||||
const std::size_t functions = symboldatabase->functionScopes.size();
|
for (const Scope * scope : symboldatabase->functionScopes) {
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
|
||||||
const Scope * scope = symboldatabase->functionScopes[i];
|
|
||||||
if (!scope)
|
if (!scope)
|
||||||
continue;
|
continue;
|
||||||
const Token * start = scope->bodyStart;
|
const Token * start = scope->bodyStart;
|
||||||
|
@ -2328,10 +2317,8 @@ static void valueFlowAfterMove(TokenList *tokenlist, SymbolDatabase* symboldatab
|
||||||
|
|
||||||
static void valueFlowAfterAssign(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
static void valueFlowAfterAssign(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
||||||
{
|
{
|
||||||
const std::size_t functions = symboldatabase->functionScopes.size();
|
for (const Scope * scope : symboldatabase->functionScopes) {
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
|
||||||
std::set<unsigned int> aliased;
|
std::set<unsigned int> aliased;
|
||||||
const Scope * scope = symboldatabase->functionScopes[i];
|
|
||||||
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
|
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
|
||||||
// Alias
|
// Alias
|
||||||
if (tok->str() == "&" && !tok->astOperand2() && tok->astOperand1()) {
|
if (tok->str() == "&" && !tok->astOperand2() && tok->astOperand1()) {
|
||||||
|
@ -2390,9 +2377,7 @@ static void valueFlowAfterAssign(TokenList *tokenlist, SymbolDatabase* symboldat
|
||||||
|
|
||||||
static void valueFlowAfterCondition(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
static void valueFlowAfterCondition(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
||||||
{
|
{
|
||||||
const std::size_t functions = symboldatabase->functionScopes.size();
|
for (const Scope * scope : symboldatabase->functionScopes) {
|
||||||
for (std::size_t func = 0; func < functions; ++func) {
|
|
||||||
const Scope * scope = symboldatabase->functionScopes[func];
|
|
||||||
std::set<unsigned> aliased;
|
std::set<unsigned> aliased;
|
||||||
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
|
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
|
||||||
const Token * vartok = nullptr;
|
const Token * vartok = nullptr;
|
||||||
|
@ -3025,12 +3010,12 @@ static void valueFlowForLoopSimplifyAfter(Token *fortok, unsigned int varid, con
|
||||||
|
|
||||||
static void valueFlowForLoop(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
static void valueFlowForLoop(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
||||||
{
|
{
|
||||||
for (std::list<Scope>::const_iterator scope = symboldatabase->scopeList.begin(); scope != symboldatabase->scopeList.end(); ++scope) {
|
for (const Scope &scope : symboldatabase->scopeList) {
|
||||||
if (scope->type != Scope::eFor)
|
if (scope.type != Scope::eFor)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Token* tok = const_cast<Token*>(scope->classDef);
|
Token* tok = const_cast<Token*>(scope.classDef);
|
||||||
Token* const bodyStart = const_cast<Token*>(scope->bodyStart);
|
Token* const bodyStart = const_cast<Token*>(scope.bodyStart);
|
||||||
|
|
||||||
if (!Token::simpleMatch(tok->next()->astOperand2(), ";") ||
|
if (!Token::simpleMatch(tok->next()->astOperand2(), ";") ||
|
||||||
!Token::simpleMatch(tok->next()->astOperand2()->astOperand2(), ";"))
|
!Token::simpleMatch(tok->next()->astOperand2()->astOperand2(), ";"))
|
||||||
|
@ -3086,12 +3071,12 @@ static void valueFlowInjectParameter(TokenList* tokenlist, ErrorLogger* errorLog
|
||||||
|
|
||||||
static void valueFlowSwitchVariable(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
static void valueFlowSwitchVariable(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
|
||||||
{
|
{
|
||||||
for (std::list<Scope>::iterator scope = symboldatabase->scopeList.begin(); scope != symboldatabase->scopeList.end(); ++scope) {
|
for (const Scope &scope : symboldatabase->scopeList) {
|
||||||
if (scope->type != Scope::ScopeType::eSwitch)
|
if (scope.type != Scope::ScopeType::eSwitch)
|
||||||
continue;
|
continue;
|
||||||
if (!Token::Match(scope->classDef, "switch ( %var% ) {"))
|
if (!Token::Match(scope.classDef, "switch ( %var% ) {"))
|
||||||
continue;
|
continue;
|
||||||
const Token *vartok = scope->classDef->tokAt(2);
|
const Token *vartok = scope.classDef->tokAt(2);
|
||||||
const Variable *var = vartok->variable();
|
const Variable *var = vartok->variable();
|
||||||
if (!var)
|
if (!var)
|
||||||
continue;
|
continue;
|
||||||
|
@ -3103,7 +3088,7 @@ static void valueFlowSwitchVariable(TokenList *tokenlist, SymbolDatabase* symbol
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Token *tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) {
|
for (Token *tok = scope.bodyStart->next(); tok != scope.bodyEnd; tok = tok->next()) {
|
||||||
if (tok->str() == "{") {
|
if (tok->str() == "{") {
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
continue;
|
continue;
|
||||||
|
@ -3129,7 +3114,7 @@ static void valueFlowSwitchVariable(TokenList *tokenlist, SymbolDatabase* symbol
|
||||||
}
|
}
|
||||||
for (std::list<ValueFlow::Value>::const_iterator val = values.begin(); val != values.end(); ++val) {
|
for (std::list<ValueFlow::Value>::const_iterator val = values.begin(); val != values.end(); ++val) {
|
||||||
valueFlowReverse(tokenlist,
|
valueFlowReverse(tokenlist,
|
||||||
const_cast<Token*>(scope->classDef),
|
const_cast<Token*>(scope.classDef),
|
||||||
vartok,
|
vartok,
|
||||||
*val,
|
*val,
|
||||||
ValueFlow::Value(),
|
ValueFlow::Value(),
|
||||||
|
@ -3169,8 +3154,7 @@ static void valueFlowLibraryFunction(Token *tok, const std::string &returnValue,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Token::simpleMatch(tokenList.front(), "strlen ( arg1 )") && arg1) {
|
if (Token::simpleMatch(tokenList.front(), "strlen ( arg1 )") && arg1) {
|
||||||
for (std::list<ValueFlow::Value>::const_iterator it = arg1->values().begin(); it != arg1->values().end(); ++it) {
|
for (const ValueFlow::Value &value : arg1->values()) {
|
||||||
const ValueFlow::Value &value = *it;
|
|
||||||
if (value.isTokValue() && value.tokvalue->tokType() == Token::eString) {
|
if (value.isTokValue() && value.tokvalue->tokType() == Token::eString) {
|
||||||
ValueFlow::Value retval(value); // copy all "inconclusive", "condition", etc attributes
|
ValueFlow::Value retval(value); // copy all "inconclusive", "condition", etc attributes
|
||||||
// set return value..
|
// set return value..
|
||||||
|
@ -3276,9 +3260,7 @@ static void valueFlowFunctionDefaultParameter(TokenList *tokenlist, SymbolDataba
|
||||||
if (!tokenlist->isCPP())
|
if (!tokenlist->isCPP())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const std::size_t functions = symboldatabase->functionScopes.size();
|
for (const Scope* scope : symboldatabase->functionScopes) {
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
|
||||||
const Scope* scope = symboldatabase->functionScopes[i];
|
|
||||||
const Function* function = scope->function;
|
const Function* function = scope->function;
|
||||||
if (!function)
|
if (!function)
|
||||||
continue;
|
continue;
|
||||||
|
@ -3287,8 +3269,8 @@ static void valueFlowFunctionDefaultParameter(TokenList *tokenlist, SymbolDataba
|
||||||
if (var && var->hasDefault() && Token::Match(var->nameToken(), "%var% = %num%|%str% [,)]")) {
|
if (var && var->hasDefault() && Token::Match(var->nameToken(), "%var% = %num%|%str% [,)]")) {
|
||||||
const std::list<ValueFlow::Value> &values = var->nameToken()->tokAt(2)->values();
|
const std::list<ValueFlow::Value> &values = var->nameToken()->tokAt(2)->values();
|
||||||
std::list<ValueFlow::Value> argvalues;
|
std::list<ValueFlow::Value> argvalues;
|
||||||
for (std::list<ValueFlow::Value>::const_iterator it = values.begin(); it != values.end(); ++it) {
|
for (const ValueFlow::Value &value : values) {
|
||||||
ValueFlow::Value v(*it);
|
ValueFlow::Value v(value);
|
||||||
v.defaultArg = true;
|
v.defaultArg = true;
|
||||||
v.changeKnownToPossible();
|
v.changeKnownToPossible();
|
||||||
if (v.isPossible())
|
if (v.isPossible())
|
||||||
|
|
Loading…
Reference in New Issue