Fix 10361: false negative: uninitvar (std::next(iterator)) (#4256)
This commit is contained in:
parent
b246781da6
commit
edebe746bc
|
@ -7305,8 +7305,14 @@ static bool needsInitialization(const Variable* var, bool cpp)
|
||||||
return true;
|
return true;
|
||||||
if (var->type() && var->type()->needInitialization == Type::NeedInitialization::True)
|
if (var->type() && var->type()->needInitialization == Type::NeedInitialization::True)
|
||||||
return true;
|
return true;
|
||||||
if (var->valueType() && (var->valueType()->isPrimitive() || var->valueType()->type == ValueType::Type::POD))
|
if (var->valueType()) {
|
||||||
return true;
|
if (var->valueType()->isPrimitive())
|
||||||
|
return true;
|
||||||
|
if (var->valueType()->type == ValueType::Type::POD)
|
||||||
|
return true;
|
||||||
|
if (var->valueType()->type == ValueType::Type::ITERATOR)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -413,19 +413,19 @@ void uninitvar_std_next(const std::vector<int> &v, int count)
|
||||||
if (std::next(v.begin(), count) != v.end()) {}
|
if (std::next(v.begin(), count) != v.end()) {}
|
||||||
|
|
||||||
std::vector<int>::iterator it;
|
std::vector<int>::iterator it;
|
||||||
// TODO-cppcheck-suppress uninitvar
|
// cppcheck-suppress uninitvar
|
||||||
if (std::next(it) != v.end()) {}
|
if (std::next(it) != v.end()) {}
|
||||||
|
|
||||||
std::vector<int>::const_iterator const_it;
|
std::vector<int>::const_iterator const_it;
|
||||||
// TODO-cppcheck-suppress uninitvar
|
// cppcheck-suppress uninitvar
|
||||||
if (std::next(const_it) != v.end()) {}
|
if (std::next(const_it) != v.end()) {}
|
||||||
|
|
||||||
std::vector<int>::reverse_iterator rit;
|
std::vector<int>::reverse_iterator rit;
|
||||||
// TODO-cppcheck-suppress uninitvar
|
// cppcheck-suppress uninitvar
|
||||||
if (std::next(rit) != v.rend()) {}
|
if (std::next(rit) != v.rend()) {}
|
||||||
|
|
||||||
std::vector<int>::const_reverse_iterator const_rit;
|
std::vector<int>::const_reverse_iterator const_rit;
|
||||||
// TODO-cppcheck-suppress uninitvar
|
// cppcheck-suppress uninitvar
|
||||||
if (std::next(const_rit) != v.rend()) {}
|
if (std::next(const_rit) != v.rend()) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,19 +436,19 @@ void uninitvar_std_prev(const std::vector<int> &v, int count)
|
||||||
if (std::prev(v.begin(), count) != v.end()) {}
|
if (std::prev(v.begin(), count) != v.end()) {}
|
||||||
|
|
||||||
std::vector<int>::iterator it;
|
std::vector<int>::iterator it;
|
||||||
// TODO-cppcheck-suppress uninitvar
|
// cppcheck-suppress uninitvar
|
||||||
if (std::prev(it) != v.end()) {}
|
if (std::prev(it) != v.end()) {}
|
||||||
|
|
||||||
std::vector<int>::const_iterator const_it;
|
std::vector<int>::const_iterator const_it;
|
||||||
// TODO-cppcheck-suppress uninitvar
|
// cppcheck-suppress uninitvar
|
||||||
if (std::prev(const_it) != v.end()) {}
|
if (std::prev(const_it) != v.end()) {}
|
||||||
|
|
||||||
std::vector<int>::reverse_iterator rit;
|
std::vector<int>::reverse_iterator rit;
|
||||||
// TODO-cppcheck-suppress uninitvar
|
// cppcheck-suppress uninitvar
|
||||||
if (std::prev(rit) != v.rend()) {}
|
if (std::prev(rit) != v.rend()) {}
|
||||||
|
|
||||||
std::vector<int>::const_reverse_iterator const_rit;
|
std::vector<int>::const_reverse_iterator const_rit;
|
||||||
// TODO-cppcheck-suppress uninitvar
|
// cppcheck-suppress uninitvar
|
||||||
if (std::prev(const_rit) != v.rend()) {}
|
if (std::prev(const_rit) != v.rend()) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4095,7 +4095,7 @@ void stdalgorithm(const std::list<int> &ints1, const std::list<int> &ints2)
|
||||||
// #9455
|
// #9455
|
||||||
std::list<int>::const_iterator uninitItBegin;
|
std::list<int>::const_iterator uninitItBegin;
|
||||||
std::list<int>::const_iterator uninitItEnd;
|
std::list<int>::const_iterator uninitItEnd;
|
||||||
// @todo cppcheck-suppress uninitvar
|
// cppcheck-suppress uninitvar
|
||||||
if (std::find(uninitItBegin, uninitItEnd, 123) == uninitItEnd) {}
|
if (std::find(uninitItBegin, uninitItEnd, 123) == uninitItEnd) {}
|
||||||
|
|
||||||
// <!-- InputIterator std::find_if(InputIterator first, InputIterator last, UnaryPredicate val) -->
|
// <!-- InputIterator std::find_if(InputIterator first, InputIterator last, UnaryPredicate val) -->
|
||||||
|
|
Loading…
Reference in New Issue