diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 |
commit | 01095a5d43bbfde13731688ddcf6048ebb8b7721 (patch) | |
tree | 4def12e759965de927d963ac65840d663ef9d1ea /lib/Object/Object.cpp | |
parent | f0f4822ed4b66e3579e92a89f368f8fb860e218e (diff) |
Notes
Diffstat (limited to 'lib/Object/Object.cpp')
-rw-r--r-- | lib/Object/Object.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
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<MemoryBuffer> Buf(unwrap(MemBuf)); - ErrorOr<std::unique_ptr<ObjectFile>> ObjOrErr( + Expected<std::unique_ptr<ObjectFile>> ObjOrErr( ObjectFile::createObjectFile(Buf->getMemBufferRef())); std::unique_ptr<ObjectFile> Obj; - if (!ObjOrErr) + if (!ObjOrErr) { + // TODO: Actually report errors helpfully. + consumeError(ObjOrErr.takeError()); return nullptr; + } auto *Ret = new OwningBinary<ObjectFile>(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<section_iterator> SecOrErr = (*unwrap(Sym))->getSection(); - if (std::error_code ec = SecOrErr.getError()) - report_fatal_error(ec.message()); + Expected<section_iterator> 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<StringRef> Ret = (*unwrap(SI))->getName(); - if (std::error_code EC = Ret.getError()) - report_fatal_error(EC.message()); + Expected<StringRef> 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<uint64_t> Ret = (*unwrap(SI))->getAddress(); - if (std::error_code EC = Ret.getError()) - report_fatal_error(EC.message()); + Expected<uint64_t> 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; } |