Convert a few ErrorOr to Expected.

llvm-svn: 315477
This commit is contained in:
Rafael Espindola 2017-10-11 17:23:15 +00:00
parent 9590658fb8
commit 748949257a
3 changed files with 14 additions and 14 deletions

View File

@ -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();
}

View File

@ -641,9 +641,9 @@ void llvm::printCOFFSymbolTable(const object::COFFImportFile *i) {
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) << "]"

View File

@ -1423,9 +1423,9 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
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 SymbolRef &Sym) {
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);