Break loops earlier
This commit is contained in:
parent
fddc301f7b
commit
01e0a61ebe
|
@ -1605,8 +1605,10 @@ struct FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const
|
||||||
if (conditionStart && conditionEnd) {
|
if (conditionStart && conditionEnd) {
|
||||||
bool used = false;
|
bool used = false;
|
||||||
for (const Token *condTok = conditionStart; condTok != conditionEnd; condTok = condTok->next()) {
|
for (const Token *condTok = conditionStart; condTok != conditionEnd; condTok = condTok->next()) {
|
||||||
if (exprVarIds.find(condTok->varId()) != exprVarIds.end())
|
if (exprVarIds.find(condTok->varId()) != exprVarIds.end()) {
|
||||||
used = true;
|
used = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (used)
|
if (used)
|
||||||
return Result(Result::Type::BAILOUT);
|
return Result(Result::Type::BAILOUT);
|
||||||
|
|
|
@ -1975,9 +1975,11 @@ void CheckOther::checkDuplicateExpression()
|
||||||
for (const Token *assignTok = Token::findsimplematch(var2, ";"); assignTok && assignTok != varScope->bodyEnd; assignTok = assignTok->next()) {
|
for (const Token *assignTok = Token::findsimplematch(var2, ";"); assignTok && assignTok != varScope->bodyEnd; assignTok = assignTok->next()) {
|
||||||
if (Token::Match(assignTok, "%varid% = %var%", var1->varId()) && Token::Match(assignTok, "%var% = %varid%", var2->varId())) {
|
if (Token::Match(assignTok, "%varid% = %var%", var1->varId()) && Token::Match(assignTok, "%var% = %varid%", var2->varId())) {
|
||||||
assigned = true;
|
assigned = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (Token::Match(assignTok, "%varid% = %var%", var2->varId()) && Token::Match(assignTok, "%var% = %varid%", var1->varId())) {
|
if (Token::Match(assignTok, "%varid% = %var%", var2->varId()) && Token::Match(assignTok, "%var% = %varid%", var1->varId())) {
|
||||||
assigned = true;
|
assigned = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!assigned && !isUniqueExpression(tok->astOperand2()))
|
if (!assigned && !isUniqueExpression(tok->astOperand2()))
|
||||||
|
|
|
@ -146,8 +146,10 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
|
||||||
const std::map<int, VariableValue> variableValue;
|
const std::map<int, VariableValue> variableValue;
|
||||||
bool init = false;
|
bool init = false;
|
||||||
for (const Token *parent = var.nameToken(); parent; parent = parent->astParent()) {
|
for (const Token *parent = var.nameToken(); parent; parent = parent->astParent()) {
|
||||||
if (parent->str() == "=")
|
if (parent->str() == "=") {
|
||||||
init = true;
|
init = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!init)
|
if (!init)
|
||||||
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue);
|
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue);
|
||||||
|
|
Loading…
Reference in New Issue