[llvm] r281844 - [llvm-objump] Simplify the code. NFCI.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 17 21:39:16 PDT 2016
Author: davide
Date: Sat Sep 17 23:39:15 2016
New Revision: 281844
URL: http://llvm.org/viewvc/llvm-project?rev=281844&view=rev
Log:
[llvm-objump] Simplify the code. NFCI.
Modified:
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=281844&r1=281843&r2=281844&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Sat Sep 17 23:39:15 2016
@@ -1877,27 +1877,18 @@ static void printFaultMaps(const ObjectF
outs() << FMP;
}
-static void printPrivateFileHeaders(const ObjectFile *o) {
+static void printPrivateFileHeaders(const ObjectFile *o, bool onlyFirst) {
if (o->isELF())
- printELFFileHeader(o);
- else if (o->isCOFF())
- printCOFFFileHeader(o);
- else if (o->isMachO()) {
+ return printELFFileHeader(o);
+ if (o->isCOFF())
+ return printCOFFFileHeader(o);
+ if (o->isMachO()) {
printMachOFileHeader(o);
- printMachOLoadCommands(o);
- } else
- report_fatal_error("Invalid/Unsupported object file format");
-}
-
-static void printFirstPrivateFileHeader(const ObjectFile *o) {
- if (o->isELF())
- printELFFileHeader(o);
- else if (o->isCOFF())
- printCOFFFileHeader(o);
- else if (o->isMachO())
- printMachOFileHeader(o);
- else
- report_fatal_error("Invalid/Unsupported object file format");
+ if (!onlyFirst)
+ printMachOLoadCommands(o);
+ return;
+ }
+ report_fatal_error("Invalid/Unsupported object file format");
}
static void DumpObject(const ObjectFile *o, const Archive *a = nullptr) {
@@ -1924,10 +1915,8 @@ static void DumpObject(const ObjectFile
PrintSymbolTable(o, ArchiveName);
if (UnwindInfo)
PrintUnwindInfo(o);
- if (PrivateHeaders)
- printPrivateFileHeaders(o);
- if (FirstPrivateHeader)
- printFirstPrivateFileHeader(o);
+ if (PrivateHeaders || FirstPrivateHeader)
+ printPrivateFileHeaders(o, FirstPrivateHeader);
if (ExportsTrie)
printExportsTrie(o);
if (Rebase)
More information about the llvm-commits
mailing list