Skip to content

Commit d9ca58e

Browse files
committed
[lld-link] Do not assert when reporting error about non-thin archive
Follow-up to https://reviews.llvm.org/D57974, which added calls to Archive::Child::getFullName() to produce strings in errors. But getFullName() is only valid on thin archives, and should only be used to open the file the archive points to. For diagnostics, getName() is better: It works for both thin and non-thin files, and it doesn't make a very long string for thin files. And we already prepend the name of the parent archive file anyways.
1 parent 6e977aa commit d9ca58e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lld/COFF/Driver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,17 @@ void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,
404404
const Archive::Symbol &sym,
405405
StringRef parentName) {
406406

407-
auto reportBufferError = [=](Error &&e, StringRef childName) {
407+
auto reportBufferError = [=](Error &&e) {
408408
Fatal(ctx) << "could not get the buffer for the member defining symbol "
409-
<< &sym << ": " << parentName << "(" << childName
409+
<< &sym << ": " << parentName << "(" << check(c.getName())
410410
<< "): " << std::move(e);
411411
};
412412

413413
if (!c.getParent()->isThin()) {
414414
uint64_t offsetInArchive = c.getChildOffset();
415415
Expected<MemoryBufferRef> mbOrErr = c.getMemoryBufferRef();
416416
if (!mbOrErr)
417-
reportBufferError(mbOrErr.takeError(), check(c.getFullName()));
417+
reportBufferError(mbOrErr.takeError());
418418
MemoryBufferRef mb = mbOrErr.get();
419419
enqueueTask([=]() {
420420
llvm::TimeTraceScope timeScope("Archive: ", mb.getBufferIdentifier());
@@ -433,7 +433,7 @@ void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,
433433
enqueueTask([=]() {
434434
auto mbOrErr = future->get();
435435
if (mbOrErr.second)
436-
reportBufferError(errorCodeToError(mbOrErr.second), childName);
436+
reportBufferError(errorCodeToError(mbOrErr.second));
437437
llvm::TimeTraceScope timeScope("Archive: ",
438438
mbOrErr.first->getBufferIdentifier());
439439
ctx.driver.addThinArchiveBuffer(takeBuffer(std::move(mbOrErr.first)),

0 commit comments

Comments
 (0)