[llvm] ed4f0cb - [VFS] Use generic_category for errors generated from the VFS
Ben Barham via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 22 15:09:00 PST 2022
Author: Ben Barham
Date: 2022-02-22T15:05:58-08:00
New Revision: ed4f0cb87878e63378f2a37a2af2b538eb493a04
URL: https://github.com/llvm/llvm-project/commit/ed4f0cb87878e63378f2a37a2af2b538eb493a04
DIFF: https://github.com/llvm/llvm-project/commit/ed4f0cb87878e63378f2a37a2af2b538eb493a04.diff
LOG: [VFS] Use generic_category for errors generated from the VFS
Errors are generally checked in clients by comparing to the portable
error condition in `std::errc`, which will have the `generic_category`
(eg. `std::errc::no_such_file_or_directory`). While in practice these
are usually equivalent for the standard errno's, they are not in *all*
implementations. One such example is CentOS 7.
Differential Revision: https://reviews.llvm.org/D120299
Added:
Modified:
llvm/lib/Support/VirtualFileSystem.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index 49151682624d8..590bc1902fbe4 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -485,8 +485,7 @@ class CombiningDirIterImpl : public llvm::vfs::detail::DirIterImpl {
}
if (IsFirstTime && CurrentDirIter == directory_iterator())
- return std::error_code(static_cast<int>(errc::no_such_file_or_directory),
- std::system_category());
+ return errc::no_such_file_or_directory;
return {};
}
@@ -1285,8 +1284,7 @@ directory_iterator RedirectingFileSystem::dir_begin(const Twine &Dir,
}
if (!S->isDirectory()) {
- EC = std::error_code(static_cast<int>(errc::not_a_directory),
- std::system_category());
+ EC = errc::not_a_directory;
return {};
}
More information about the llvm-commits
mailing list