Skip to content

Commit 5f25cc2

Browse files
committed
valueflow.cpp: added some early outs in ConditionHandler::beforeCondition() [skip ci]
1 parent 3c12164 commit 5f25cc2

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/valueflow.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4811,19 +4811,23 @@ struct ConditionHandler {
48114811
return;
48124812
}
48134813

4814+
if (cond.true_values.empty() && cond.false_values.empty())
4815+
return;
4816+
48144817
std::list<ValueFlow::Value> values = cond.true_values;
48154818
if (cond.true_values != cond.false_values)
48164819
values.insert(values.end(), cond.false_values.cbegin(), cond.false_values.cend());
48174820

48184821
// extra logic for unsigned variables 'i>=1' => possible value can also be 0
48194822
if (Token::Match(tok, "<|>|<=|>=")) {
4823+
if (cond.vartok->valueType() && cond.vartok->valueType()->sign != ValueType::Sign::UNSIGNED)
4824+
return;
4825+
48204826
values.remove_if([](const ValueFlow::Value& v) {
48214827
if (v.isIntValue())
48224828
return v.intvalue != 0;
48234829
return false;
48244830
});
4825-
if (cond.vartok->valueType() && cond.vartok->valueType()->sign != ValueType::Sign::UNSIGNED)
4826-
return;
48274831
}
48284832
if (values.empty())
48294833
return;

0 commit comments

Comments
 (0)