Skip to content

[llvm-link] Improve missing file error message #82514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion llvm/tools/llvm-link/llvm-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down