Fixed zerodiv FN for '1/std::erf(0)'
This commit is contained in:
parent
c777cd5060
commit
87c1e6587a
|
@ -1258,7 +1258,7 @@
|
|||
<function name="erf,std::erf">
|
||||
<use-retval/>
|
||||
<pure/>
|
||||
<returnValue type="double"/>
|
||||
<returnValue type="double">erf(arg1)</returnValue>
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1" direction="in">
|
||||
|
@ -1269,7 +1269,7 @@
|
|||
<function name="erff,std::erff">
|
||||
<use-retval/>
|
||||
<pure/>
|
||||
<returnValue type="float"/>
|
||||
<returnValue type="float">erf(arg1)</returnValue>
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1" direction="in">
|
||||
|
@ -1280,7 +1280,7 @@
|
|||
<function name="erfl,std::erfl">
|
||||
<use-retval/>
|
||||
<pure/>
|
||||
<returnValue type="long double"/>
|
||||
<returnValue type="long double">erf(arg1)</returnValue>
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1" direction="in">
|
||||
|
|
|
@ -719,6 +719,17 @@ static std::unordered_map<std::string, BuiltinLibraryFunction> createBuiltinLibr
|
|||
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||
return v;
|
||||
};
|
||||
functions["erf"] = [](const std::vector<ValueFlow::Value>& args) {
|
||||
if (args.size() != 1)
|
||||
return ValueFlow::Value::unknown();
|
||||
ValueFlow::Value v = args[0];
|
||||
if (!v.isFloatValue() && !v.isIntValue())
|
||||
return ValueFlow::Value::unknown();
|
||||
double value = args[0].isFloatValue() ? args[0].floatValue : args[0].intvalue;
|
||||
v.floatValue = std::erf(value);
|
||||
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||
return v;
|
||||
};
|
||||
functions["sqrt"] = [](const std::vector<ValueFlow::Value>& args) {
|
||||
if (args.size() != 1)
|
||||
return ValueFlow::Value::unknown();
|
||||
|
|
|
@ -57,6 +57,13 @@ int zerodiv_cbrt()
|
|||
return 42 / i;
|
||||
}
|
||||
|
||||
int zerodiv_erf()
|
||||
{
|
||||
int i = std::erf(0);
|
||||
// cppcheck-suppress zerodiv
|
||||
return 42 / i;
|
||||
}
|
||||
|
||||
int zerodiv_asin()
|
||||
{
|
||||
int i = std::asin(0);
|
||||
|
|
Loading…
Reference in New Issue