std.cfg: add support for smartptr member functions (#5113)

* std.cfg: add support for smartptr member functions

* Fix test

* Fix
This commit is contained in:
chrchr-github 2023-06-03 14:36:30 +02:00 committed by GitHub
parent 1b98be458d
commit f2976e5bb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 6 deletions

View File

@ -7373,9 +7373,10 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
</arg>
</function>
<!-- void std::ifstream::close(); -->
<function name="std::ifstream::close">
<!-- void std::ofstream::close(); -->
<!-- void std::fstream::close(); -->
<function name="std::ifstream::close,std::ofstream::close,std::fstream::close">
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="void"/>
</function>
<!-- void std::fstream::open(const char* filename, ios_base::openmode mode = ios_base::in | ios_base::out); -->
@ -8588,6 +8589,18 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
<const/>
<returnValue type="void *"/>
</function>
<function name="std::auto_ptr::reset,std::shared_ptr::reset,std::unique_ptr::reset,std::weak_ptr::reset">
<noreturn>false</noreturn>
<arg nr="1" direction="in" default="0">
<not-uninit/>
</arg>
<returnValue type="void *"/>
</function>
<function name="std::auto_ptr::release,std::unique_ptr::release">
<use-retval/>
<noreturn>false</noreturn>
<returnValue type="void *"/>
</function>
<memory>
<alloc init="false" buffer-size="malloc">malloc</alloc>
<alloc init="true" buffer-size="calloc">calloc</alloc>

View File

@ -4722,4 +4722,21 @@ void smartPtr_get()
p.get();
//cppcheck-suppress nullPointer
*p = 1;
}
void smartPtr_reset()
{
std::unique_ptr<int> p(new int());
p.reset(nullptr);
//cppcheck-suppress nullPointer
*p = 1;
}
void smartPtr_release()
{
std::unique_ptr<int> p{ new int() };
//cppcheck-suppress ignoredReturnValue
p.release();
//cppcheck-suppress nullPointer
*p = 1;
}

View File

@ -2002,10 +2002,8 @@ private:
" p->h(i);\n"
" p.reset(nullptr);\n"
"}\n", "test.cpp", &s);
TODO_ASSERT_EQUALS("[test.cpp:5]: (information) --check-library: There is no matching configuration for function T::h()\n",
"[test.cpp:5]: (information) --check-library: There is no matching configuration for function T::h()\n"
"[test.cpp:6]: (information) --check-library: There is no matching configuration for function std::shared_ptr::reset()\n",
errout.str());
ASSERT_EQUALS("[test.cpp:5]: (information) --check-library: There is no matching configuration for function T::h()\n",
errout.str());
}
void checkUseStandardLibrary1() {