Skip to content

Commit 43bacd8

Browse files
committed
valueflow.cpp: added some early outs in ConditionHandler::beforeCondition() [skip ci]
1 parent 11da5f2 commit 43bacd8

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
@@ -4813,19 +4813,23 @@ struct ConditionHandler {
48134813
return;
48144814
}
48154815

4816+
if (cond.true_values.empty() && cond.false_values.empty())
4817+
return;
4818+
48164819
std::list<ValueFlow::Value> values = cond.true_values;
48174820
if (cond.true_values != cond.false_values)
48184821
values.insert(values.end(), cond.false_values.cbegin(), cond.false_values.cend());
48194822

48204823
// extra logic for unsigned variables 'i>=1' => possible value can also be 0
48214824
if (Token::Match(tok, "<|>|<=|>=")) {
4825+
if (cond.vartok->valueType() && cond.vartok->valueType()->sign != ValueType::Sign::UNSIGNED)
4826+
return;
4827+
48224828
values.remove_if([](const ValueFlow::Value& v) {
48234829
if (v.isIntValue())
48244830
return v.intvalue != 0;
48254831
return false;
48264832
});
4827-
if (cond.vartok->valueType() && cond.vartok->valueType()->sign != ValueType::Sign::UNSIGNED)
4828-
return;
48294833
}
48304834
if (values.empty())
48314835
return;

0 commit comments

Comments
 (0)