Fixed zerodiv FN for '1/std::ceil(0)'
This commit is contained in:
parent
41b6452604
commit
c777cd5060
|
@ -965,7 +965,7 @@
|
|||
<function name="ceil,std::ceil">
|
||||
<use-retval/>
|
||||
<pure/>
|
||||
<returnValue type="double"/>
|
||||
<returnValue type="double">ceil(arg1)</returnValue>
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1" direction="in">
|
||||
|
@ -976,7 +976,7 @@
|
|||
<function name="ceilf,std::ceilf">
|
||||
<use-retval/>
|
||||
<pure/>
|
||||
<returnValue type="float"/>
|
||||
<returnValue type="float">ceil(arg1)</returnValue>
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1" direction="in">
|
||||
|
@ -987,7 +987,7 @@
|
|||
<function name="ceill,std::ceill">
|
||||
<use-retval/>
|
||||
<pure/>
|
||||
<returnValue type="long double"/>
|
||||
<returnValue type="long double">ceil(arg1)</returnValue>
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1" direction="in">
|
||||
|
|
|
@ -741,6 +741,17 @@ static std::unordered_map<std::string, BuiltinLibraryFunction> createBuiltinLibr
|
|||
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||
return v;
|
||||
};
|
||||
functions["ceil"] = [](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::ceil(value);
|
||||
v.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||
return v;
|
||||
};
|
||||
functions["exp"] = [](const std::vector<ValueFlow::Value>& args) {
|
||||
if (args.size() != 1)
|
||||
return ValueFlow::Value::unknown();
|
||||
|
|
|
@ -36,6 +36,13 @@
|
|||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
int zerodiv_ceil()
|
||||
{
|
||||
int i = std::ceil(0);
|
||||
// cppcheck-suppress zerodiv
|
||||
return 42 / i;
|
||||
}
|
||||
|
||||
int zerodiv_sqrt()
|
||||
{
|
||||
int i = std::sqrt(0);
|
||||
|
|
Loading…
Reference in New Issue