Skip to content

Commit

Permalink
Check all scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jul 16, 2023
1 parent ba9f8a5 commit 90b8b79
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5625,14 +5625,22 @@ static void valueFlowForwardConst(Token* start,

for (Token* tok = start; tok != end; tok = tok->next()) {
if (tok->varId() == var->declarationId()) {
if (tok->scope()->type == Scope::ScopeType::eIf) {
MathLib::bigint result{};
bool error{};
execute(tok->scope()->bodyStart->linkAt(-1), pm, &result, &error, settings);
if (!result || error)
continue;
const Scope* scope = tok->scope();
bool setValue = true;
while (scope && scope->isLocal()) {
if (scope->type == Scope::ScopeType::eIf) {
MathLib::bigint result{};
bool error{};
execute(tok->scope()->bodyStart->linkAt(-1)->astOperand2(), pm, &result, &error, settings);
if (!result && !error) {
setValue = false;
break;
}
}
scope = scope->nestedIn;
}
setTokenValue(tok, value, settings);
if (setValue)
setTokenValue(tok, value, settings);
} else {
[&] {
// Follow references
Expand Down

0 comments on commit 90b8b79

Please sign in to comment.