[PATCH] D120299: [VFS] Use generic_category for errors generated from the VFS

Ben Barham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 21 21:26:45 PST 2022


bnbarham created this revision.
bnbarham added a reviewer: keith.
Herald added subscribers: dexonsmith, hiraditya.
bnbarham requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120299

Files:
  llvm/lib/Support/VirtualFileSystem.cpp


Index: llvm/lib/Support/VirtualFileSystem.cpp
===================================================================
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -485,8 +485,7 @@
     }
 
     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 @@
   }
 
   if (!S->isDirectory()) {
-    EC = std::error_code(static_cast<int>(errc::not_a_directory),
-                         std::system_category());
+    EC = errc::not_a_directory;
     return {};
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120299.410442.patch
Type: text/x-patch
Size: 730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220222/75b28053/attachment.bin>


More information about the llvm-commits mailing list