Fixed zerodiv/moduloofone FN for '1/std::expm1(0)'
This commit is contained in:
parent
07eeee1620
commit
0282c3a86e
|
@ -1447,7 +1447,7 @@
|
|||
<function name="expm1,std::expm1">
|
||||
<use-retval/>
|
||||
<pure/>
|
||||
<returnValue type="double"/>
|
||||
<returnValue type="double">expm1(arg1)</returnValue>
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1" direction="in">
|
||||
|
@ -1458,7 +1458,7 @@
|
|||
<function name="expm1f,std::expm1f">
|
||||
<use-retval/>
|
||||
<pure/>
|
||||
<returnValue type="float"/>
|
||||
<returnValue type="float">expm1(arg1)</returnValue>
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1" direction="in">
|
||||
|
@ -1469,7 +1469,7 @@
|
|||
<function name="expm1l,std::expm1l">
|
||||
<use-retval/>
|
||||
<pure/>
|
||||
<returnValue type="long double"/>
|
||||
<returnValue type="long double">expm1(arg1)</returnValue>
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1" direction="in">
|
||||
|
|
|
@ -796,6 +796,17 @@ static std::unordered_map<std::string, BuiltinLibraryFunction> createBuiltinLibr
|
|||
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||
return v;
|
||||
};
|
||||
functions["expm1"] = [](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::exp2(value);
|
||||
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||
return v;
|
||||
};
|
||||
functions["log"] = [](const std::vector<ValueFlow::Value>& args) {
|
||||
if (args.size() != 1)
|
||||
return ValueFlow::Value::unknown();
|
||||
|
|
|
@ -141,6 +141,13 @@ int moduloofone_cos()
|
|||
return 42 % i;
|
||||
}
|
||||
|
||||
int moduloofone_expm1()
|
||||
{
|
||||
int i = std::expm1(0);
|
||||
// cppcheck-suppress moduloofone
|
||||
return 42 % i;
|
||||
}
|
||||
|
||||
int moduloofone_exp()
|
||||
{
|
||||
int i = std::exp(0);
|
||||
|
|
Loading…
Reference in New Issue