Skip to content

Commit dff6214

Browse files
Update vf_settokenvalue.cpp
1 parent c9716c6 commit dff6214

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎lib/vf_settokenvalue.cpp‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,21 @@ namespace ValueFlow
428428
setTokenValue(parent, std::move(value), settings);
429429
}
430430
} else if (!value.isImpossible()) {
431+
// is condition only depending on 1 variable?
432+
nonneg int varId = 0;
433+
bool ret = false;
434+
visitAstNodes(parent->astOperand1(),
435+
[&](const Token *t) {
436+
if (t->varId()) {
437+
if (varId > 0)
438+
ret = true;
439+
varId = t->varId();
440+
} else if (t->str() == "(" && Token::Match(t->previous(), "%name%"))
441+
ret = true; // function call
442+
return ret ? ChildrenToVisit::done : ChildrenToVisit::op1_and_op2;
443+
});
444+
if (ret)
445+
return;
431446
value.conditional = true;
432447
value.changeKnownToPossible();
433448

0 commit comments

Comments
 (0)