Removed hardcoding of functions from checkZeroDivision
This commit is contained in:
parent
1752c4f4f0
commit
503fb485cf
|
@ -1797,28 +1797,20 @@ void CheckOther::checkZeroDivision()
|
||||||
const bool printInconclusive = _settings->inconclusive;
|
const bool printInconclusive = _settings->inconclusive;
|
||||||
|
|
||||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "div|ldiv|lldiv|imaxdiv ( %num% , %num% )") &&
|
if (!Token::Match(tok, "[/%]") || !tok->astOperand2())
|
||||||
MathLib::isInt(tok->strAt(4)) &&
|
continue;
|
||||||
MathLib::toLongNumber(tok->strAt(4)) == 0L) {
|
if (astIsFloat(tok,false))
|
||||||
if (tok->str() == "div") {
|
continue;
|
||||||
if (tok->strAt(-1) == ".")
|
// Value flow..
|
||||||
continue;
|
const ValueFlow::Value *value = tok->astOperand2()->getValue(0LL);
|
||||||
if (tok->variable() || tok->function())
|
if (!value)
|
||||||
continue;
|
continue;
|
||||||
}
|
if (!printInconclusive && value->inconclusive)
|
||||||
zerodivError(tok,false);
|
continue;
|
||||||
} else if (Token::Match(tok, "[/%]") && tok->astOperand2() && !astIsFloat(tok,false)) {
|
if (value->condition == nullptr)
|
||||||
// Value flow..
|
zerodivError(tok, value->inconclusive);
|
||||||
const ValueFlow::Value *value = tok->astOperand2()->getValue(0LL);
|
else if (printWarnings)
|
||||||
if (value) {
|
zerodivcondError(value->condition,tok,value->inconclusive);
|
||||||
if (!printInconclusive && value->inconclusive)
|
|
||||||
continue;
|
|
||||||
if (value->condition == nullptr)
|
|
||||||
zerodivError(tok, value->inconclusive);
|
|
||||||
else if (printWarnings)
|
|
||||||
zerodivcondError(value->condition,tok,value->inconclusive);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue