diff options
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r-- | llvm/lib/Object/COFFObjectFile.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Object/Object.cpp | 11 |
3 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 28627cd1d42..878b93fcda0 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -157,7 +157,7 @@ uint64_t COFFObjectFile::getSymbolValueImpl(DataRefImpl Ref) const { return getCOFFSymbol(Ref).getValue(); } -ErrorOr<uint64_t> COFFObjectFile::getSymbolAddress(DataRefImpl Ref) const { +Expected<uint64_t> COFFObjectFile::getSymbolAddress(DataRefImpl Ref) const { uint64_t Result = getSymbolValue(Ref); COFFSymbolRef Symb = getCOFFSymbol(Ref); int32_t SectionNumber = Symb.getSectionNumber(); @@ -168,7 +168,7 @@ ErrorOr<uint64_t> COFFObjectFile::getSymbolAddress(DataRefImpl Ref) const { const coff_section *Section = nullptr; if (std::error_code EC = getSection(SectionNumber, Section)) - return EC; + return errorCodeToError(EC); Result += Section->VirtualAddress; // The section VirtualAddress does not include ImageBase, and we want to diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index d7ec3e57a58..3c88f9fb382 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -473,7 +473,7 @@ uint64_t MachOObjectFile::getSymbolValueImpl(DataRefImpl Sym) const { return getNValue(Sym); } -ErrorOr<uint64_t> MachOObjectFile::getSymbolAddress(DataRefImpl Sym) const { +Expected<uint64_t> MachOObjectFile::getSymbolAddress(DataRefImpl Sym) const { return getSymbolValue(Sym); } diff --git a/llvm/lib/Object/Object.cpp b/llvm/lib/Object/Object.cpp index 6777b322da3..6df481b060e 100644 --- a/llvm/lib/Object/Object.cpp +++ b/llvm/lib/Object/Object.cpp @@ -195,9 +195,14 @@ const char *LLVMGetSymbolName(LLVMSymbolIteratorRef SI) { } 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; } |