diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index 962a3e2a865..5b7e882577a 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -219,7 +219,7 @@ error_code ELFObjectFile::getSymbolName(DataRefImpl Symb, StringRef &Result) const { ErrorOr Name = EF.getSymbolName(toELFSymIter(Symb)); if (!Name) - return Name; + return Name.getError(); Result = *Name; return object_error::success; } @@ -233,7 +233,7 @@ error_code ELFObjectFile::getSymbolVersion(SymbolRef SymRef, ErrorOr Ver = EF.getSymbolVersion(EF.getSection(Symb.d.b), symb, IsDefault); if (!Ver) - return Ver; + return Ver.getError(); Version = *Ver; return object_error::success; } @@ -435,7 +435,7 @@ error_code ELFObjectFile::getSectionName(DataRefImpl Sec, StringRef &Result) const { ErrorOr Name = EF.getSectionName(&*toELFShdrIter(Sec)); if (!Name) - return Name; + return Name.getError(); Result = *Name; return object_error::success; } @@ -743,7 +743,7 @@ error_code ELFObjectFile::getRelocationValueString( ErrorOr SymName = EF.getSymbolName(EF.getSection(sec->sh_link), symb); if (!SymName) - return SymName; + return SymName.getError(); switch (EF.getHeader()->e_machine) { case ELF::EM_X86_64: switch (type) { diff --git a/include/llvm/Support/ErrorOr.h b/include/llvm/Support/ErrorOr.h index 21ab4e721dc..fba67054cb9 100644 --- a/include/llvm/Support/ErrorOr.h +++ b/include/llvm/Support/ErrorOr.h @@ -181,10 +181,6 @@ public: T &get() { return *getStorage(); } const T &get() const { return const_cast >(this)->get(); } - operator llvm::error_code() const { - return HasError ? *getErrorStorage() : llvm::error_code::success(); - } - error_code getError() const { return HasError ? *getErrorStorage() : error_code::success(); } @@ -240,7 +236,7 @@ private: } else { // Get other's error. HasError = true; - new (getErrorStorage()) error_code(Other); + new (getErrorStorage()) error_code(Other.getError()); } } diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index b82cecdd4d9..77405714a48 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -66,7 +66,7 @@ private: template T errorOrDefault(ErrorOr Val, T Default = T()) { if (!Val) { - error(Val); + error(Val.getError()); return Default; } @@ -632,7 +632,7 @@ void ELFDumper::printSymbol(typename ELFO::Elf_Sym_Iter Symbol) { FullSymbolName += (IsDefault ? "@@" : "@"); FullSymbolName += *Version; } else - error(Version); + error(Version.getError()); } DictScope D(W, "Symbol"); diff --git a/unittests/Support/ErrorOrTest.cpp b/unittests/Support/ErrorOrTest.cpp index 4c5eed050f9..98174e8cd70 100644 --- a/unittests/Support/ErrorOrTest.cpp +++ b/unittests/Support/ErrorOrTest.cpp @@ -25,7 +25,7 @@ TEST(ErrorOr, SimpleValue) { a = t2(); EXPECT_FALSE(a); - EXPECT_EQ(errc::invalid_argument, a); + EXPECT_EQ(errc::invalid_argument, a.getError()); #ifdef EXPECT_DEBUG_DEATH EXPECT_DEBUG_DEATH(*a, "Cannot get value when an error exists"); #endif