[lld] r275362 - [lld] Update LLD for Archive::child_iterator change in LLVM r275361.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 19:35:18 PDT 2016
Author: lhames
Date: Wed Jul 13 21:35:18 2016
New Revision: 275362
URL: http://llvm.org/viewvc/llvm-project?rev=275362&view=rev
Log:
[lld] Update LLD for Archive::child_iterator change in LLVM r275361.
Modified:
lld/trunk/COFF/InputFiles.cpp
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Error.cpp
lld/trunk/ELF/Error.h
lld/trunk/include/lld/Core/LLVM.h
lld/trunk/lib/ReaderWriter/FileArchive.cpp
Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=275362&r1=275361&r2=275362&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Wed Jul 13 21:35:18 2016
@@ -79,11 +79,10 @@ 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 (auto &ChildOrErr : File->children()) {
- error(ChildOrErr, "Failed to parse static library");
- const Archive::Child &Child = *ChildOrErr;
+ Error Err;
+ for (auto &Child : File->children(Err))
Seen[Child.getChildOffset()].clear();
- }
+ error(std::move(Err), "Failed to parse static library");
}
// Returns a buffer pointing to a member file containing a given symbol.
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=275362&r1=275361&r2=275362&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Jul 13 21:35:18 2016
@@ -90,7 +90,8 @@ LinkerDriver::getArchiveMembers(MemoryBu
check(Archive::create(MB), "failed to parse archive");
std::vector<MemoryBufferRef> V;
- for (const ErrorOr<Archive::Child> &COrErr : File->children()) {
+ Error Err;
+ for (const ErrorOr<Archive::Child> &COrErr : File->children(Err)) {
Archive::Child C = check(COrErr, "could not get the child of the archive " +
File->getFileName());
MemoryBufferRef MBRef =
@@ -99,6 +100,7 @@ LinkerDriver::getArchiveMembers(MemoryBu
File->getFileName());
V.push_back(MBRef);
}
+ check(std::move(Err));
// Take ownership of memory buffers created for members of thin archives.
for (std::unique_ptr<MemoryBuffer> &MB : File->takeThinBuffers())
Modified: lld/trunk/ELF/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.cpp?rev=275362&r1=275361&r2=275362&view=diff
==============================================================================
--- lld/trunk/ELF/Error.cpp (original)
+++ lld/trunk/ELF/Error.cpp Wed Jul 13 21:35:18 2016
@@ -11,6 +11,7 @@
#include "Config.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -57,5 +58,9 @@ void check(std::error_code EC) {
fatal(EC.message());
}
+void check(Error Err) {
+ check(errorToErrorCode(std::move(Err)));
+}
+
} // namespace elf
} // namespace lld
Modified: lld/trunk/ELF/Error.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.h?rev=275362&r1=275361&r2=275362&view=diff
==============================================================================
--- lld/trunk/ELF/Error.h (original)
+++ lld/trunk/ELF/Error.h Wed Jul 13 21:35:18 2016
@@ -32,6 +32,7 @@ LLVM_ATTRIBUTE_NORETURN void fatal(const
LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg, const Twine &Prefix);
void check(std::error_code EC);
+void check(Error Err);
template <class T> T check(ErrorOr<T> EO) {
if (EO)
@@ -42,7 +43,7 @@ template <class T> T check(ErrorOr<T> EO
template <class T> T check(Expected<T> EO) {
if (EO)
return std::move(*EO);
- check(errorToErrorCode(EO.takeError()));
+ check(EO.takeError());
return T();
}
Modified: lld/trunk/include/lld/Core/LLVM.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LLVM.h?rev=275362&r1=275361&r2=275362&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/LLVM.h (original)
+++ lld/trunk/include/lld/Core/LLVM.h Wed Jul 13 21:35:18 2016
@@ -23,6 +23,7 @@
namespace llvm {
// ADT's.
+ class Error;
class StringRef;
class Twine;
class MemoryBuffer;
@@ -54,6 +55,7 @@ namespace lld {
using llvm::cast_or_null;
// ADT's.
+ using llvm::Error;
using llvm::StringRef;
using llvm::Twine;
using llvm::MemoryBuffer;
Modified: lld/trunk/lib/ReaderWriter/FileArchive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/FileArchive.cpp?rev=275362&r1=275361&r2=275362&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/FileArchive.cpp (original)
+++ lld/trunk/lib/ReaderWriter/FileArchive.cpp Wed Jul 13 21:35:18 2016
@@ -49,12 +49,10 @@ public:
auto member = _symbolMemberMap.find(name);
if (member == _symbolMemberMap.end())
return nullptr;
- Archive::child_iterator ci = member->second;
- if (ci->getError())
- return nullptr;
+ Archive::Child c = member->second;
// Don't return a member already returned
- ErrorOr<StringRef> buf = (*ci)->getBuffer();
+ ErrorOr<StringRef> buf = c.getBuffer();
if (!buf)
return nullptr;
const char *memberStart = buf->data();
@@ -63,7 +61,7 @@ public:
_membersInstantiated.insert(memberStart);
std::unique_ptr<File> result;
- if (instantiateMember(ci, result))
+ if (instantiateMember(c, result))
return nullptr;
File *file = result.get();
@@ -78,13 +76,20 @@ public:
parseAllMembers(std::vector<std::unique_ptr<File>> &result) override {
if (std::error_code ec = parse())
return ec;
- for (auto mf = _archive->child_begin(), me = _archive->child_end();
+ llvm::Error err;
+ for (auto mf = _archive->child_begin(err), me = _archive->child_end();
mf != me; ++mf) {
std::unique_ptr<File> file;
- if (std::error_code ec = instantiateMember(mf, file))
+ if (std::error_code ec = instantiateMember(*mf, file)) {
+ // err is Success (or we wouldn't be in the loop body) but we can't
+ // return without testing or consuming it.
+ consumeError(std::move(err));
return ec;
+ }
result.push_back(std::move(file));
}
+ if (err)
+ return errorToErrorCode(std::move(err));
return std::error_code();
}
@@ -125,12 +130,9 @@ protected:
}
private:
- std::error_code instantiateMember(Archive::child_iterator cOrErr,
+ std::error_code instantiateMember(Archive::Child member,
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();
+ ErrorOr<llvm::MemoryBufferRef> mbOrErr = member.getMemoryBufferRef();
if (std::error_code ec = mbOrErr.getError())
return ec;
llvm::MemoryBufferRef mb = mbOrErr.get();
@@ -164,21 +166,21 @@ private:
<< _archive->getFileName() << "':\n");
for (const Archive::Symbol &sym : _archive->symbols()) {
StringRef name = sym.getName();
- ErrorOr<Archive::child_iterator> memberOrErr = sym.getMember();
+ ErrorOr<Archive::Child> memberOrErr = sym.getMember();
if (std::error_code ec = memberOrErr.getError())
return ec;
- Archive::child_iterator member = memberOrErr.get();
+ Archive::Child member = memberOrErr.get();
DEBUG_WITH_TYPE("FileArchive",
llvm::dbgs()
<< llvm::format("0x%08llX ",
- (*member)->getBuffer()->data())
+ member.getBuffer()->data())
<< "'" << name << "'\n");
_symbolMemberMap.insert(std::make_pair(name, member));
}
return std::error_code();
}
- typedef std::unordered_map<StringRef, Archive::child_iterator> MemberMap;
+ typedef std::unordered_map<StringRef, Archive::Child> MemberMap;
typedef std::set<const char *> InstantiatedSet;
std::shared_ptr<MemoryBuffer> _mb;
More information about the llvm-commits
mailing list