[llvm] r315477 - Convert a few ErrorOr to Expected.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 11 10:23:15 PDT 2017
Author: rafael
Date: Wed Oct 11 10:23:15 2017
New Revision: 315477
URL: http://llvm.org/viewvc/llvm-project?rev=315477&view=rev
Log:
Convert a few ErrorOr to Expected.
Modified:
llvm/trunk/include/llvm/Object/COFF.h
llvm/trunk/tools/llvm-objdump/COFFDump.cpp
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=315477&r1=315476&r2=315477&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Wed Oct 11 10:23:15 2017
@@ -954,28 +954,28 @@ public:
Res = reinterpret_cast<coff_symbol_type *>(getSymbolTable()) + Index;
return std::error_code();
}
- ErrorOr<COFFSymbolRef> getSymbol(uint32_t index) const {
+ Expected<COFFSymbolRef> getSymbol(uint32_t index) const {
if (SymbolTable16) {
const coff_symbol16 *Symb = nullptr;
if (std::error_code EC = getSymbol(index, Symb))
- return EC;
+ return errorCodeToError(EC);
return COFFSymbolRef(Symb);
}
if (SymbolTable32) {
const coff_symbol32 *Symb = nullptr;
if (std::error_code EC = getSymbol(index, Symb))
- return EC;
+ return errorCodeToError(EC);
return COFFSymbolRef(Symb);
}
- return object_error::parse_failed;
+ return errorCodeToError(object_error::parse_failed);
}
template <typename T>
std::error_code getAuxSymbol(uint32_t index, const T *&Res) const {
- ErrorOr<COFFSymbolRef> s = getSymbol(index);
- if (std::error_code EC = s.getError())
- return EC;
- Res = reinterpret_cast<const T *>(s->getRawPtr());
+ Expected<COFFSymbolRef> S = getSymbol(index);
+ if (Error E = S.takeError())
+ return errorToErrorCode(std::move(E));
+ Res = reinterpret_cast<const T *>(S->getRawPtr());
return std::error_code();
}
Modified: llvm/trunk/tools/llvm-objdump/COFFDump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/COFFDump.cpp?rev=315477&r1=315476&r2=315477&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/COFFDump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/COFFDump.cpp Wed Oct 11 10:23:15 2017
@@ -641,9 +641,9 @@ void llvm::printCOFFSymbolTable(const ob
void llvm::printCOFFSymbolTable(const COFFObjectFile *coff) {
for (unsigned SI = 0, SE = coff->getNumberOfSymbols(); SI != SE; ++SI) {
- ErrorOr<COFFSymbolRef> Symbol = coff->getSymbol(SI);
+ Expected<COFFSymbolRef> Symbol = coff->getSymbol(SI);
StringRef Name;
- error(Symbol.getError());
+ error(errorToErrorCode(Symbol.takeError()));
error(coff->getSymbolName(*Symbol, Name));
outs() << "[" << format("%2d", SI) << "]"
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=315477&r1=315476&r2=315477&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Wed Oct 11 10:23:15 2017
@@ -1423,9 +1423,9 @@ void COFFDumper::printSymbol(const Symbo
const coff_aux_weak_external *Aux;
error(getSymbolAuxData(Obj, Symbol, I, Aux));
- ErrorOr<COFFSymbolRef> Linked = Obj->getSymbol(Aux->TagIndex);
+ Expected<COFFSymbolRef> Linked = Obj->getSymbol(Aux->TagIndex);
StringRef LinkedName;
- std::error_code EC = Linked.getError();
+ std::error_code EC = errorToErrorCode(Linked.takeError());
if (EC || (EC = Obj->getSymbolName(*Linked, LinkedName))) {
LinkedName = "";
error(EC);
@@ -1481,10 +1481,10 @@ void COFFDumper::printSymbol(const Symbo
const coff_aux_clr_token *Aux;
error(getSymbolAuxData(Obj, Symbol, I, Aux));
- ErrorOr<COFFSymbolRef> ReferredSym =
+ Expected<COFFSymbolRef> ReferredSym =
Obj->getSymbol(Aux->SymbolTableIndex);
StringRef ReferredName;
- std::error_code EC = ReferredSym.getError();
+ std::error_code EC = errorToErrorCode(ReferredSym.takeError());
if (EC || (EC = Obj->getSymbolName(*ReferredSym, ReferredName))) {
ReferredName = "";
error(EC);
More information about the llvm-commits
mailing list