Skip to content

Commit 4e66b59

Browse files
authored
std.cfg: Added support for std::quoted() (#5996)
1 parent 8050448 commit 4e66b59

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

cfg/std.cfg

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6428,7 +6428,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
64286428
std::istringstream& std::istringstream::get (char* s, streamsize n, char delim);
64296429
stream buffer (3) std::istringstream& std::istringstream::get (streambuf& sb);
64306430
std::istringstream& std::istringstream::get (streambuf& sb, char delim);-->
6431-
<!-- There is currently no way to define this properly because Cppcheck lacks support for
6431+
<!-- There is currently no way to define this properly because Cppcheck lacks support for
64326432
overloaded functions.-->
64336433
<function name="std::istream::get,std::istringstream::get">
64346434
<noreturn>false</noreturn>
@@ -6566,6 +6566,31 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
65666566
<valid>0:</valid>
65676567
</arg>
65686568
</function>
6569+
<!--https://en.cppreference.com/w/cpp/io/manip/quoted -->
6570+
<!--template< class CharT >
6571+
/*unspecified*/ quoted( const CharT* s,
6572+
CharT delim = CharT('"'), CharT escape = CharT('\\') ); (1)(since C++14)
6573+
template< class CharT, class Traits, class Allocator >
6574+
/*unspecified*/ quoted( const std::basic_string<CharT, Traits, Allocator>& s,
6575+
CharT delim = CharT('"'), CharT escape = CharT('\\') ); (2)(since C++14)
6576+
template< class CharT, class Traits>
6577+
/*unspecified*/ quoted( std::basic_string_view<CharT, Traits> s,
6578+
CharT delim = CharT('"'), CharT escape = CharT('\\') ); (3)(since C++17)
6579+
template< class CharT, class Traits, class Allocator >
6580+
/*unspecified*/ quoted( std::basic_string<CharT, Traits, Allocator>& s,
6581+
CharT delim=CharT('"'), CharT escape=CharT('\\') ); (4)(since C++14) -->
6582+
<function name="std::quoted">
6583+
<!-- This function returns an object of unspecified type -->
6584+
<leak-ignore/>
6585+
<noreturn>false</noreturn>
6586+
<arg nr="1" direction="in"/>
6587+
<arg nr="2" direction="in" default="&apos;&quot;&apos;">
6588+
<not-uninit/>
6589+
</arg>
6590+
<arg nr="3" direction="in" default="&apos;\\&apos;">
6591+
<not-uninit/>
6592+
</arg>
6593+
</function>
65696594
<!--std::ostream& std::ostream::write (const char* s, streamsize n);-->
65706595
<function name="std::ostream::write">
65716596
<returnValue type="std::ostream &amp;"/>
@@ -8303,7 +8328,7 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
83038328
<not-bool/>
83048329
<strz/>
83058330
</arg>
8306-
</function>
8331+
</function>
83078332
<!-- int mtx_init( mtx_t* mutex, int type ); // since C11 -->
83088333
<function name="mtx_init">
83098334
<noreturn>false</noreturn>

test/cfg/std.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@
5353
#include <span>
5454
#endif
5555

56+
// https://en.cppreference.com/w/cpp/io/manip/quoted
57+
void uninitvar_std_quoted(std::stringstream &ss, const std::string &input, const char delim, const char escape)
58+
{
59+
ss << std::quoted(input);
60+
ss << std::quoted(input, delim);
61+
ss << std::quoted(input, delim, escape);
62+
char delimChar;
63+
// cppcheck-suppress uninitvar
64+
ss << std::quoted(input, delimChar);
65+
char escapeChar;
66+
// cppcheck-suppress uninitvar
67+
ss << std::quoted(input, delim, escapeChar);
68+
}
69+
5670
int zerodiv_ldexp()
5771
{
5872
int i = std::ldexp(0.0, 42.0);

0 commit comments

Comments
 (0)