Skip to content

Commit 66b60bf

Browse files
committed
[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
1 parent 01b0925 commit 66b60bf

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

llvm/lib/Support/VirtualFileSystem.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,7 @@ class CombiningDirIterImpl : public llvm::vfs::detail::DirIterImpl {
482482
}
483483

484484
if (IsFirstTime && CurrentDirIter == directory_iterator())
485-
return std::error_code(static_cast<int>(errc::no_such_file_or_directory),
486-
std::system_category());
485+
return errc::no_such_file_or_directory;
487486
return {};
488487
}
489488

@@ -1265,8 +1264,7 @@ directory_iterator RedirectingFileSystem::dir_begin(const Twine &Dir,
12651264
}
12661265

12671266
if (!S->isDirectory()) {
1268-
EC = std::error_code(static_cast<int>(errc::not_a_directory),
1269-
std::system_category());
1267+
EC = errc::not_a_directory;
12701268
return {};
12711269
}
12721270

0 commit comments

Comments
 (0)