-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm-nm] Switch command line parsing from llvm::cl to OptTable
Part of https://lists.llvm.org/pipermail/llvm-dev/2021-July/151622.html "Binary utilities: switch command line parsing from llvm::cl to OptTable" Users should generally observe no difference as long as they only use intended option forms. Behavior changes: * `-t=d` is removed. Use `-t d` instead. * `--demangle=0` cannot be used. Omit the option or use `--no-demangle` instead. * `--help-list` is removed. This is a `cl::` specific option. Note: * `-t` diagnostic gets improved. * This patch avoids cl::opt collision if we decide to support multiplexing for binary utilities * One-dash long options are still supported. * The `-s` collision (`-s segment section` for Mach-O) is unfortunate. `-s` means `--print-armap` in GNU nm. * This patch removes the last `cl::multi_val` use case from the `llvm/lib/Support/CommandLine.cpp` library `-M` (`--print-armap`), `-U` (`--defined-only`), and `-W` (`--no-weak`) are now deprecated. They could conflict with future GNU nm options. (--print-armap has an existing alias -s, so GNU will unlikely add a new one. --no-weak (not in GNU nm) is rarely used anyway.) `--just-symbol-name` is now deprecated in favor of `--format=just-symbols` and `-j`. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D105330
- Loading branch information
Showing
14 changed files
with
311 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
RUN: llvm-nm --help 2>&1 | FileCheck --implicit-check-not="General Options:" %s | ||
CHECK: Generic Options: | ||
CHECK: llvm-nm Options: | ||
RUN: llvm-nm -h 2>&1 | FileCheck --implicit-check-not="General Options:" %s | ||
CHECK: OPTIONS: | ||
CHECK: --debug-syms | ||
CHECK: --demangle | ||
CHECK: --format=<format> | ||
CHECK: llvm-nm Mach-O Specific Options: | ||
CHECK: --arch=<value> | ||
CHECK: -s | ||
CHECK: Pass @FILE {{.*}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
include "llvm/Option/OptParser.td" | ||
|
||
class F<string letter, string help> : Flag<["-"], letter>, HelpText<help>; | ||
class FF<string name, string help> : Flag<["--", "-"], name>, HelpText<help>; | ||
|
||
multiclass BB<string name, string help1, string help2> { | ||
def NAME: Flag<["--", "-"], name>, HelpText<help1>; | ||
def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>; | ||
} | ||
|
||
multiclass Eq<string name, string help> { | ||
def NAME #_EQ : Joined<["--", "-"], name #"=">, | ||
HelpText<help>; | ||
def : Separate<["--", "-"], name>, Alias<!cast<Joined>(NAME #_EQ)>; | ||
} | ||
|
||
def debug_syms : FF<"debug-syms", "Show all symbols, even debugger only">; | ||
def defined_only : FF<"defined-only", "Show only defined symbols">; | ||
defm demangle : BB<"demangle", "Demangle C++ symbol names", "Don't demangle symbol names">; | ||
def dynamic : FF<"dynamic", "Display dynamic symbols instead of normal symbols">; | ||
def extern_only : FF<"extern-only", "Show only external symbols">; | ||
defm format : Eq<"format", "Specify output format: bsd (default), posix, sysv, darwin, just-symbols">, MetaVarName<"<format>">; | ||
def help : FF<"help", "Display this help">; | ||
def no_llvm_bc : FF<"no-llvm-bc", "Disable LLVM bitcode reader">; | ||
def no_sort : FF<"no-sort", "Show symbols in order encountered">; | ||
def no_weak : FF<"no-weak", "Show only non-weak symbols">; | ||
def numeric_sort : FF<"numeric-sort", "Sort symbols by address">; | ||
def print_armap : FF<"print-armap", "Print the archive map">; | ||
def print_file_name : FF<"print-file-name", "Precede each symbol with the object file it came from">; | ||
def print_size : FF<"print-size", "Show symbol size as well as address">; | ||
def quiet : FF<"quiet", "Suppress 'no symbols' diagnostic">; | ||
defm radix : Eq<"radix", "Radix (o/d/x) for printing symbol Values">, MetaVarName<"<radix>">; | ||
def reverse_sort : FF<"reverse-sort", "Sort in reverse order">; | ||
def size_sort : FF<"size-sort", "Sort symbols by size">; | ||
def special_syms : FF<"special-syms", "Do not filter special symbols from the output">; | ||
def undefined_only : FF<"undefined-only", "Show only undefined symbols">; | ||
def version : FF<"version", "Display the version">; | ||
def without_aliases : FF<"without-aliases", "Exclude aliases from output">, Flags<[HelpHidden]>; | ||
|
||
// Mach-O specific options. | ||
def grp_mach_o : OptionGroup<"kind">, HelpText<"llvm-nm Mach-O Specific Options">; | ||
|
||
def add_dyldinfo : FF<"add-dyldinfo", "Add symbols from the dyldinfo not already in the symbol table">, Group<grp_mach_o>; | ||
def add_inlinedinfo : FF<"add-inlinedinfo", "Add symbols from the inlined libraries, TBD only">, Group<grp_mach_o>; | ||
defm arch : Eq<"arch", "architecture(s) from a Mach-O file to dump">, Group<grp_mach_o>; | ||
def dyldinfo_only : FF<"dyldinfo-only", "Show only symbols from the dyldinfo">, Group<grp_mach_o>; | ||
def no_dyldinfo : FF<"no-dyldinfo", "Don't add any symbols from the dyldinfo">, Group<grp_mach_o>; | ||
def s : F<"s", "Dump only symbols from this segment and section name">, Group<grp_mach_o>; | ||
def x : F<"x", "Print symbol entry in hex">, Group<grp_mach_o>; | ||
|
||
def : FF<"just-symbol-name", "Alias for --format=just-symbols">, Alias<format_EQ>, AliasArgs<["just-symbols"]>, Flags<[HelpHidden]>; | ||
def : FF<"portability", "Alias for --format=posix">, Alias<format_EQ>, AliasArgs<["posix"]>; | ||
|
||
def : F<"a", "Alias for --debug-syms">, Alias<debug_syms>; | ||
def : F<"A", "Alias for --print-file-name">, Alias<print_file_name>; | ||
def : F<"B", "Alias for --format=bsd">, Alias<format_EQ>, AliasArgs<["bsd"]>; | ||
def : F<"C", "Alias for --demangle">, Alias<demangle>; | ||
def : F<"D", "Alias for --dynamic">, Alias<dynamic>; | ||
def : JoinedOrSeparate<["-"], "f">, HelpText<"Alias for --format">, Alias<format_EQ>, MetaVarName<"<format>">; | ||
def : F<"h", "Alias for --help">, Alias<help>; | ||
def : F<"g", "Alias for --extern-only">, Alias<extern_only>; | ||
def : F<"j", "Alias for --format=just-symbols">, Alias<format_EQ>, AliasArgs<["just-symbols"]>; | ||
def : F<"m", "Alias for --format=darwin">, Alias<format_EQ>, AliasArgs<["darwin"]>; | ||
def : F<"M", "Deprecated alias for --print-armap">, Alias<print_armap>, Flags<[HelpHidden]>; | ||
def : F<"n", "Alias for --numeric-sort">, Alias<numeric_sort>; | ||
def : F<"o", "Alias for --print-file-name">, Alias<print_file_name>; | ||
def : F<"p", "Alias for --no-sort">, Alias<no_sort>; | ||
def : F<"P", "Alias for --format=posix">, Alias<format_EQ>, AliasArgs<["posix"]>; | ||
def : F<"r", "Alias for --reverse-sort">, Alias<reverse_sort>; | ||
def : F<"S", "Alias for --print-size">, Alias<print_size>; | ||
def : JoinedOrSeparate<["-"], "t">, HelpText<"Alias for --radix">, Alias<radix_EQ>, MetaVarName<"<radix>">; | ||
def : F<"u", "Alias for --undefined-only">, Alias<undefined_only>; | ||
def : F<"U", "Deprecated alias for --defined-only">, Alias<defined_only>, Flags<[HelpHidden]>; | ||
def : F<"v", "Alias for --numeric-sort">, Alias<numeric_sort>; | ||
def : F<"V", "Alias for --version">, Alias<version>; | ||
def : F<"W", "Deprecated alias for --no-weak">, Alias<no_weak>, Flags<[HelpHidden]>; |
Oops, something went wrong.