Skip to content

Commit

Permalink
std.cfg: Added support for std::filesystem::exists()
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitcowboy committed Feb 22, 2024
1 parent 7ebb7bf commit 7efa8de
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
15 changes: 13 additions & 2 deletions cfg/std.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6498,6 +6498,17 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<not-uninit/>
</arg>
</function>
<!-- (1) (since C++17) bool std::filesystem::exists( std::filesystem::file_status s ) noexcept; -->
<!-- (2) (since C++17) bool std::filesystem::exists( const std::filesystem::path& p ); -->
<!-- (3) (since C++17) bool std::filesystem::exists( const std::filesystem::path& p, std::error_code& ec ) noexcept; -->
<function name="std::filesystem::exists">
<returnValue type="bool"/>
<noreturn>false</noreturn>
<leak-ignore/>
<use-retval/>
<arg nr="1" direction="in"/>
<arg nr="2" direction="out" default=""/>
</function>
<!-- std::string std::ostringstream::str() const; -->
<!-- std::string std::stringstream::str() const; -->
<!-- @todo Implement the second version when function overloading is possible: -->
Expand Down Expand Up @@ -6814,7 +6825,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<function name="std::exchange">
<leak-ignore/>
<noreturn>false</noreturn>
<use-retval/>
<use-retval/>
<returnValue>arg1</returnValue>
<arg nr="1">
<not-uninit/>
Expand Down Expand Up @@ -8998,7 +9009,7 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
<podtype name="std::atomic_intmax_t"/>
<podtype name="std::atomic_uintmax_t"/>
<!-- https://en.cppreference.com/w/c/program/SIG_types
Values are in alignment with posix.cfg -->
Values are in alignment with posix.cfg -->
<define name="SIGTERM" value="15"/>
<define name="SIGSEGV" value="11"/>
<define name="SIGINT" value="2"/>
Expand Down
13 changes: 12 additions & 1 deletion test/cfg/std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <cwchar>
#include <deque>
#include <exception>
#include <filesystem>
#include <fstream>
#include <functional>
#ifndef __STDC_NO_THREADS__
Expand Down Expand Up @@ -54,6 +55,16 @@
#include <span>
#endif

bool ignoredReturnValue_std_filesystem_exists(const std::filesystem::path &path, std::error_code& ec)
{
// cppcheck-suppress ignoredReturnValue
std::filesystem::exists(path);
// cppcheck-suppress ignoredReturnValue
std::filesystem::exists(path, ec);
const bool b {std::filesystem::exists(path)};
return b && std::filesystem::exists(path, ec);
}

// 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)
{
Expand Down Expand Up @@ -4956,4 +4967,4 @@ void eraseIteratorOutOfBounds_std_deque(std::deque<int>& x) // #8690
{
// cppcheck-suppress eraseIteratorOutOfBounds
x.erase(x.end());
}
}

0 comments on commit 7efa8de

Please sign in to comment.