[libcxx-commits] [libcxx] [libcxx] Handle windows system error code mapping in std::error_code. (PR #93101)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 13 15:05:39 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff b74e7792194d9a8a9ef32c7dc1ffcd205b299336 1533c1018f19f5078d8ba567c75b1c682fdadd28 --extensions cpp,h -- libcxx/test/libcxx/diagnostics/system_error_win_codes.pass.cpp libcxx/include/__filesystem/directory_entry.h libcxx/include/__system_error/system_error.h libcxx/src/filesystem/directory_iterator.cpp libcxx/src/filesystem/error.h libcxx/src/filesystem/file_descriptor.h libcxx/src/filesystem/operations.cpp libcxx/src/filesystem/posix_compat.h libcxx/src/print.cpp libcxx/src/system_error.cpp libcxx/test/std/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/status.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/symlink_status.pass.cpp libcxx/test/support/filesystem_test_helper.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/src/system_error.cpp b/libcxx/src/system_error.cpp
index 967826d7ef..cd8526a1aa 100644
--- a/libcxx/src/system_error.cpp
+++ b/libcxx/src/system_error.cpp
@@ -36,56 +36,106 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace {
std::optional<errc> __win_err_to_errc(int err) {
switch (err) {
- case ERROR_ACCESS_DENIED: return errc::permission_denied;
- case ERROR_ALREADY_EXISTS: return errc::file_exists;
- case ERROR_BAD_NETPATH: return errc::no_such_file_or_directory;
- case ERROR_BAD_PATHNAME: return errc::no_such_file_or_directory;
- case ERROR_BAD_UNIT: return errc::no_such_device;
- case ERROR_BROKEN_PIPE: return errc::broken_pipe;
- case ERROR_BUFFER_OVERFLOW: return errc::filename_too_long;
- case ERROR_BUSY: return errc::device_or_resource_busy;
- case ERROR_BUSY_DRIVE: return errc::device_or_resource_busy;
- case ERROR_CANNOT_MAKE: return errc::permission_denied;
- case ERROR_CANTOPEN: return errc::io_error;
- case ERROR_CANTREAD: return errc::io_error;
- case ERROR_CANTWRITE: return errc::io_error;
- case ERROR_CURRENT_DIRECTORY: return errc::permission_denied;
- case ERROR_DEV_NOT_EXIST: return errc::no_such_device;
- case ERROR_DEVICE_IN_USE: return errc::device_or_resource_busy;
- case ERROR_DIR_NOT_EMPTY: return errc::directory_not_empty;
- case ERROR_DIRECTORY: return errc::invalid_argument;
- case ERROR_DISK_FULL: return errc::no_space_on_device;
- case ERROR_FILE_EXISTS: return errc::file_exists;
- case ERROR_FILE_NOT_FOUND: return errc::no_such_file_or_directory;
- case ERROR_HANDLE_DISK_FULL: return errc::no_space_on_device;
- case ERROR_INVALID_ACCESS: return errc::permission_denied;
- case ERROR_INVALID_DRIVE: return errc::no_such_device;
- case ERROR_INVALID_FUNCTION: return errc::function_not_supported;
- case ERROR_INVALID_HANDLE: return errc::invalid_argument;
- case ERROR_INVALID_NAME: return errc::no_such_file_or_directory;
- case ERROR_INVALID_PARAMETER: return errc::invalid_argument;
- case ERROR_LOCK_VIOLATION: return errc::no_lock_available;
- case ERROR_LOCKED: return errc::no_lock_available;
- case ERROR_NEGATIVE_SEEK: return errc::invalid_argument;
- case ERROR_NOACCESS: return errc::permission_denied;
- case ERROR_NOT_ENOUGH_MEMORY: return errc::not_enough_memory;
- case ERROR_NOT_READY: return errc::resource_unavailable_try_again;
- case ERROR_NOT_SAME_DEVICE: return errc::cross_device_link;
- case ERROR_NOT_SUPPORTED: return errc::not_supported;
- case ERROR_OPEN_FAILED: return errc::io_error;
- case ERROR_OPEN_FILES: return errc::device_or_resource_busy;
- case ERROR_OPERATION_ABORTED: return errc::operation_canceled;
- case ERROR_OUTOFMEMORY: return errc::not_enough_memory;
- case ERROR_PATH_NOT_FOUND: return errc::no_such_file_or_directory;
- case ERROR_READ_FAULT: return errc::io_error;
- case ERROR_REPARSE_TAG_INVALID: return errc::invalid_argument;
- case ERROR_RETRY: return errc::resource_unavailable_try_again;
- case ERROR_SEEK: return errc::io_error;
- case ERROR_SHARING_VIOLATION: return errc::permission_denied;
- case ERROR_TOO_MANY_OPEN_FILES: return errc::too_many_files_open;
- case ERROR_WRITE_FAULT: return errc::io_error;
- case ERROR_WRITE_PROTECT: return errc::permission_denied;
- default: return {};
+ case ERROR_ACCESS_DENIED:
+ return errc::permission_denied;
+ case ERROR_ALREADY_EXISTS:
+ return errc::file_exists;
+ case ERROR_BAD_NETPATH:
+ return errc::no_such_file_or_directory;
+ case ERROR_BAD_PATHNAME:
+ return errc::no_such_file_or_directory;
+ case ERROR_BAD_UNIT:
+ return errc::no_such_device;
+ case ERROR_BROKEN_PIPE:
+ return errc::broken_pipe;
+ case ERROR_BUFFER_OVERFLOW:
+ return errc::filename_too_long;
+ case ERROR_BUSY:
+ return errc::device_or_resource_busy;
+ case ERROR_BUSY_DRIVE:
+ return errc::device_or_resource_busy;
+ case ERROR_CANNOT_MAKE:
+ return errc::permission_denied;
+ case ERROR_CANTOPEN:
+ return errc::io_error;
+ case ERROR_CANTREAD:
+ return errc::io_error;
+ case ERROR_CANTWRITE:
+ return errc::io_error;
+ case ERROR_CURRENT_DIRECTORY:
+ return errc::permission_denied;
+ case ERROR_DEV_NOT_EXIST:
+ return errc::no_such_device;
+ case ERROR_DEVICE_IN_USE:
+ return errc::device_or_resource_busy;
+ case ERROR_DIR_NOT_EMPTY:
+ return errc::directory_not_empty;
+ case ERROR_DIRECTORY:
+ return errc::invalid_argument;
+ case ERROR_DISK_FULL:
+ return errc::no_space_on_device;
+ case ERROR_FILE_EXISTS:
+ return errc::file_exists;
+ case ERROR_FILE_NOT_FOUND:
+ return errc::no_such_file_or_directory;
+ case ERROR_HANDLE_DISK_FULL:
+ return errc::no_space_on_device;
+ case ERROR_INVALID_ACCESS:
+ return errc::permission_denied;
+ case ERROR_INVALID_DRIVE:
+ return errc::no_such_device;
+ case ERROR_INVALID_FUNCTION:
+ return errc::function_not_supported;
+ case ERROR_INVALID_HANDLE:
+ return errc::invalid_argument;
+ case ERROR_INVALID_NAME:
+ return errc::no_such_file_or_directory;
+ case ERROR_INVALID_PARAMETER:
+ return errc::invalid_argument;
+ case ERROR_LOCK_VIOLATION:
+ return errc::no_lock_available;
+ case ERROR_LOCKED:
+ return errc::no_lock_available;
+ case ERROR_NEGATIVE_SEEK:
+ return errc::invalid_argument;
+ case ERROR_NOACCESS:
+ return errc::permission_denied;
+ case ERROR_NOT_ENOUGH_MEMORY:
+ return errc::not_enough_memory;
+ case ERROR_NOT_READY:
+ return errc::resource_unavailable_try_again;
+ case ERROR_NOT_SAME_DEVICE:
+ return errc::cross_device_link;
+ case ERROR_NOT_SUPPORTED:
+ return errc::not_supported;
+ case ERROR_OPEN_FAILED:
+ return errc::io_error;
+ case ERROR_OPEN_FILES:
+ return errc::device_or_resource_busy;
+ case ERROR_OPERATION_ABORTED:
+ return errc::operation_canceled;
+ case ERROR_OUTOFMEMORY:
+ return errc::not_enough_memory;
+ case ERROR_PATH_NOT_FOUND:
+ return errc::no_such_file_or_directory;
+ case ERROR_READ_FAULT:
+ return errc::io_error;
+ case ERROR_REPARSE_TAG_INVALID:
+ return errc::invalid_argument;
+ case ERROR_RETRY:
+ return errc::resource_unavailable_try_again;
+ case ERROR_SEEK:
+ return errc::io_error;
+ case ERROR_SHARING_VIOLATION:
+ return errc::permission_denied;
+ case ERROR_TOO_MANY_OPEN_FILES:
+ return errc::too_many_files_open;
+ case ERROR_WRITE_FAULT:
+ return errc::io_error;
+ case ERROR_WRITE_PROTECT:
+ return errc::permission_denied;
+ default:
+ return {};
}
}
} // namespace
``````````
</details>
https://github.com/llvm/llvm-project/pull/93101
More information about the libcxx-commits
mailing list