[llvm] 5ea2819 - [llvm-objdump][Wasm][NFC] Create WasmDump.h
Hubert Tong via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 15:26:31 PDT 2020
Author: Hubert Tong
Date: 2020-04-14T18:26:24-04:00
New Revision: 5ea28196f19df0e051cf834289d85423a49a84c1
URL: https://github.com/llvm/llvm-project/commit/5ea28196f19df0e051cf834289d85423a49a84c1
DIFF: https://github.com/llvm/llvm-project/commit/5ea28196f19df0e051cf834289d85423a49a84c1.diff
LOG: [llvm-objdump][Wasm][NFC] Create WasmDump.h
Summary:
Continuing from D77285, the external interfaces implemented by
`WasmDump.cpp` are now declared in `WasmDump.h` and moved into the
`llvm::objdump` namespace.
Reviewers: jhenderson, MaskRay, DiggerLin, jasonliu, daltenty
Reviewed By: jhenderson, MaskRay
Differential Revision: https://reviews.llvm.org/D77990
Added:
llvm/tools/llvm-objdump/WasmDump.h
Modified:
llvm/tools/llvm-objdump/WasmDump.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-objdump/llvm-objdump.h
Removed:
################################################################################
diff --git a/llvm/tools/llvm-objdump/WasmDump.cpp b/llvm/tools/llvm-objdump/WasmDump.cpp
index da27a4acbb5f..28311361d97e 100644
--- a/llvm/tools/llvm-objdump/WasmDump.cpp
+++ b/llvm/tools/llvm-objdump/WasmDump.cpp
@@ -11,13 +11,15 @@
///
//===----------------------------------------------------------------------===//
+#include "WasmDump.h"
+
#include "llvm-objdump.h"
#include "llvm/Object/Wasm.h"
+using namespace llvm;
using namespace llvm::object;
-namespace llvm {
-void printWasmFileHeader(const object::ObjectFile *Obj) {
+void objdump::printWasmFileHeader(const object::ObjectFile *Obj) {
const auto *File = dyn_cast<const WasmObjectFile>(Obj);
outs() << "Program Header:\n";
@@ -26,9 +28,9 @@ void printWasmFileHeader(const object::ObjectFile *Obj) {
outs() << "\n";
}
-Error getWasmRelocationValueString(const WasmObjectFile *Obj,
- const RelocationRef &RelRef,
- SmallVectorImpl<char> &Result) {
+Error objdump::getWasmRelocationValueString(const WasmObjectFile *Obj,
+ const RelocationRef &RelRef,
+ SmallVectorImpl<char> &Result) {
const wasm::WasmRelocation &Rel = Obj->getWasmRelocation(RelRef);
symbol_iterator SI = RelRef.getSymbol();
std::string FmtBuf;
@@ -49,4 +51,3 @@ Error getWasmRelocationValueString(const WasmObjectFile *Obj,
Result.append(FmtBuf.begin(), FmtBuf.end());
return Error::success();
}
-} // namespace llvm
diff --git a/llvm/tools/llvm-objdump/WasmDump.h b/llvm/tools/llvm-objdump/WasmDump.h
new file mode 100644
index 000000000000..03ff9aed8e07
--- /dev/null
+++ b/llvm/tools/llvm-objdump/WasmDump.h
@@ -0,0 +1,35 @@
+//===-- WasmDump.h - wasm-specific dumper -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVM_OBJDUMP_WASMDUMP_H
+#define LLVM_TOOLS_LLVM_OBJDUMP_WASMDUMP_H
+
+#include "llvm/ADT/SmallVector.h"
+
+namespace llvm {
+
+class Error;
+
+namespace object {
+class WasmObjectFile;
+class ObjectFile;
+class RelocationRef;
+} // namespace object
+
+namespace objdump {
+
+Error getWasmRelocationValueString(const object::WasmObjectFile *Obj,
+ const object::RelocationRef &RelRef,
+ llvm::SmallVectorImpl<char> &Result);
+
+void printWasmFileHeader(const object::ObjectFile *O);
+
+} // namespace objdump
+} // namespace llvm
+
+#endif
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index dd1fec61c10e..fc4de6be1f90 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -18,6 +18,7 @@
#include "llvm-objdump.h"
#include "COFFDump.h"
#include "MachODump.h"
+#include "WasmDump.h"
#include "XCOFFDump.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.h b/llvm/tools/llvm-objdump/llvm-objdump.h
index 931ef0231022..18fd9032c0d5 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.h
+++ b/llvm/tools/llvm-objdump/llvm-objdump.h
@@ -118,9 +118,6 @@ SectionFilter ToolSectionFilter(llvm::object::ObjectFile const &O,
Error getELFRelocationValueString(const object::ELFObjectFileBase *Obj,
const object::RelocationRef &Rel,
llvm::SmallVectorImpl<char> &Result);
-Error getWasmRelocationValueString(const object::WasmObjectFile *Obj,
- const object::RelocationRef &RelRef,
- llvm::SmallVectorImpl<char> &Result);
uint64_t getELFSectionLMA(const object::ELFSectionRef& Sec);
@@ -128,7 +125,6 @@ bool isRelocAddressLess(object::RelocationRef A, object::RelocationRef B);
void printELFFileHeader(const object::ObjectFile *O);
void printELFDynamicSection(const object::ObjectFile *Obj);
void printELFSymbolVersionInfo(const object::ObjectFile *Obj);
-void printWasmFileHeader(const object::ObjectFile *O);
void printRawClangAST(const object::ObjectFile *O);
void printRelocations(const object::ObjectFile *O);
void printDynamicRelocations(const object::ObjectFile *O);
More information about the llvm-commits
mailing list