[llvm] 2d40bd1 - [llvm-objdump] Remove bool MachOOnlyFirst from printPrivateHeaders after D155045. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 26 00:25:59 PDT 2023
Author: Fangrui Song
Date: 2023-07-26T00:25:55-07:00
New Revision: 2d40bd1e49025de687b65812718d30605cfb1c37
URL: https://github.com/llvm/llvm-project/commit/2d40bd1e49025de687b65812718d30605cfb1c37
DIFF: https://github.com/llvm/llvm-project/commit/2d40bd1e49025de687b65812718d30605cfb1c37.diff
LOG: [llvm-objdump] Remove bool MachOOnlyFirst from printPrivateHeaders after D155045. NFC
Mach-O can just use the global variable `FirstPrivateHeader`.
If we ever manage to remove global variables, we can add a Config
variable to Dumper. Either case, the parameter is not needed.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D156291
Added:
Modified:
llvm/tools/llvm-objdump/COFFDump.cpp
llvm/tools/llvm-objdump/ELFDump.cpp
llvm/tools/llvm-objdump/MachODump.cpp
llvm/tools/llvm-objdump/WasmDump.cpp
llvm/tools/llvm-objdump/XCOFFDump.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-objdump/llvm-objdump.h
Removed:
################################################################################
diff --git a/llvm/tools/llvm-objdump/COFFDump.cpp b/llvm/tools/llvm-objdump/COFFDump.cpp
index e1b38471c77fbf..8f685a21505c1b 100644
--- a/llvm/tools/llvm-objdump/COFFDump.cpp
+++ b/llvm/tools/llvm-objdump/COFFDump.cpp
@@ -45,7 +45,7 @@ class COFFDumper : public Dumper {
}
template <class PEHeader> void printPEHeader(const PEHeader &Hdr) const;
- void printPrivateHeaders(bool MachOOnlyFirst) override;
+ void printPrivateHeaders() override;
private:
template <typename T> FormattedNumber formatAddr(T V) const {
@@ -771,7 +771,7 @@ void objdump::printCOFFUnwindInfo(const COFFObjectFile *Obj) {
}
}
-void COFFDumper::printPrivateHeaders(bool MachOOnlyFirst) {
+void COFFDumper::printPrivateHeaders() {
COFFDumper CD(Obj);
const uint16_t Cha = Obj.getCharacteristics();
outs() << "Characteristics 0x" << Twine::utohexstr(Cha) << '\n';
diff --git a/llvm/tools/llvm-objdump/ELFDump.cpp b/llvm/tools/llvm-objdump/ELFDump.cpp
index 5b08a4b128581e..34fe2ddb0e08ae 100644
--- a/llvm/tools/llvm-objdump/ELFDump.cpp
+++ b/llvm/tools/llvm-objdump/ELFDump.cpp
@@ -28,7 +28,7 @@ namespace {
template <typename ELFT> class ELFDumper : public Dumper {
public:
ELFDumper(const ELFObjectFile<ELFT> &O) : Dumper(O), Obj(O) {}
- void printPrivateHeaders(bool MachOOnlyFirst) override;
+ void printPrivateHeaders() override;
void printDynamicRelocations() override;
private:
@@ -426,7 +426,7 @@ template <class ELFT> void ELFDumper<ELFT>::printSymbolVersion() {
}
}
-template <class ELFT> void ELFDumper<ELFT>::printPrivateHeaders(bool) {
+template <class ELFT> void ELFDumper<ELFT>::printPrivateHeaders() {
printProgramHeaders();
printDynamicSection();
printSymbolVersion();
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 11fb1cb41a9fbd..296cd698304d0a 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -197,7 +197,7 @@ class MachODumper : public Dumper {
public:
MachODumper(const object::MachOObjectFile &O) : Dumper(O), Obj(O) {}
- void printPrivateHeaders(bool OnlyFirst) override;
+ void printPrivateHeaders() override;
};
} // namespace
@@ -10554,9 +10554,9 @@ void objdump::printMachOFileHeader(const object::ObjectFile *Obj) {
PrintMachHeader(file, Verbose);
}
-void MachODumper::printPrivateHeaders(bool OnlyFirst) {
+void MachODumper::printPrivateHeaders() {
printMachOFileHeader(&Obj);
- if (!OnlyFirst)
+ if (!FirstPrivateHeader)
printMachOLoadCommands(&Obj);
}
diff --git a/llvm/tools/llvm-objdump/WasmDump.cpp b/llvm/tools/llvm-objdump/WasmDump.cpp
index a1d767d81003f4..56c084750b7d06 100644
--- a/llvm/tools/llvm-objdump/WasmDump.cpp
+++ b/llvm/tools/llvm-objdump/WasmDump.cpp
@@ -25,7 +25,7 @@ class WasmDumper : public objdump::Dumper {
public:
WasmDumper(const WasmObjectFile &O) : Dumper(O), Obj(O) {}
- void printPrivateHeaders(bool MachOOnlyFirst) override;
+ void printPrivateHeaders() override;
};
} // namespace
@@ -34,7 +34,7 @@ objdump::createWasmDumper(const object::WasmObjectFile &Obj) {
return std::make_unique<WasmDumper>(Obj);
}
-void WasmDumper::printPrivateHeaders(bool) {
+void WasmDumper::printPrivateHeaders() {
outs() << "Program Header:\n";
outs() << "Version: 0x";
outs().write_hex(Obj.getHeader().Version);
diff --git a/llvm/tools/llvm-objdump/XCOFFDump.cpp b/llvm/tools/llvm-objdump/XCOFFDump.cpp
index 87b1679a79692c..0f6147924f8a1a 100644
--- a/llvm/tools/llvm-objdump/XCOFFDump.cpp
+++ b/llvm/tools/llvm-objdump/XCOFFDump.cpp
@@ -32,7 +32,7 @@ namespace {
class XCOFFDumper : public objdump::Dumper {
public:
XCOFFDumper(const object::XCOFFObjectFile &O) : Dumper(O) {}
- void printPrivateHeaders(bool MachOOnlyFirst) override;
+ void printPrivateHeaders() override {}
};
} // namespace
@@ -41,8 +41,6 @@ objdump::createXCOFFDumper(const object::XCOFFObjectFile &Obj) {
return std::make_unique<XCOFFDumper>(Obj);
}
-void XCOFFDumper::printPrivateHeaders(bool) {}
-
Error objdump::getXCOFFRelocationValueString(const XCOFFObjectFile &Obj,
const RelocationRef &Rel,
SmallVectorImpl<char> &Result) {
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 64905ccc5dccfc..98de0fa8df278a 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -2720,7 +2720,7 @@ static void printFaultMaps(const ObjectFile *Obj) {
outs() << FMP;
}
-void Dumper::printPrivateHeaders(bool) {
+void Dumper::printPrivateHeaders() {
reportError(O.getFileName(), "Invalid/Unsupported object file format");
}
@@ -2855,7 +2855,7 @@ static void dumpObject(ObjectFile *O, const Archive *A = nullptr,
if (FileHeaders)
printFileHeaders(O);
if (PrivateHeaders || FirstPrivateHeader)
- D.printPrivateHeaders(FirstPrivateHeader);
+ D.printPrivateHeaders();
if (SectionHeaders)
printSectionHeaders(*O);
if (SymbolTable)
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.h b/llvm/tools/llvm-objdump/llvm-objdump.h
index b3136f0374d2fd..e55f4f669b9300 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.h
+++ b/llvm/tools/llvm-objdump/llvm-objdump.h
@@ -83,7 +83,7 @@ class Dumper {
void reportUniqueWarning(Error Err);
void reportUniqueWarning(const Twine &Msg);
- virtual void printPrivateHeaders(bool MachOOnlyFirst);
+ virtual void printPrivateHeaders();
virtual void printDynamicRelocations() {}
void printSymbolTable(StringRef ArchiveName,
StringRef ArchitectureName = StringRef(),
More information about the llvm-commits
mailing list