[lld] r277657 - Needed change to lld for the changes to libObject/Archive interfaces now returning Expected<>
Kevin Enderby via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 3 14:58:48 PDT 2016
Author: enderby
Date: Wed Aug 3 16:58:48 2016
New Revision: 277657
URL: http://llvm.org/viewvc/llvm-project?rev=277657&view=rev
Log:
Needed change to lld for the changes to libObject/Archive interfaces now returning Expected<>
for the llvm trunk change in r277656
Modified:
lld/trunk/COFF/Error.h
lld/trunk/lib/ReaderWriter/FileArchive.cpp
Modified: lld/trunk/COFF/Error.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Error.h?rev=277657&r1=277656&r2=277657&view=diff
==============================================================================
--- lld/trunk/COFF/Error.h (original)
+++ lld/trunk/COFF/Error.h Wed Aug 3 16:58:48 2016
@@ -38,6 +38,17 @@ template <class T> T check(ErrorOr<T> EO
return std::move(*EO);
}
+template <class T> T check(Expected<T> E) {
+ if (!E) {
+ std::string Buf;
+ llvm::raw_string_ostream OS(Buf);
+ logAllUnhandledErrors(E.takeError(), OS, "");
+ OS.flush();
+ fatal(Buf);
+ }
+ return std::move(*E);
+}
+
} // namespace coff
} // namespace lld
Modified: lld/trunk/lib/ReaderWriter/FileArchive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/FileArchive.cpp?rev=277657&r1=277656&r2=277657&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/FileArchive.cpp (original)
+++ lld/trunk/lib/ReaderWriter/FileArchive.cpp Wed Aug 3 16:58:48 2016
@@ -52,9 +52,12 @@ public:
Archive::Child c = member->second;
// Don't return a member already returned
- ErrorOr<StringRef> buf = c.getBuffer();
- if (!buf)
+ Expected<StringRef> buf = c.getBuffer();
+ if (!buf) {
+ // TODO: Actually report errors helpfully.
+ consumeError(buf.takeError());
return nullptr;
+ }
const char *memberStart = buf->data();
if (_membersInstantiated.count(memberStart))
return nullptr;
@@ -166,9 +169,9 @@ private:
<< _archive->getFileName() << "':\n");
for (const Archive::Symbol &sym : _archive->symbols()) {
StringRef name = sym.getName();
- ErrorOr<Archive::Child> memberOrErr = sym.getMember();
- if (std::error_code ec = memberOrErr.getError())
- return ec;
+ Expected<Archive::Child> memberOrErr = sym.getMember();
+ if (!memberOrErr)
+ return errorToErrorCode(memberOrErr.takeError());
Archive::Child member = memberOrErr.get();
DEBUG_WITH_TYPE("FileArchive",
llvm::dbgs()
More information about the llvm-commits
mailing list