Skip to content

Commit

Permalink
Token: added special handling for ValueFlow::Value::ValueType::INT
Browse files Browse the repository at this point in the history
…in `getKnownValue()`
  • Loading branch information
firewave committed Feb 6, 2025
1 parent f778a3d commit 8694c69
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2534,6 +2534,15 @@ const ValueFlow::Value* Token::getKnownValue(ValueFlow::Value::ValueType t) cons
{
if (!mImpl->mValues)
return nullptr;
if (mImpl->mValues->empty())
return nullptr;
// known INT values are always the first entry
if (t == ValueFlow::Value::ValueType::INT) {
const auto& v = mImpl->mValues->front();
if (!v.isKnown() || !v.isIntValue())
return nullptr;
return &v;
}
auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [&](const ValueFlow::Value& value) {
return value.isKnown() && value.valueType == t;
});
Expand Down

0 comments on commit 8694c69

Please sign in to comment.