From 8be28cdc5281edbe83886168978303345ca4a78b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 2 May 2019 10:32:03 +0000 Subject: [Object] Change getSectionName() to return Expected Summary: It currently receives an output parameter and returns std::error_code. Expected fits for this purpose perfectly. Differential Revision: https://reviews.llvm.org/D61421 llvm-svn: 359774 --- llvm/lib/Object/WasmObjectFile.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'llvm/lib/Object/WasmObjectFile.cpp') diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index 45e343f8f47..1c56ee6652a 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -1389,13 +1389,11 @@ WasmObjectFile::getSymbolSection(DataRefImpl Symb) const { void WasmObjectFile::moveSectionNext(DataRefImpl &Sec) const { Sec.d.a++; } -std::error_code WasmObjectFile::getSectionName(DataRefImpl Sec, - StringRef &Res) const { +Expected WasmObjectFile::getSectionName(DataRefImpl Sec) const { const WasmSection &S = Sections[Sec.d.a]; #define ECase(X) \ case wasm::WASM_SEC_##X: \ - Res = #X; \ - break + return #X; switch (S.Type) { ECase(TYPE); ECase(IMPORT); @@ -1411,13 +1409,11 @@ std::error_code WasmObjectFile::getSectionName(DataRefImpl Sec, ECase(DATA); ECase(DATACOUNT); case wasm::WASM_SEC_CUSTOM: - Res = S.Name; - break; + return S.Name; default: - return object_error::invalid_section_index; + return createStringError(object_error::invalid_section_index, ""); } #undef ECase - return std::error_code(); } uint64_t WasmObjectFile::getSectionAddress(DataRefImpl Sec) const { return 0; } -- cgit v1.2.3