[lld] r353572 - [lld-link] better error message when failing to open archive members
Bob Haarman via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 8 13:59:35 PST 2019
Author: inglorion
Date: Fri Feb 8 13:59:35 2019
New Revision: 353572
URL: http://llvm.org/viewvc/llvm-project?rev=353572&view=rev
Log:
[lld-link] better error message when failing to open archive members
Summary:
The message "could not get the buffer for the member defining symbol"
now also contains the name of the archive and the name of the archive
member that we tried to open.
Reviewers: ruiu
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D57974
Modified:
lld/trunk/COFF/Driver.cpp
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=353572&r1=353571&r2=353572&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Fri Feb 8 13:59:35 2019
@@ -224,23 +224,33 @@ void LinkerDriver::addArchiveBuffer(Memo
void LinkerDriver::enqueueArchiveMember(const Archive::Child &C,
StringRef SymName,
StringRef ParentName) {
+
+ auto ReportBufferError = [=](Error &&E,
+ StringRef ChildName) {
+ fatal("could not get the buffer for the member defining symbol " +
+ SymName + ": " + ParentName + "(" + ChildName + "): " +
+ toString(std::move(E)));
+ };
+
if (!C.getParent()->isThin()) {
- MemoryBufferRef MB = CHECK(
- C.getMemoryBufferRef(),
- "could not get the buffer for the member defining symbol " + SymName);
+ Expected<MemoryBufferRef> MBOrErr = C.getMemoryBufferRef();
+ if (!MBOrErr)
+ ReportBufferError(MBOrErr.takeError(), check(C.getFullName()));
+ MemoryBufferRef MB = MBOrErr.get();
enqueueTask([=]() { Driver->addArchiveBuffer(MB, SymName, ParentName); });
return;
}
- auto Future = std::make_shared<std::future<MBErrPair>>(createFutureForFile(
- CHECK(C.getFullName(),
- "could not get the filename for the member defining symbol " +
- SymName)));
+ std::string ChildName = CHECK(
+ C.getFullName(),
+ "could not get the filename for the member defining symbol " +
+ SymName);
+ auto Future = std::make_shared<std::future<MBErrPair>>(
+ createFutureForFile(ChildName));
enqueueTask([=]() {
auto MBOrErr = Future->get();
if (MBOrErr.second)
- fatal("could not get the buffer for the member defining " + SymName +
- ": " + MBOrErr.second.message());
+ ReportBufferError(errorCodeToError(MBOrErr.second), ChildName);
Driver->addArchiveBuffer(takeBuffer(std::move(MBOrErr.first)), SymName,
ParentName);
});
More information about the llvm-commits
mailing list