Fixed zerodiv/moduloofone FNs for more math functions
This commit is contained in:
parent
ef47d34e75
commit
8215521843
24
cfg/std.cfg
24
cfg/std.cfg
|
@ -2119,7 +2119,7 @@
|
||||||
<function name="hypot,std::hypot">
|
<function name="hypot,std::hypot">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
<pure/>
|
<pure/>
|
||||||
<returnValue type="double"/>
|
<returnValue type="double">hypot(arg1, arg2)</returnValue>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
|
@ -2136,7 +2136,7 @@
|
||||||
<function name="hypotf,std::hypotf">
|
<function name="hypotf,std::hypotf">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
<pure/>
|
<pure/>
|
||||||
<returnValue type="float"/>
|
<returnValue type="float">hypot(arg1, arg2)</returnValue>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
|
@ -2150,7 +2150,7 @@
|
||||||
<function name="hypotl,std::hypotl">
|
<function name="hypotl,std::hypotl">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
<pure/>
|
<pure/>
|
||||||
<returnValue type="long double"/>
|
<returnValue type="long double">hypot(arg1, arg2)</returnValue>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
|
@ -2989,7 +2989,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
<function name="ldexp,std::ldexp">
|
<function name="ldexp,std::ldexp">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
<pure/>
|
<pure/>
|
||||||
<returnValue type="double"/>
|
<returnValue type="double">ldexp(arg1,arg2)</returnValue>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
|
@ -3003,7 +3003,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
<function name="ldexpf,std::ldexpf">
|
<function name="ldexpf,std::ldexpf">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
<pure/>
|
<pure/>
|
||||||
<returnValue type="float"/>
|
<returnValue type="float">ldexp(arg1,arg2)</returnValue>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
|
@ -3017,7 +3017,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
<function name="ldexpl,std::ldexpl">
|
<function name="ldexpl,std::ldexpl">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
<pure/>
|
<pure/>
|
||||||
<returnValue type="long double"/>
|
<returnValue type="long double">ldexp(arg1,arg2)</returnValue>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
|
@ -3031,7 +3031,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
<function name="lgamma,std::lgamma">
|
<function name="lgamma,std::lgamma">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
<pure/>
|
<pure/>
|
||||||
<returnValue type="double"/>
|
<returnValue type="double">lgamma(arg1)</returnValue>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
|
@ -3042,7 +3042,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
<function name="lgammaf,std::lgammaf">
|
<function name="lgammaf,std::lgammaf">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
<pure/>
|
<pure/>
|
||||||
<returnValue type="float"/>
|
<returnValue type="float">lgamma(arg1)</returnValue>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
|
@ -3053,7 +3053,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
<function name="lgammal,std::lgammal">
|
<function name="lgammal,std::lgammal">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
<pure/>
|
<pure/>
|
||||||
<returnValue type="long double"/>
|
<returnValue type="long double">lgamma(arg1)</returnValue>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
|
@ -3511,7 +3511,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
<function name="ilogb,std::ilogb">
|
<function name="ilogb,std::ilogb">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
<pure/>
|
<pure/>
|
||||||
<returnValue type="int"/>
|
<returnValue type="int">ilogb(arg1)</returnValue>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
|
@ -3522,7 +3522,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
<function name="ilogbf,std::ilogbf">
|
<function name="ilogbf,std::ilogbf">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
<pure/>
|
<pure/>
|
||||||
<returnValue type="int"/>
|
<returnValue type="int">ilogb(arg1)</returnValue>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
|
@ -3533,7 +3533,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
<function name="ilogbl,std::ilogbl">
|
<function name="ilogbl,std::ilogbl">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
<pure/>
|
<pure/>
|
||||||
<returnValue type="int"/>
|
<returnValue type="int">ilogb(arg1)</returnValue>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
|
|
|
@ -642,6 +642,17 @@ static std::unordered_map<std::string, BuiltinLibraryFunction> createBuiltinLibr
|
||||||
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||||
return v;
|
return v;
|
||||||
};
|
};
|
||||||
|
functions["lgamma"] = [](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::lgamma(value);
|
||||||
|
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||||
|
return v;
|
||||||
|
};
|
||||||
functions["cos"] = [](const std::vector<ValueFlow::Value>& args) {
|
functions["cos"] = [](const std::vector<ValueFlow::Value>& args) {
|
||||||
if (args.size() != 1)
|
if (args.size() != 1)
|
||||||
return ValueFlow::Value::unknown();
|
return ValueFlow::Value::unknown();
|
||||||
|
@ -708,6 +719,17 @@ static std::unordered_map<std::string, BuiltinLibraryFunction> createBuiltinLibr
|
||||||
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||||
return v;
|
return v;
|
||||||
};
|
};
|
||||||
|
functions["hypot"] = [](const std::vector<ValueFlow::Value>& args) {
|
||||||
|
if (args.size() != 2)
|
||||||
|
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::hypot(value, args[1].isFloatValue() ? args[1].floatValue : args[1].intvalue);
|
||||||
|
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||||
|
return v;
|
||||||
|
};
|
||||||
functions["fdim"] = [](const std::vector<ValueFlow::Value>& args) {
|
functions["fdim"] = [](const std::vector<ValueFlow::Value>& args) {
|
||||||
if (args.size() != 2)
|
if (args.size() != 2)
|
||||||
return ValueFlow::Value::unknown();
|
return ValueFlow::Value::unknown();
|
||||||
|
@ -763,6 +785,28 @@ static std::unordered_map<std::string, BuiltinLibraryFunction> createBuiltinLibr
|
||||||
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||||
return v;
|
return v;
|
||||||
};
|
};
|
||||||
|
functions["ldexp"] = [](const std::vector<ValueFlow::Value>& args) {
|
||||||
|
if (args.size() != 2)
|
||||||
|
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::ldexp(value, args[1].isFloatValue() ? args[1].floatValue : args[1].intvalue);
|
||||||
|
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
functions["ilogb"] = [](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.intvalue = std::ilogb(value);
|
||||||
|
v.valueType = ValueFlow::Value::ValueType::INT;
|
||||||
|
return v;
|
||||||
|
};
|
||||||
functions["erf"] = [](const std::vector<ValueFlow::Value>& args) {
|
functions["erf"] = [](const std::vector<ValueFlow::Value>& args) {
|
||||||
if (args.size() != 1)
|
if (args.size() != 1)
|
||||||
return ValueFlow::Value::unknown();
|
return ValueFlow::Value::unknown();
|
||||||
|
|
|
@ -36,6 +36,27 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
int zerodiv_ldexp()
|
||||||
|
{
|
||||||
|
int i = std::ldexp(0.0, 42.0);
|
||||||
|
// cppcheck-suppress zerodiv
|
||||||
|
return 42 / i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int zerodiv_ilogb()
|
||||||
|
{
|
||||||
|
int i = std::ilogb(1.0);
|
||||||
|
// cppcheck-suppress zerodiv
|
||||||
|
return 42 / i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int zerodiv_hypot()
|
||||||
|
{
|
||||||
|
int i = std::hypot(0.0, 0.0);
|
||||||
|
// cppcheck-suppress zerodiv
|
||||||
|
return 42 / i;
|
||||||
|
}
|
||||||
|
|
||||||
int zerodiv_fmod()
|
int zerodiv_fmod()
|
||||||
{
|
{
|
||||||
int i = std::fmod(0.0, 42.0);
|
int i = std::fmod(0.0, 42.0);
|
||||||
|
|
Loading…
Reference in New Issue