aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-link/llvm-link.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-link/llvm-link.cpp')
-rw-r--r--llvm/tools/llvm-link/llvm-link.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index e6c219a..9e7f2c3 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -393,8 +393,16 @@ static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L,
// Similar to some flags, internalization doesn't apply to the first file.
bool InternalizeLinkedSymbols = false;
for (const auto &File : Files) {
+ auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(File);
+
+ // When we encounter a missing file, make sure we expose its name.
+ if (auto EC = BufferOrErr.getError())
+ if (EC == std::errc::no_such_file_or_directory)
+ ExitOnErr(createStringError(EC, "No such file or directory: '%s'",
+ File.c_str()));
+
std::unique_ptr<MemoryBuffer> Buffer =
- ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(File)));
+ ExitOnErr(errorOrToExpected(std::move(BufferOrErr)));
std::unique_ptr<Module> M =
identify_magic(Buffer->getBuffer()) == file_magic::archive