From: Kevin Enderby Date: Mon, 2 Nov 2015 23:42:05 +0000 (+0000) Subject: Allow llvm-nm’s single letter command line flags to be grouped. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=06e175204105f46c23ea7ef5ce9743846524929f;p=oota-llvm.git Allow llvm-nm’s single letter command line flags to be grouped. Which is needed if we want to replace darwin’s nm(1) with llvm-nm as there are many uses of grouped flags. The added test case is one specific case that is in real use. rdar://23337419 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251864 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/tools/llvm-nm/X86/groupingflags.test b/test/tools/llvm-nm/X86/groupingflags.test new file mode 100644 index 00000000000..a1a258506e9 --- /dev/null +++ b/test/tools/llvm-nm/X86/groupingflags.test @@ -0,0 +1,5 @@ +# RUN: llvm-nm -gjp %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s + +# CHECK: _main +# CHECK: _main.eh +# CHECK: _printf diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index 9d0cc575843..5cf6b4fb2ce 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -65,27 +65,30 @@ cl::list InputFilenames(cl::Positional, cl::desc(""), cl::opt UndefinedOnly("undefined-only", cl::desc("Show only undefined symbols")); cl::alias UndefinedOnly2("u", cl::desc("Alias for --undefined-only"), - cl::aliasopt(UndefinedOnly)); + cl::aliasopt(UndefinedOnly), cl::Grouping); cl::opt DynamicSyms("dynamic", cl::desc("Display the dynamic symbols instead " "of normal symbols.")); cl::alias DynamicSyms2("D", cl::desc("Alias for --dynamic"), - cl::aliasopt(DynamicSyms)); + cl::aliasopt(DynamicSyms), cl::Grouping); cl::opt DefinedOnly("defined-only", cl::desc("Show only defined symbols")); cl::alias DefinedOnly2("U", cl::desc("Alias for --defined-only"), - cl::aliasopt(DefinedOnly)); + cl::aliasopt(DefinedOnly), cl::Grouping); cl::opt ExternalOnly("extern-only", cl::desc("Show only external symbols")); cl::alias ExternalOnly2("g", cl::desc("Alias for --extern-only"), - cl::aliasopt(ExternalOnly)); + cl::aliasopt(ExternalOnly), cl::Grouping); -cl::opt BSDFormat("B", cl::desc("Alias for --format=bsd")); -cl::opt POSIXFormat("P", cl::desc("Alias for --format=posix")); -cl::opt DarwinFormat("m", cl::desc("Alias for --format=darwin")); +cl::opt BSDFormat("B", cl::desc("Alias for --format=bsd"), + cl::Grouping); +cl::opt POSIXFormat("P", cl::desc("Alias for --format=posix"), + cl::Grouping); +cl::opt DarwinFormat("m", cl::desc("Alias for --format=darwin"), + cl::Grouping); static cl::list ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"), @@ -97,32 +100,33 @@ cl::opt PrintFileName( cl::desc("Precede each symbol with the object file it came from")); cl::alias PrintFileNameA("A", cl::desc("Alias for --print-file-name"), - cl::aliasopt(PrintFileName)); + cl::aliasopt(PrintFileName), cl::Grouping); cl::alias PrintFileNameo("o", cl::desc("Alias for --print-file-name"), - cl::aliasopt(PrintFileName)); + cl::aliasopt(PrintFileName), cl::Grouping); cl::opt DebugSyms("debug-syms", cl::desc("Show all symbols, even debugger only")); cl::alias DebugSymsa("a", cl::desc("Alias for --debug-syms"), - cl::aliasopt(DebugSyms)); + cl::aliasopt(DebugSyms), cl::Grouping); cl::opt NumericSort("numeric-sort", cl::desc("Sort symbols by address")); cl::alias NumericSortn("n", cl::desc("Alias for --numeric-sort"), - cl::aliasopt(NumericSort)); + cl::aliasopt(NumericSort), cl::Grouping); cl::alias NumericSortv("v", cl::desc("Alias for --numeric-sort"), - cl::aliasopt(NumericSort)); + cl::aliasopt(NumericSort), cl::Grouping); cl::opt NoSort("no-sort", cl::desc("Show symbols in order encountered")); -cl::alias NoSortp("p", cl::desc("Alias for --no-sort"), cl::aliasopt(NoSort)); +cl::alias NoSortp("p", cl::desc("Alias for --no-sort"), cl::aliasopt(NoSort), + cl::Grouping); cl::opt ReverseSort("reverse-sort", cl::desc("Sort in reverse order")); cl::alias ReverseSortr("r", cl::desc("Alias for --reverse-sort"), - cl::aliasopt(ReverseSort)); + cl::aliasopt(ReverseSort), cl::Grouping); cl::opt PrintSize("print-size", cl::desc("Show symbol size instead of address")); cl::alias PrintSizeS("S", cl::desc("Alias for --print-size"), - cl::aliasopt(PrintSize)); + cl::aliasopt(PrintSize), cl::Grouping); cl::opt SizeSort("size-sort", cl::desc("Sort symbols by size")); @@ -131,12 +135,12 @@ cl::opt WithoutAliases("without-aliases", cl::Hidden, cl::opt ArchiveMap("print-armap", cl::desc("Print the archive map")); cl::alias ArchiveMaps("M", cl::desc("Alias for --print-armap"), - cl::aliasopt(ArchiveMap)); + cl::aliasopt(ArchiveMap), cl::Grouping); cl::opt JustSymbolName("just-symbol-name", cl::desc("Print just the symbol's name")); cl::alias JustSymbolNames("j", cl::desc("Alias for --just-symbol-name"), - cl::aliasopt(JustSymbolName)); + cl::aliasopt(JustSymbolName), cl::Grouping); // FIXME: This option takes exactly two strings and should be allowed anywhere // on the command line. Such that "llvm-nm -s __TEXT __text foo.o" would work. @@ -148,7 +152,7 @@ cl::list SegSect("s", cl::Positional, cl::ZeroOrMore, "and section name, Mach-O only")); cl::opt FormatMachOasHex("x", cl::desc("Print symbol entry in hex, " - "Mach-O only")); + "Mach-O only"), cl::Grouping); cl::opt NoLLVMBitcode("no-llvm-bc", cl::desc("Disable LLVM bitcode reader"));