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