From 01095a5d43bbfde13731688ddcf6048ebb8b7721 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 23 Jul 2016 20:41:05 +0000 Subject: Vendor import of llvm release_39 branch r276489: https://llvm.org/svn/llvm-project/llvm/branches/release_39@276489 --- lib/Object/Object.cpp | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'lib/Object/Object.cpp') diff --git a/lib/Object/Object.cpp b/lib/Object/Object.cpp index b44c1a16fd08..6df481b060e1 100644 --- a/lib/Object/Object.cpp +++ b/lib/Object/Object.cpp @@ -61,11 +61,14 @@ wrap(const relocation_iterator *SI) { // ObjectFile creation LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf) { std::unique_ptr Buf(unwrap(MemBuf)); - ErrorOr> ObjOrErr( + Expected> ObjOrErr( ObjectFile::createObjectFile(Buf->getMemBufferRef())); std::unique_ptr Obj; - if (!ObjOrErr) + if (!ObjOrErr) { + // TODO: Actually report errors helpfully. + consumeError(ObjOrErr.takeError()); return nullptr; + } auto *Ret = new OwningBinary(std::move(ObjOrErr.get()), std::move(Buf)); return wrap(Ret); @@ -98,9 +101,14 @@ void LLVMMoveToNextSection(LLVMSectionIteratorRef SI) { void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect, LLVMSymbolIteratorRef Sym) { - ErrorOr SecOrErr = (*unwrap(Sym))->getSection(); - if (std::error_code ec = SecOrErr.getError()) - report_fatal_error(ec.message()); + Expected SecOrErr = (*unwrap(Sym))->getSection(); + if (!SecOrErr) { + std::string Buf; + raw_string_ostream OS(Buf); + logAllUnhandledErrors(SecOrErr.takeError(), OS, ""); + OS.flush(); + report_fatal_error(Buf); + } *unwrap(Sect) = *SecOrErr; } @@ -175,16 +183,26 @@ void LLVMMoveToNextRelocation(LLVMRelocationIteratorRef SI) { // SymbolRef accessors const char *LLVMGetSymbolName(LLVMSymbolIteratorRef SI) { - ErrorOr Ret = (*unwrap(SI))->getName(); - if (std::error_code EC = Ret.getError()) - report_fatal_error(EC.message()); + Expected Ret = (*unwrap(SI))->getName(); + if (!Ret) { + std::string Buf; + raw_string_ostream OS(Buf); + logAllUnhandledErrors(Ret.takeError(), OS, ""); + OS.flush(); + report_fatal_error(Buf); + } return Ret->data(); } uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI) { - ErrorOr Ret = (*unwrap(SI))->getAddress(); - if (std::error_code EC = Ret.getError()) - report_fatal_error(EC.message()); + Expected Ret = (*unwrap(SI))->getAddress(); + if (!Ret) { + std::string Buf; + raw_string_ostream OS(Buf); + logAllUnhandledErrors(Ret.takeError(), OS, ""); + OS.flush(); + report_fatal_error(Buf); + } return *Ret; } -- cgit v1.2.3