Skip to content

Commit 73bbd41

Browse files
committed
[llvm-link] Improve missing file error message
Add error message showing the missing filename. Currently, we only get 'No such file or directory' without any(!) further info. This patch will (upon ENOENT error) create an error which exposes the filename.
1 parent 81b4b89 commit 73bbd41

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

llvm/tools/llvm-link/llvm-link.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,16 @@ static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L,
393393
// Similar to some flags, internalization doesn't apply to the first file.
394394
bool InternalizeLinkedSymbols = false;
395395
for (const auto &File : Files) {
396+
auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(File);
397+
398+
// When we encounter a missing file, make sure we expose its name.
399+
if (auto EC = BufferOrErr.getError())
400+
if (EC == std::errc::no_such_file_or_directory)
401+
ExitOnErr(createStringError(EC, "No such file or directory: '%s'",
402+
File.c_str()));
403+
396404
std::unique_ptr<MemoryBuffer> Buffer =
397-
ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(File)));
405+
ExitOnErr(errorOrToExpected(std::move(BufferOrErr)));
398406

399407
std::unique_ptr<Module> M =
400408
identify_magic(Buffer->getBuffer()) == file_magic::archive

0 commit comments

Comments
 (0)