Bug hunting; Avoid false warnings for impossible values
This commit is contained in:
parent
ab8bf81f03
commit
d4169f04d5
|
@ -2108,6 +2108,8 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer,
|
||||||
return;
|
return;
|
||||||
if (tok->hasKnownIntValue() && tok->getKnownIntValue() != 0)
|
if (tok->hasKnownIntValue() && tok->getKnownIntValue() != 0)
|
||||||
return;
|
return;
|
||||||
|
if (tok->isImpossibleIntValue(0))
|
||||||
|
return;
|
||||||
if (value.isUninit())
|
if (value.isUninit())
|
||||||
return;
|
return;
|
||||||
float f = getKnownFloatValue(tok, 0.0f);
|
float f = getKnownFloatValue(tok, 0.0f);
|
||||||
|
|
13
lib/token.h
13
lib/token.h
|
@ -1032,6 +1032,19 @@ public:
|
||||||
return mImpl->mValues->front().intvalue;
|
return mImpl->mValues->front().intvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isImpossibleIntValue(const MathLib::bigint val) const {
|
||||||
|
if (!mImpl->mValues)
|
||||||
|
return false;
|
||||||
|
for (const auto &v: *mImpl->mValues) {
|
||||||
|
if (v.isIntValue() && v.isImpossible() && v.intvalue == val)
|
||||||
|
return true;
|
||||||
|
if (v.isIntValue() && v.bound == ValueFlow::Value::Bound::Lower && v.intvalue > val)
|
||||||
|
return true;
|
||||||
|
if (v.isIntValue() && v.bound == ValueFlow::Value::Bound::Upper && v.intvalue < val)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const ValueFlow::Value * getValue(const MathLib::bigint val) const {
|
const ValueFlow::Value * getValue(const MathLib::bigint val) const {
|
||||||
if (!mImpl->mValues)
|
if (!mImpl->mValues)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
Loading…
Reference in New Issue