Skip to content

Commit 7a7a8f3

Browse files
committed
Token: simplified hasKnownIntValue()
1 parent dd53957 commit 7a7a8f3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/token.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -2475,13 +2475,15 @@ std::shared_ptr<ScopeInfo2> Token::scopeInfo() const
24752475
return mImpl->mScopeInfo;
24762476
}
24772477

2478+
// if there is a known INT value it will always be the first entry
24782479
bool Token::hasKnownIntValue() const
24792480
{
24802481
if (!mImpl->mValues)
24812482
return false;
2482-
return std::any_of(mImpl->mValues->begin(), mImpl->mValues->end(), [](const ValueFlow::Value& value) {
2483-
return value.isKnown() && value.isIntValue();
2484-
});
2483+
if (mImpl->mValues->empty())
2484+
return false;
2485+
const ValueFlow::Value& value = mImpl->mValues->front();
2486+
return value.isIntValue() && value.isKnown();
24852487
}
24862488

24872489
bool Token::hasKnownValue() const

lib/token.h

-1
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,6 @@ class CPPCHECKLIB Token {
12911291
const ValueFlow::Value* getKnownValue() const;
12921292
const ValueFlow::Value* getKnownValue(ValueFlow::Value::ValueType t) const;
12931293
MathLib::bigint getKnownIntValue() const {
1294-
// TODO: need to perform lookup
12951294
assert(!mImpl->mValues->empty());
12961295
assert(mImpl->mValues->front().isKnown());
12971296
assert(mImpl->mValues->front().valueType == ValueFlow::Value::ValueType::INT);

0 commit comments

Comments
 (0)