MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / getKnownValue

Method getKnownValue

lib/token.cpp:2552–2569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2550}
2551
2552const ValueFlow::Value* Token::getKnownValue(ValueFlow::Value::ValueType t) const
2553{
2554 if (!mImpl->mValues)
2555 return nullptr;
2556 if (mImpl->mValues->empty())
2557 return nullptr;
2558 // known INT values are always the first entry
2559 if (t == ValueFlow::Value::ValueType::INT) {
2560 const auto& v = mImpl->mValues->front();
2561 if (!v.isKnown() || !v.isIntValue())
2562 return nullptr;
2563 return &v;
2564 }
2565 auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [&](const ValueFlow::Value& value) {
2566 return value.isKnown() && value.valueType == t;
2567 });
2568 return it == mImpl->mValues->end() ? nullptr : &*it;
2569}
2570
2571const ValueFlow::Value* Token::getValue(const MathLib::bigint val) const
2572{

Callers 15

checkRecursiveMethod · 0.80
getOverrunIndexValuesFunction · 0.80
objectIndexMethod · 0.80
checkCondMethod · 0.80
checkLongCastMethod · 0.80
arrayDimensionsMethod · 0.80
parseCompareEachIntFunction · 0.80
parseCompareIntMethod · 0.80
valueFlowArrayElementFunction · 0.80
getExpressionRangeFunction · 0.80
minUnsignedValueFunction · 0.80

Calls 5

frontMethod · 0.80
isKnownMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected