Skip to content

Commit c19d3ff

Browse files
mhalkronlieb
authored andcommitted
[llvm-link] Improve missing file error message (llvm#82514)
Add error messages showing the missing filenames. Currently, we only get 'No such file or directory' without any(!) further info. This patch will (only upon ENOENT error) iterate over all requested files and print which ones are actually missing. Change-Id: I2a240e66576980e6878891e10ad3c5972b47ea1f
1 parent 64dee75 commit c19d3ff

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,16 @@ static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L,
386386
// Similar to some flags, internalization doesn't apply to the first file.
387387
bool InternalizeLinkedSymbols = false;
388388
for (const auto &File : Files) {
389+
auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(File);
390+
391+
// When we encounter a missing file, make sure we expose its name.
392+
if (auto EC = BufferOrErr.getError())
393+
if (EC == std::errc::no_such_file_or_directory)
394+
ExitOnErr(createStringError(EC, "No such file or directory: '%s'",
395+
File.c_str()));
396+
389397
std::unique_ptr<MemoryBuffer> Buffer =
390-
ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(File)));
398+
ExitOnErr(errorOrToExpected(std::move(BufferOrErr)));
391399

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

0 commit comments

Comments
 (0)