Add support for std::unordered_set::count(), std::push_heap (#4469)

* Add support for std::copy_n/merge/stable_sort

* Format

* Add support for std::unordered_set::count(), std::push_heap

* Missing include
This commit is contained in:
chrchr-github 2022-09-16 07:12:36 +02:00 committed by GitHub
parent a536d53d62
commit d6aab96734
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View File

@ -6682,7 +6682,8 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<!-- size_type std::map::count( const Key& key ) const; -->
<!-- template< class K > size_type std::map::count( const K& x ) const; // since C++14 -->
<!-- size_type std::set::count( const value_type& val) const; -->
<function name="std::map::count,std::set::count">
<!-- size_type std::unordered_set::count( const Key& key ) const; -->
<function name="std::map::count,std::set::count,std::unordered_set::count">
<noreturn>false</noreturn>
<returnValue type="size_t"/>
<use-retval/>
@ -7564,6 +7565,19 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
<iterator container="3" type="first"/>
</arg>
</function>
<!-- template< class RandomIt > void push_heap( RandomIt first, RandomIt last ); -->
<function name="std::push_heap">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1">
<not-uninit/>
<iterator container="1" type="first"/>
</arg>
<arg nr="2">
<not-uninit/>
<iterator container="1" type="last"/>
</arg>
</function>
<!-- template< class RandomIt > void std::random_shuffle( RandomIt first, RandomIt last ); (deprecated in C++14) (removed in C++17) -->
<!-- template< class RandomIt, class RandomFunc > void std::random_shuffle( RandomIt first, RandomIt last, RandomFunc& r ); (until C++11) -->
<!-- template< class RandomIt, class RandomFunc > void std::random_shuffle( RandomIt first, RandomIt last, RandomFunc&& r ); (since C++11) (deprecated in C++14) (removed in C++17) -->

View File

@ -35,6 +35,7 @@
#include <istream>
#include <iterator>
#include <vector>
#include <unordered_set>
#include <algorithm>
int zerodiv_ldexp()
@ -827,6 +828,13 @@ std::bitset<10> std_bitset_count_ignoredReturnValue()
return b1;
}
void std_unordered_set_count_ignoredReturnValue(const std::unordered_set<int>& u)
{
int i;
// cppcheck-suppress [uninitvar, ignoredReturnValue]
u.count(i);
}
void valid_code()
{
std::vector<int> vecInt{0, 1, 2};
@ -2990,6 +2998,13 @@ void uninitvar_merge(const std::vector<int>& a, const std::vector<int>& b)
std::merge(a.begin(), a.end(), b.begin(), b.end(), dst);
}
void uninitvar_push_heap(std::vector<int>& v)
{
std::vector<int>::iterator end;
// cppcheck-suppress uninitvar
std::push_heap(v.begin(), end);
}
void uninitvar_copy_n(const std::vector<int>& v)
{
std::vector<int>::iterator dst;