aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/WasmObjectFile.cpp
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2022-05-27 08:23:37 -0700
committerDerek Schuff <dschuff@chromium.org>2022-05-27 09:26:36 -0700
commita205f2904d0ae4e3c6ce73b6e0a0aff29e46bd96 (patch)
tree2513560d9ada68c6ac736d72c33539cbbbb8177b /llvm/lib/Object/WasmObjectFile.cpp
parent042ae89556572d045619dbc7ede1be20c644fa6d (diff)
downloadllvm-a205f2904d0ae4e3c6ce73b6e0a0aff29e46bd96.zip
llvm-a205f2904d0ae4e3c6ce73b6e0a0aff29e46bd96.tar.gz
llvm-a205f2904d0ae4e3c6ce73b6e0a0aff29e46bd96.tar.bz2
[WebAssembly] Consolidate sectionTypeToString in BinaryFormat [NFC]
Currently there are 2 duplicate implementation, and I want to add a use in a 3rd place. Combine them in lib/BinaryFormat so they can be shared. Also update toString for symbol and reloc types to use StringRef Differential Revision: https://reviews.llvm.org/D126553
Diffstat (limited to 'llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r--llvm/lib/Object/WasmObjectFile.cpp24
1 files changed, 3 insertions, 21 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index dfb9e2b..73c2f86 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -1727,29 +1727,11 @@ void WasmObjectFile::moveSectionNext(DataRefImpl &Sec) const { Sec.d.a++; }
Expected<StringRef> WasmObjectFile::getSectionName(DataRefImpl Sec) const {
const WasmSection &S = Sections[Sec.d.a];
-#define ECase(X) \
- case wasm::WASM_SEC_##X: \
- return #X;
- switch (S.Type) {
- ECase(TYPE);
- ECase(IMPORT);
- ECase(FUNCTION);
- ECase(TABLE);
- ECase(MEMORY);
- ECase(GLOBAL);
- ECase(TAG);
- ECase(EXPORT);
- ECase(START);
- ECase(ELEM);
- ECase(CODE);
- ECase(DATA);
- ECase(DATACOUNT);
- case wasm::WASM_SEC_CUSTOM:
+ if (S.Type == wasm::WASM_SEC_CUSTOM)
return S.Name;
- default:
+ if (S.Type > wasm::WASM_SEC_TAG)
return createStringError(object_error::invalid_section_index, "");
- }
-#undef ECase
+ return wasm::sectionTypeToString(S.Type);
}
uint64_t WasmObjectFile::getSectionAddress(DataRefImpl Sec) const { return 0; }