Skip to content

Commit 089812b

Browse files
committed
Token: simplified hasKnownIntValue()
1 parent f59c7d0 commit 089812b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/token.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,13 +2490,15 @@ std::shared_ptr<ScopeInfo2> Token::scopeInfo() const
24902490
return mImpl->mScopeInfo;
24912491
}
24922492

2493+
// if there is a known INT value it will always be the first entry
24932494
bool Token::hasKnownIntValue() const
24942495
{
24952496
if (!mImpl->mValues)
24962497
return false;
2497-
return std::any_of(mImpl->mValues->begin(), mImpl->mValues->end(), [](const ValueFlow::Value& value) {
2498-
return value.isKnown() && value.isIntValue();
2499-
});
2498+
if (mImpl->mValues->empty())
2499+
return false;
2500+
const ValueFlow::Value& value = mImpl->mValues->front();
2501+
return value.isIntValue() && value.isKnown();
25002502
}
25012503

25022504
bool Token::hasKnownValue() const

lib/token.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,6 @@ class CPPCHECKLIB Token {
13071307
const ValueFlow::Value* getKnownValue() const;
13081308
const ValueFlow::Value* getKnownValue(ValueFlow::Value::ValueType t) const;
13091309
MathLib::bigint getKnownIntValue() const {
1310-
// TODO: need to perform lookup
13111310
assert(!mImpl->mValues->empty());
13121311
assert(mImpl->mValues->front().isKnown());
13131312
assert(mImpl->mValues->front().valueType == ValueFlow::Value::ValueType::INT);

0 commit comments

Comments
 (0)