Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.cfg: Added support for std::quoted() #5996

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions cfg/std.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6428,7 +6428,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
std::istringstream& std::istringstream::get (char* s, streamsize n, char delim);
stream buffer (3) std::istringstream& std::istringstream::get (streambuf& sb);
std::istringstream& std::istringstream::get (streambuf& sb, char delim);-->
<!-- There is currently no way to define this properly because Cppcheck lacks support for
<!-- There is currently no way to define this properly because Cppcheck lacks support for
overloaded functions.-->
<function name="std::istream::get,std::istringstream::get">
<noreturn>false</noreturn>
Expand Down Expand Up @@ -6566,6 +6566,31 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<valid>0:</valid>
</arg>
</function>
<!--https://en.cppreference.com/w/cpp/io/manip/quoted -->
<!--template< class CharT >
/*unspecified*/ quoted( const CharT* s,
CharT delim = CharT('"'), CharT escape = CharT('\\') ); (1)(since C++14)
template< class CharT, class Traits, class Allocator >
/*unspecified*/ quoted( const std::basic_string<CharT, Traits, Allocator>& s,
CharT delim = CharT('"'), CharT escape = CharT('\\') ); (2)(since C++14)
template< class CharT, class Traits>
/*unspecified*/ quoted( std::basic_string_view<CharT, Traits> s,
CharT delim = CharT('"'), CharT escape = CharT('\\') ); (3)(since C++17)
template< class CharT, class Traits, class Allocator >
/*unspecified*/ quoted( std::basic_string<CharT, Traits, Allocator>& s,
CharT delim=CharT('"'), CharT escape=CharT('\\') ); (4)(since C++14) -->
<function name="std::quoted">
<!-- This function returns an object of unspecified type -->
<leak-ignore/>
<noreturn>false</noreturn>
<arg nr="1" direction="in"/>
<arg nr="2" direction="in" default="&apos;&quot;&apos;">
<not-uninit/>
</arg>
<arg nr="3" direction="in" default="&apos;\\&apos;">
<not-uninit/>
</arg>
</function>
<!--std::ostream& std::ostream::write (const char* s, streamsize n);-->
<function name="std::ostream::write">
<returnValue type="std::ostream &amp;"/>
Expand Down Expand Up @@ -8303,7 +8328,7 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
<not-bool/>
<strz/>
</arg>
</function>
</function>
<!-- int mtx_init( mtx_t* mutex, int type ); // since C11 -->
<function name="mtx_init">
<noreturn>false</noreturn>
Expand Down
14 changes: 14 additions & 0 deletions test/cfg/std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@
#include <span>
#endif

// https://en.cppreference.com/w/cpp/io/manip/quoted
void uninitvar_std_quoted(std::stringstream &ss, const std::string &input, const char delim, const char escape)
{
ss << std::quoted(input);
ss << std::quoted(input, delim);
ss << std::quoted(input, delim, escape);
char delimChar;
// cppcheck-suppress uninitvar
ss << std::quoted(input, delimChar);
char escapeChar;
// cppcheck-suppress uninitvar
ss << std::quoted(input, delim, escapeChar);
}

int zerodiv_ldexp()
{
int i = std::ldexp(0.0, 42.0);
Expand Down
Loading