diff --git a/llvm/docs/CommandGuide/llvm-cxxfilt.rst b/llvm/docs/CommandGuide/llvm-cxxfilt.rst --- a/llvm/docs/CommandGuide/llvm-cxxfilt.rst +++ b/llvm/docs/CommandGuide/llvm-cxxfilt.rst @@ -48,10 +48,6 @@ Print a summary of command line options. -.. option:: --help-list - - Print an uncategorized summary of command line options. - .. option:: --no-strip-underscore, -n Do not strip a leading underscore. This is the default for all platforms diff --git a/llvm/test/tools/llvm-cxxfilt/help.test b/llvm/test/tools/llvm-cxxfilt/help.test --- a/llvm/test/tools/llvm-cxxfilt/help.test +++ b/llvm/test/tools/llvm-cxxfilt/help.test @@ -1,7 +1,7 @@ RUN: llvm-cxxfilt -h | FileCheck %s RUN: llvm-cxxfilt --help | FileCheck %s -CHECK: OVERVIEW: llvm symbol undecoration tool -CHECK: USAGE: llvm-cxxfilt{{(.exe)?}} [options] {{$}} +CHECK: OVERVIEW: LLVM symbol undecoration tool +CHECK: USAGE: {{.*}}llvm-cxxfilt{{(.exe)?}} [options] {{$}} CHECK: OPTIONS: CHECK: @FILE diff --git a/llvm/tools/llvm-cxxfilt/CMakeLists.txt b/llvm/tools/llvm-cxxfilt/CMakeLists.txt --- a/llvm/tools/llvm-cxxfilt/CMakeLists.txt +++ b/llvm/tools/llvm-cxxfilt/CMakeLists.txt @@ -1,10 +1,18 @@ set(LLVM_LINK_COMPONENTS Demangle + Option Support ) +set(LLVM_TARGET_DEFINITIONS Opts.td) +tablegen(LLVM Opts.inc -gen-opt-parser-defs) +add_public_tablegen_target(CxxfiltOptsTableGen) + add_llvm_tool(llvm-cxxfilt llvm-cxxfilt.cpp + + DEPENDS + CxxfiltOptsTableGen ) if(LLVM_INSTALL_BINUTILS_SYMLINKS) diff --git a/llvm/tools/llvm-cxxfilt/Opts.td b/llvm/tools/llvm-cxxfilt/Opts.td new file mode 100644 --- /dev/null +++ b/llvm/tools/llvm-cxxfilt/Opts.td @@ -0,0 +1,28 @@ +include "llvm/Option/OptParser.td" + +class F : Flag<["-"], letter>, HelpText; +class FF : Flag<["--"], name>, HelpText; + +multiclass BB { + def NAME: Flag<["--"], name>, HelpText; + def no_ # NAME: Flag<["--"], "no-" # name>, HelpText; +} + +multiclass Eq { + def NAME #_EQ : Joined<["--"], name #"=">, + HelpText; + def : Separate<["--"], name>, Alias(NAME #_EQ)>; +} + +def help : FF<"help", "Display this help">; +defm strip_underscore : BB<"strip-underscore", "Strip the leading underscore", "Don't strip the leading underscore">; +def types : FF<"types", "">; +def version : FF<"version", "Display the version">; + +defm : Eq<"format", "Specify mangling format. Currently ignored because only 'gnu' is supported">; +def : F<"s", "Alias for --format">; + +def : F<"_", "Alias for --strip-underscore">, Alias; +def : F<"h", "Alias for --help">, Alias; +def : F<"n", "Alias for --no-strip-underscore">, Alias; +def : F<"t", "Alias for --types">, Alias; diff --git a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp --- a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp +++ b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp @@ -9,69 +9,59 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Triple.h" #include "llvm/Demangle/Demangle.h" +#include "llvm/Option/Arg.h" +#include "llvm/Option/ArgList.h" +#include "llvm/Option/Option.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Host.h" #include "llvm/Support/InitLLVM.h" +#include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" #include #include using namespace llvm; -enum Style { - Auto, ///< auto-detect mangling - GNU, ///< GNU - Lucid, ///< Lucid compiler (lcc) - ARM, - HP, ///< HP compiler (xCC) - EDG, ///< EDG compiler - GNUv3, ///< GNU C++ v3 ABI - Java, ///< Java (gcj) - GNAT ///< ADA compiler (gnat) +namespace { +enum ID { + OPT_INVALID = 0, // This is not an option ID. +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, VALUES) \ + OPT_##ID, +#include "Opts.inc" +#undef OPTION }; -static cl::opt