[lld] r252193 - These are the matching changes needed to the lld project for the changes to llvm
Kevin Enderby via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 5 11:25:47 PST 2015
Author: enderby
Date: Thu Nov 5 13:25:47 2015
New Revision: 252193
URL: http://llvm.org/viewvc/llvm-project?rev=252193&view=rev
Log:
These are the matching changes needed to the lld project for the changes to llvm
in r252192 that changed the Archive and Child interfaces in libObject. These include
Rafael Espindola’s many suggested updates.
Modified:
lld/trunk/COFF/DriverUtils.cpp
lld/trunk/COFF/InputFiles.cpp
lld/trunk/ELF/InputFiles.cpp
lld/trunk/lib/ReaderWriter/FileArchive.cpp
Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=252193&r1=252192&r2=252193&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Thu Nov 5 13:25:47 2015
@@ -521,7 +521,9 @@ static std::unique_ptr<MemoryBuffer> cre
static std::vector<NewArchiveIterator>
readMembers(const object::Archive &Archive) {
std::vector<NewArchiveIterator> V;
- for (const object::Archive::Child &C : Archive.children()) {
+ for (const auto &ChildOrErr : Archive.children()) {
+ error(ChildOrErr, "Archive::Child::getName failed");
+ const object::Archive::Child C(*ChildOrErr);
ErrorOr<StringRef> NameOrErr = C.getName();
error(NameOrErr, "Archive::Child::getName failed");
V.emplace_back(C, *NameOrErr);
@@ -570,7 +572,7 @@ public:
P += Sym.size() + 1;
memcpy(P, DLLName.data(), DLLName.size());
- object::Archive::Child C(Parent, Buf);
+ object::Archive::Child C(Parent, Buf, nullptr);
return NewArchiveIterator(C, DLLName);
}
Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=252193&r1=252192&r2=252193&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Thu Nov 5 13:25:47 2015
@@ -67,8 +67,11 @@ void ArchiveFile::parse() {
// Seen is a map from member files to boolean values. Initially
// all members are mapped to false, which indicates all these files
// are not read yet.
- for (const Archive::Child &Child : File->children())
+ for (auto &ChildOrErr : File->children()) {
+ error(ChildOrErr, "Failed to parse static library");
+ const Archive::Child &Child = *ChildOrErr;
Seen[Child.getChildOffset()].clear();
+ }
}
// Returns a buffer pointing to a member file containing a given symbol.
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=252193&r1=252192&r2=252193&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Thu Nov 5 13:25:47 2015
@@ -308,7 +308,10 @@ std::vector<MemoryBufferRef> ArchiveFile
File = openArchive(MB);
std::vector<MemoryBufferRef> Result;
- for (const Archive::Child &Child : File->children()) {
+ for (auto &ChildOrErr : File->children()) {
+ error(ChildOrErr,
+ "Could not get the child of the archive " + File->getFileName());
+ const Archive::Child Child(*ChildOrErr);
ErrorOr<MemoryBufferRef> MbOrErr = Child.getMemoryBufferRef();
error(MbOrErr, "Could not get the buffer for a child of the archive " +
File->getFileName());
Modified: lld/trunk/lib/ReaderWriter/FileArchive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/FileArchive.cpp?rev=252193&r1=252192&r2=252193&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/FileArchive.cpp (original)
+++ lld/trunk/lib/ReaderWriter/FileArchive.cpp Thu Nov 5 13:25:47 2015
@@ -49,9 +49,11 @@ public:
if (member == _symbolMemberMap.end())
return nullptr;
Archive::child_iterator ci = member->second;
+ if (ci->getError())
+ return nullptr;
// Don't return a member already returned
- ErrorOr<StringRef> buf = ci->getBuffer();
+ ErrorOr<StringRef> buf = (*ci)->getBuffer();
if (!buf)
return nullptr;
const char *memberStart = buf->data();
@@ -90,9 +92,11 @@ public:
if (member == _symbolMemberMap.end())
return;
Archive::child_iterator ci = member->second;
+ if (ci->getError())
+ return;
// Do nothing if a member is already instantiated.
- ErrorOr<StringRef> buf = ci->getBuffer();
+ ErrorOr<StringRef> buf = (*ci)->getBuffer();
if (!buf)
return;
const char *memberStart = buf->data();
@@ -167,10 +171,12 @@ protected:
}
private:
- std::error_code
- instantiateMember(Archive::child_iterator member,
- std::unique_ptr<File> &result) const {
- ErrorOr<llvm::MemoryBufferRef> mbOrErr = member->getMemoryBufferRef();
+ std::error_code instantiateMember(Archive::child_iterator cOrErr,
+ std::unique_ptr<File> &result) const {
+ if (std::error_code ec = cOrErr->getError())
+ return ec;
+ Archive::child_iterator member = cOrErr->get();
+ ErrorOr<llvm::MemoryBufferRef> mbOrErr = (*member)->getMemoryBufferRef();
if (std::error_code ec = mbOrErr.getError())
return ec;
llvm::MemoryBufferRef mb = mbOrErr.get();
@@ -201,8 +207,11 @@ private:
// Parses the given memory buffer as an object file, and returns true
// code if the given symbol is a data symbol. If the symbol is not a data
// symbol or does not exist, returns false.
- bool isDataSymbol(Archive::child_iterator member, StringRef symbol) const {
- ErrorOr<llvm::MemoryBufferRef> buf = member->getMemoryBufferRef();
+ bool isDataSymbol(Archive::child_iterator cOrErr, StringRef symbol) const {
+ if (cOrErr->getError())
+ return false;
+ Archive::child_iterator member = cOrErr->get();
+ ErrorOr<llvm::MemoryBufferRef> buf = (*member)->getMemoryBufferRef();
if (buf.getError())
return false;
std::unique_ptr<MemoryBuffer> mb(MemoryBuffer::getMemBuffer(
@@ -242,10 +251,11 @@ private:
if (std::error_code ec = memberOrErr.getError())
return ec;
Archive::child_iterator member = memberOrErr.get();
- DEBUG_WITH_TYPE(
- "FileArchive",
- llvm::dbgs() << llvm::format("0x%08llX ", member->getBuffer()->data())
- << "'" << name << "'\n");
+ DEBUG_WITH_TYPE("FileArchive",
+ llvm::dbgs()
+ << llvm::format("0x%08llX ",
+ (*member)->getBuffer()->data())
+ << "'" << name << "'\n");
_symbolMemberMap.insert(std::make_pair(name, member));
}
return std::error_code();
More information about the llvm-commits
mailing list