diff options
author | Cyndy Ishida <cyndy_ishida@apple.com> | 2024-02-03 10:02:16 -0800 |
---|---|---|
committer | Cyndy Ishida <cyndy_ishida@apple.com> | 2024-02-03 10:02:16 -0800 |
commit | 5bcd91058ee4855804780c4ae35ac87ed45a4b58 (patch) | |
tree | b986f71b0d2c4ab1646231148cf1b9800b5b69ec | |
parent | 0ed02621b9d87342daff0dcd9014319d4eeb2735 (diff) | |
download | llvm-5bcd91058ee4855804780c4ae35ac87ed45a4b58.zip llvm-5bcd91058ee4855804780c4ae35ac87ed45a4b58.tar.gz llvm-5bcd91058ee4855804780c4ae35ac87ed45a4b58.tar.bz2 |
[readtapi] Use ExitOnError instead of errorcodes for `readlink` wrapper
Silences: ` error C4716: 'read_link': must return a value` windows error
-rw-r--r-- | llvm/tools/llvm-readtapi/llvm-readtapi.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp index ba348e4..5944b1c 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 |