From 051a699ed62b94e3c480bfc8c858c9dbe7319b0b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 16 Apr 2019 02:37:29 +0000 Subject: [PATCH] [llvm-objdump] Simplify PrintHelpMessage() logic This relands rL358418. It missed one test that should also use -macho Note, all the other -private-header -exports-trie tests are used together with -macho. llvm-svn: 358472 --- llvm/test/Object/objdump-export-list.test | 5 ++- .../X86/macho-private-header.test | 2 +- llvm/tools/llvm-objdump/llvm-objdump.cpp | 37 +++++-------------- 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/llvm/test/Object/objdump-export-list.test b/llvm/test/Object/objdump-export-list.test index 74344c1c2e2e..1728f73d8b40 100644 --- a/llvm/test/Object/objdump-export-list.test +++ b/llvm/test/Object/objdump-export-list.test @@ -1,4 +1,5 @@ -RUN: llvm-objdump -exports-trie %p/Inputs/macho-no-exports.dylib | FileCheck %s +RUN: llvm-objdump -macho -exports-trie %p/Inputs/macho-no-exports.dylib | FileCheck %s ; Test that we don't crash with an empty export list. -CHECK: macho-no-exports.dylib: file format Mach-O 64-bit x86-64 +CHECK: macho-no-exports.dylib +CHECK: Exports trie: diff --git a/llvm/test/tools/llvm-objdump/X86/macho-private-header.test b/llvm/test/tools/llvm-objdump/X86/macho-private-header.test index d90072542a2e..b904bbcf5ec0 100644 --- a/llvm/test/tools/llvm-objdump/X86/macho-private-header.test +++ b/llvm/test/tools/llvm-objdump/X86/macho-private-header.test @@ -1,4 +1,4 @@ -// RUN: llvm-objdump -private-header %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s +// RUN: llvm-objdump -macho -private-header %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s CHECK: Mach header CHECK: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index bc688d6ca943..2606d9b20c21 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -2008,34 +2008,15 @@ int main(int argc, char **argv) { if (DisassembleAll || PrintSource || PrintLines) Disassemble = true; - if (!Disassemble - && !Relocations - && !DynamicRelocations - && !SectionHeaders - && !SectionContents - && !SymbolTable - && !UnwindInfo - && !PrivateHeaders - && !FileHeaders - && !FirstPrivateHeader - && !ExportsTrie - && !Rebase - && !Bind - && !LazyBind - && !WeakBind - && !RawClangAST - && !(UniversalHeaders && MachOOpt) - && !ArchiveHeaders - && !(IndirectSymbols && MachOOpt) - && !(DataInCode && MachOOpt) - && !(LinkOptHints && MachOOpt) - && !(InfoPlist && MachOOpt) - && !(DylibsUsed && MachOOpt) - && !(DylibId && MachOOpt) - && !(ObjcMetaData && MachOOpt) - && !(!FilterSections.empty() && MachOOpt) - && !FaultMapSection - && DwarfDumpType == DIDT_Null) { + if (!ArchiveHeaders && !Disassemble && DwarfDumpType == DIDT_Null && + !DynamicRelocations && !FileHeaders && !PrivateHeaders && !RawClangAST && + !Relocations && !SectionHeaders && !SectionContents && !SymbolTable && + !UnwindInfo && !FaultMapSection && + !(MachOOpt && + (Bind || DataInCode || DylibId || DylibsUsed || ExportsTrie || + FirstPrivateHeader || IndirectSymbols || InfoPlist || LazyBind || + LinkOptHints || ObjcMetaData || Rebase || UniversalHeaders || + WeakBind || !FilterSections.empty()))) { cl::PrintHelpMessage(); return 2; }