Fixed zerodiv FN for '1/std::exp2(0)'
This commit is contained in:
parent
048d31ec56
commit
07eeee1620
|
@ -1414,7 +1414,7 @@
|
|||
<function name="exp2,std::exp2">
|
||||
<use-retval/>
|
||||
<pure/>
|
||||
<returnValue type="double"/>
|
||||
<returnValue type="double">exp2(arg1)</returnValue>
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1" direction="in">
|
||||
|
@ -1425,7 +1425,7 @@
|
|||
<function name="exp2f,std::exp2f">
|
||||
<use-retval/>
|
||||
<pure/>
|
||||
<returnValue type="float"/>
|
||||
<returnValue type="float">exp2(arg1)</returnValue>
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1" direction="in">
|
||||
|
@ -1436,7 +1436,7 @@
|
|||
<function name="exp2l,std::exp2l">
|
||||
<use-retval/>
|
||||
<pure/>
|
||||
<returnValue type="long double"/>
|
||||
<returnValue type="long double">exp2(arg1)</returnValue>
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1" direction="in">
|
||||
|
|
|
@ -785,6 +785,17 @@ static std::unordered_map<std::string, BuiltinLibraryFunction> createBuiltinLibr
|
|||
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||
return v;
|
||||
};
|
||||
functions["exp2"] = [](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();
|
||||
|
|
|
@ -148,6 +148,13 @@ int moduloofone_exp()
|
|||
return 42 % i;
|
||||
}
|
||||
|
||||
int moduloofone_exp2()
|
||||
{
|
||||
int i = std::exp2(0);
|
||||
// cppcheck-suppress moduloofone
|
||||
return 42 % i;
|
||||
}
|
||||
|
||||
int moduloofone_pow()
|
||||
{
|
||||
int i = std::pow(2, 0);
|
||||
|
|
Loading…
Reference in New Issue