[PATCH] D57974: [lld-link] better error message when failing to open archive members
Bob Haarman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 8 13:52:25 PST 2019
inglorion updated this revision to Diff 186039.
inglorion marked an inline comment as done.
inglorion added a comment.
Use [=] instead of explicitly passing StringRefs to ReportBufferError.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57974/new/
https://reviews.llvm.org/D57974
Files:
lld/COFF/Driver.cpp
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -224,23 +224,33 @@
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);
});
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57974.186039.patch
Type: text/x-patch
Size: 1978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190208/d421ad41/attachment.bin>
More information about the llvm-commits
mailing list