diff options
author | Fangrui Song <maskray@google.com> | 2019-05-02 10:32:03 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-05-02 10:32:03 +0000 |
commit | 8be28cdc5281edbe83886168978303345ca4a78b (patch) | |
tree | 613ac659e7c0e7384806266757e1fbf34bf418c6 /llvm/lib/Object/WasmObjectFile.cpp | |
parent | 71569d0d523465203ba465a89c37d75075a5e2c2 (diff) | |
download | bcm5719-llvm-8be28cdc5281edbe83886168978303345ca4a78b.tar.gz bcm5719-llvm-8be28cdc5281edbe83886168978303345ca4a78b.zip |
[Object] Change getSectionName() to return Expected<StringRef>
Summary:
It currently receives an output parameter and returns
std::error_code. Expected<StringRef> fits for this purpose perfectly.
Differential Revision: https://reviews.llvm.org/D61421
llvm-svn: 359774
Diffstat (limited to 'llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/WasmObjectFile.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
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<StringRef> 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; } |