<div dir="ltr">Any test coverage for the new diagnostics this supports? (does it support new diagnostics, or was the lower layer handling the diagnostics previously & now it's just moved around but not changed behavior?)</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 13, 2016 at 7:42 PM Lang Hames via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: lhames<br>
Date: Wed Jul 13 21:35:18 2016<br>
New Revision: 275362<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=275362&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=275362&view=rev</a><br>
Log:<br>
[lld] Update LLD for Archive::child_iterator change in LLVM r275361.<br>
<br>
Modified:<br>
lld/trunk/COFF/InputFiles.cpp<br>
lld/trunk/ELF/Driver.cpp<br>
lld/trunk/ELF/Error.cpp<br>
lld/trunk/ELF/Error.h<br>
lld/trunk/include/lld/Core/LLVM.h<br>
lld/trunk/lib/ReaderWriter/FileArchive.cpp<br>
<br>
Modified: lld/trunk/COFF/InputFiles.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=275362&r1=275361&r2=275362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=275362&r1=275361&r2=275362&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/COFF/InputFiles.cpp (original)<br>
+++ lld/trunk/COFF/InputFiles.cpp Wed Jul 13 21:35:18 2016<br>
@@ -79,11 +79,10 @@ void ArchiveFile::parse() {<br>
// Seen is a map from member files to boolean values. Initially<br>
// all members are mapped to false, which indicates all these files<br>
// are not read yet.<br>
- for (auto &ChildOrErr : File->children()) {<br>
- error(ChildOrErr, "Failed to parse static library");<br>
- const Archive::Child &Child = *ChildOrErr;<br>
+ Error Err;<br>
+ for (auto &Child : File->children(Err))<br>
Seen[Child.getChildOffset()].clear();<br>
- }<br>
+ error(std::move(Err), "Failed to parse static library");<br>
}<br>
<br>
// Returns a buffer pointing to a member file containing a given symbol.<br>
<br>
Modified: lld/trunk/ELF/Driver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=275362&r1=275361&r2=275362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=275362&r1=275361&r2=275362&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Driver.cpp (original)<br>
+++ lld/trunk/ELF/Driver.cpp Wed Jul 13 21:35:18 2016<br>
@@ -90,7 +90,8 @@ LinkerDriver::getArchiveMembers(MemoryBu<br>
check(Archive::create(MB), "failed to parse archive");<br>
<br>
std::vector<MemoryBufferRef> V;<br>
- for (const ErrorOr<Archive::Child> &COrErr : File->children()) {<br>
+ Error Err;<br>
+ for (const ErrorOr<Archive::Child> &COrErr : File->children(Err)) {<br>
Archive::Child C = check(COrErr, "could not get the child of the archive " +<br>
File->getFileName());<br>
MemoryBufferRef MBRef =<br>
@@ -99,6 +100,7 @@ LinkerDriver::getArchiveMembers(MemoryBu<br>
File->getFileName());<br>
V.push_back(MBRef);<br>
}<br>
+ check(std::move(Err));<br>
<br>
// Take ownership of memory buffers created for members of thin archives.<br>
for (std::unique_ptr<MemoryBuffer> &MB : File->takeThinBuffers())<br>
<br>
Modified: lld/trunk/ELF/Error.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.cpp?rev=275362&r1=275361&r2=275362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.cpp?rev=275362&r1=275361&r2=275362&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Error.cpp (original)<br>
+++ lld/trunk/ELF/Error.cpp Wed Jul 13 21:35:18 2016<br>
@@ -11,6 +11,7 @@<br>
#include "Config.h"<br>
<br>
#include "llvm/ADT/Twine.h"<br>
+#include "llvm/Support/Error.h"<br>
#include "llvm/Support/raw_ostream.h"<br>
<br>
using namespace llvm;<br>
@@ -57,5 +58,9 @@ void check(std::error_code EC) {<br>
fatal(EC.message());<br>
}<br>
<br>
+void check(Error Err) {<br>
+ check(errorToErrorCode(std::move(Err)));<br>
+}<br>
+<br>
} // namespace elf<br>
} // namespace lld<br>
<br>
Modified: lld/trunk/ELF/Error.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.h?rev=275362&r1=275361&r2=275362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.h?rev=275362&r1=275361&r2=275362&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Error.h (original)<br>
+++ lld/trunk/ELF/Error.h Wed Jul 13 21:35:18 2016<br>
@@ -32,6 +32,7 @@ LLVM_ATTRIBUTE_NORETURN void fatal(const<br>
LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg, const Twine &Prefix);<br>
<br>
void check(std::error_code EC);<br>
+void check(Error Err);<br>
<br>
template <class T> T check(ErrorOr<T> EO) {<br>
if (EO)<br>
@@ -42,7 +43,7 @@ template <class T> T check(ErrorOr<T> EO<br>
template <class T> T check(Expected<T> EO) {<br>
if (EO)<br>
return std::move(*EO);<br>
- check(errorToErrorCode(EO.takeError()));<br>
+ check(EO.takeError());<br>
return T();<br>
}<br>
<br>
<br>
Modified: lld/trunk/include/lld/Core/LLVM.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LLVM.h?rev=275362&r1=275361&r2=275362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LLVM.h?rev=275362&r1=275361&r2=275362&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/include/lld/Core/LLVM.h (original)<br>
+++ lld/trunk/include/lld/Core/LLVM.h Wed Jul 13 21:35:18 2016<br>
@@ -23,6 +23,7 @@<br>
<br>
namespace llvm {<br>
// ADT's.<br>
+ class Error;<br>
class StringRef;<br>
class Twine;<br>
class MemoryBuffer;<br>
@@ -54,6 +55,7 @@ namespace lld {<br>
using llvm::cast_or_null;<br>
<br>
// ADT's.<br>
+ using llvm::Error;<br>
using llvm::StringRef;<br>
using llvm::Twine;<br>
using llvm::MemoryBuffer;<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/FileArchive.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/FileArchive.cpp?rev=275362&r1=275361&r2=275362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/FileArchive.cpp?rev=275362&r1=275361&r2=275362&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/FileArchive.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/FileArchive.cpp Wed Jul 13 21:35:18 2016<br>
@@ -49,12 +49,10 @@ public:<br>
auto member = _symbolMemberMap.find(name);<br>
if (member == _symbolMemberMap.end())<br>
return nullptr;<br>
- Archive::child_iterator ci = member->second;<br>
- if (ci->getError())<br>
- return nullptr;<br>
+ Archive::Child c = member->second;<br>
<br>
// Don't return a member already returned<br>
- ErrorOr<StringRef> buf = (*ci)->getBuffer();<br>
+ ErrorOr<StringRef> buf = c.getBuffer();<br>
if (!buf)<br>
return nullptr;<br>
const char *memberStart = buf->data();<br>
@@ -63,7 +61,7 @@ public:<br>
_membersInstantiated.insert(memberStart);<br>
<br>
std::unique_ptr<File> result;<br>
- if (instantiateMember(ci, result))<br>
+ if (instantiateMember(c, result))<br>
return nullptr;<br>
<br>
File *file = result.get();<br>
@@ -78,13 +76,20 @@ public:<br>
parseAllMembers(std::vector<std::unique_ptr<File>> &result) override {<br>
if (std::error_code ec = parse())<br>
return ec;<br>
- for (auto mf = _archive->child_begin(), me = _archive->child_end();<br>
+ llvm::Error err;<br>
+ for (auto mf = _archive->child_begin(err), me = _archive->child_end();<br>
mf != me; ++mf) {<br>
std::unique_ptr<File> file;<br>
- if (std::error_code ec = instantiateMember(mf, file))<br>
+ if (std::error_code ec = instantiateMember(*mf, file)) {<br>
+ // err is Success (or we wouldn't be in the loop body) but we can't<br>
+ // return without testing or consuming it.<br>
+ consumeError(std::move(err));<br>
return ec;<br>
+ }<br>
result.push_back(std::move(file));<br>
}<br>
+ if (err)<br>
+ return errorToErrorCode(std::move(err));<br>
return std::error_code();<br>
}<br>
<br>
@@ -125,12 +130,9 @@ protected:<br>
}<br>
<br>
private:<br>
- std::error_code instantiateMember(Archive::child_iterator cOrErr,<br>
+ std::error_code instantiateMember(Archive::Child member,<br>
std::unique_ptr<File> &result) const {<br>
- if (std::error_code ec = cOrErr->getError())<br>
- return ec;<br>
- Archive::child_iterator member = cOrErr->get();<br>
- ErrorOr<llvm::MemoryBufferRef> mbOrErr = (*member)->getMemoryBufferRef();<br>
+ ErrorOr<llvm::MemoryBufferRef> mbOrErr = member.getMemoryBufferRef();<br>
if (std::error_code ec = mbOrErr.getError())<br>
return ec;<br>
llvm::MemoryBufferRef mb = mbOrErr.get();<br>
@@ -164,21 +166,21 @@ private:<br>
<< _archive->getFileName() << "':\n");<br>
for (const Archive::Symbol &sym : _archive->symbols()) {<br>
StringRef name = sym.getName();<br>
- ErrorOr<Archive::child_iterator> memberOrErr = sym.getMember();<br>
+ ErrorOr<Archive::Child> memberOrErr = sym.getMember();<br>
if (std::error_code ec = memberOrErr.getError())<br>
return ec;<br>
- Archive::child_iterator member = memberOrErr.get();<br>
+ Archive::Child member = memberOrErr.get();<br>
DEBUG_WITH_TYPE("FileArchive",<br>
llvm::dbgs()<br>
<< llvm::format("0x%08llX ",<br>
- (*member)->getBuffer()->data())<br>
+ member.getBuffer()->data())<br>
<< "'" << name << "'\n");<br>
_symbolMemberMap.insert(std::make_pair(name, member));<br>
}<br>
return std::error_code();<br>
}<br>
<br>
- typedef std::unordered_map<StringRef, Archive::child_iterator> MemberMap;<br>
+ typedef std::unordered_map<StringRef, Archive::Child> MemberMap;<br>
typedef std::set<const char *> InstantiatedSet;<br>
<br>
std::shared_ptr<MemoryBuffer> _mb;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>