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::filesystem::exists() #6022

Merged
merged 1 commit into from
Feb 22, 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
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());
}
}
Loading