std.cfg: use-retval for container member functions (#4766)

This commit is contained in:
chrchr-github 2023-02-06 22:03:23 +01:00 committed by GitHub
parent 7dde6c5d29
commit d8323c367e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -6699,11 +6699,15 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<not-uninit/> <not-uninit/>
</arg> </arg>
</function> </function>
<function name="std::list::back,std::list::front,std::forward_list::front,std::queue::back,std::queue::front,std::vector::back,std::vector::front,std::array::front,std::array::back"> <function name="std::list::back,std::list::front,std::forward_list::front,std::queue::back,std::queue::front,std::vector::back,std::vector::front,std::array::front,std::array::back,std::string::front,std::string::back,std::wstring::front,std::wstring::back,std::string_view::front,std::string_view::back,std::wstring_view::front,std::wstring_view::back">
<use-retval/> <use-retval/>
<noreturn>false</noreturn> <noreturn>false</noreturn>
</function> </function>
<function name="std::vector::at"> <function name="std::list::begin,std::list::end,std::forward_list::begin,std::forward_list::end,std::queue::begin,std::queue::end,std::vector::begin,std::vector::end,std::array::begin,std::array::end,std::string::begin,std::string::end,std::wstring::begin,std::wstring::end,std::string_view::begin,std::string_view::end,std::wstring_view::begin,std::wstring_view::end">
<use-retval/>
<noreturn>false</noreturn>
</function>
<function name="std::vector::at,std::array::at,std::string::at,std::wstring::at,std::string_view::at,std::wstring_view::at">
<use-retval/> <use-retval/>
<noreturn>false</noreturn> <noreturn>false</noreturn>
<arg nr="1"> <arg nr="1">

View File

@ -4205,6 +4205,19 @@ void ignoredReturnValue_string_compare(std::string teststr, std::wstring testwst
testwstr.compare(L"wtest"); testwstr.compare(L"wtest");
} }
// cppcheck-suppress constParameter
void ignoredReturnValue_container_access(std::string& s, std::string_view& sv, std::vector<int>& v)
{
// cppcheck-suppress ignoredReturnValue
s.begin();
// cppcheck-suppress ignoredReturnValue
v.end();
// cppcheck-suppress ignoredReturnValue
sv.front();
// cppcheck-suppress ignoredReturnValue
s.at(0);
}
void ignoredReturnValue_locale_global(const std::locale& loc) void ignoredReturnValue_locale_global(const std::locale& loc)
{ {
// no ignoredReturnValue shall be shown for // no ignoredReturnValue shall be shown for