[llvm] 5bcd910 - [readtapi] Use ExitOnError instead of errorcodes for `readlink` wrapper

Cyndy Ishida via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 3 10:04:41 PST 2024


Author: Cyndy Ishida
Date: 2024-02-03T10:02:16-08:00
New Revision: 5bcd91058ee4855804780c4ae35ac87ed45a4b58

URL: https://github.com/llvm/llvm-project/commit/5bcd91058ee4855804780c4ae35ac87ed45a4b58
DIFF: https://github.com/llvm/llvm-project/commit/5bcd91058ee4855804780c4ae35ac87ed45a4b58.diff

LOG: [readtapi] Use ExitOnError instead of errorcodes for `readlink` wrapper

Silences: ` error C4716: 'read_link': must return a value` windows error

Added: 
    

Modified: 
    llvm/tools/llvm-readtapi/llvm-readtapi.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
index ba348e4cf3867..5944b1cd1f591 100644
--- a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
+++ b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
@@ -102,22 +102,20 @@ static void reportWarning(Twine Message) {
 
 /// Get what the symlink points to.
 /// This is a no-op on windows as it references POSIX level apis.
-static std::error_code read_link(const Twine &Path,
-                                 SmallVectorImpl<char> &Output) {
+static void read_link(const Twine &Path, SmallVectorImpl<char> &Output) {
 #if !defined(_MSC_VER) && !defined(__MINGW32__)
   Output.clear();
   if (Path.isTriviallyEmpty())
-    return std::error_code();
+    return;
 
   SmallString<PATH_MAX> Storage;
   auto P = Path.toNullTerminatedStringRef(Storage);
   SmallString<PATH_MAX> Result;
   ssize_t Len;
   if ((Len = ::readlink(P.data(), Result.data(), PATH_MAX)) == -1)
-    return std::error_code(errno, std::generic_category());
+    reportError("unable to read symlink: " + Path);
   Result.resize_for_overwrite(Len);
   Output.swap(Result);
-  return std::error_code();
 #else
   reportError("unable to read symlink on windows: " + Path);
 #endif
@@ -265,9 +263,7 @@ static void stubifyDirectory(const StringRef InputPath, Context &Ctx) {
       }
 
       SmallString<PATH_MAX> SymPath;
-      if (auto EC = read_link(Path, SymPath))
-        reportError("cannot read '" + Path + "' :" + EC.message());
-
+      read_link(Path, SymPath);
       // Sometimes there are broken symlinks that are absolute paths, which are
       // invalid during build time, but would be correct during runtime. In the
       // case of an absolute path we should check first if the path exists with


        


More information about the llvm-commits mailing list