diff options
author | Raphael Isemann <teemperor@gmail.com> | 2019-07-26 11:46:21 +0000 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2019-07-26 11:46:21 +0000 |
commit | 0ab0bb91aad5fd880399ab78bc06d7e140e66b84 (patch) | |
tree | 6e6a9088e408b02f21ce66112b5d0bbe728b7285 /lldb | |
parent | c229cfeb7a7e8c9fefafac6b8576f8a0aa1dee3a (diff) | |
download | bcm5719-llvm-0ab0bb91aad5fd880399ab78bc06d7e140e66b84.tar.gz bcm5719-llvm-0ab0bb91aad5fd880399ab78bc06d7e140e66b84.zip |
[lldb] Don't dynamically allocate the posix option validator.
We dynamically allocate the option validator which means we
can't mark this list of OptionDefinitions as constexpr. It's also
more complicated than necessary.
llvm-svn: 367102
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/source/Commands/CommandObjectPlatform.cpp | 20 | ||||
-rw-r--r-- | lldb/source/Commands/Options.td | 8 | ||||
-rw-r--r-- | lldb/source/Commands/OptionsBase.td | 9 | ||||
-rw-r--r-- | lldb/utils/TableGen/LLDBOptionDefEmitter.cpp | 8 |
4 files changed, 21 insertions, 24 deletions
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp index d1054020c81..1088384089c 100644 --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -1041,7 +1041,8 @@ protected: // "platform process list" -static OptionDefinition g_platform_process_list_options[] = { +static PosixPlatformCommandOptionValidator posix_validator; +static constexpr OptionDefinition g_platform_process_list_options[] = { #define LLDB_OPTIONS_platform_process_list #include "CommandOptions.inc" }; @@ -1166,23 +1167,6 @@ protected: public: CommandOptions() : Options(), match_info(), show_args(false), verbose(false) { - static llvm::once_flag g_once_flag; - llvm::call_once(g_once_flag, []() { - PosixPlatformCommandOptionValidator *posix_validator = - new PosixPlatformCommandOptionValidator(); - for (auto &Option : g_platform_process_list_options) { - switch (Option.short_option) { - case 'u': - case 'U': - case 'g': - case 'G': - Option.validator = posix_validator; - break; - default: - break; - } - } - }); } ~CommandOptions() override = default; diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index 4483d493246..d71029015ea 100644 --- a/lldb/source/Commands/Options.td +++ b/lldb/source/Commands/Options.td @@ -576,16 +576,16 @@ let Command = "platform process list" in { def platform_process_list_parent : Option<"parent", "P">, GroupRange<2, 6>, Arg<"Pid">, Desc<"Find processes that have a matching parent process ID.">; def platform_process_list_uid : Option<"uid", "u">, GroupRange<2, 6>, - Arg<"UnsignedInteger">, + Arg<"UnsignedInteger">, Validator<"&posix_validator">, Desc<"Find processes that have a matching user ID.">; def platform_process_list_euid : Option<"euid", "U">, GroupRange<2, 6>, - Arg<"UnsignedInteger">, + Arg<"UnsignedInteger">, Validator<"&posix_validator">, Desc<"Find processes that have a matching effective user ID.">; def platform_process_list_gid : Option<"gid", "g">, GroupRange<2, 6>, - Arg<"UnsignedInteger">, + Arg<"UnsignedInteger">, Validator<"&posix_validator">, Desc<"Find processes that have a matching group ID.">; def platform_process_list_egid : Option<"egid", "G">, GroupRange<2, 6>, - Arg<"UnsignedInteger">, + Arg<"UnsignedInteger">, Validator<"&posix_validator">, Desc<"Find processes that have a matching effective group ID.">; def platform_process_list_arch : Option<"arch", "a">, GroupRange<2, 6>, Arg<"Architecture">, diff --git a/lldb/source/Commands/OptionsBase.td b/lldb/source/Commands/OptionsBase.td index e0ee03fa9fb..f6967f067bf 100644 --- a/lldb/source/Commands/OptionsBase.td +++ b/lldb/source/Commands/OptionsBase.td @@ -46,7 +46,9 @@ //////////////////////////////////////////////////////////////////////////////// // Field: validator // Default value: 0 (No validator for option) -// Set by: Nothing. This is currently only set after initialization in LLDB. +// Set by: +// - `Validator`: Sets the value to a given validator (which has to exist in +// the surrounding code. //////////////////////////////////////////////////////////////////////////////// // Field: enum_values // Default value: {} (No enum associated with this option) @@ -169,3 +171,8 @@ class Completions<list<string> completions> { class Completion<string completion> { list<string> Completions = [completion]; } + +// Sets the validator for a given option. +class Validator<string validator> { + string Validator = validator; +} diff --git a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp index 537f71cd582..844d258568e 100644 --- a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp +++ b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp @@ -81,7 +81,13 @@ static void emitOption(Record *Option, raw_ostream &OS) { OS << "eRequiredArgument"; } else OS << "eNoArgument"; - OS << ", nullptr, "; + OS << ", "; + + if (Option->getValue("Validator")) + OS << Option->getValueAsString("Validator"); + else + OS << "nullptr"; + OS << ", "; if (Option->getValue("ArgEnum")) OS << Option->getValueAsString("ArgEnum"); |