[lldb] Also include the array definition in CommandOptions.inc
authorRaphael Isemann <teemperor@gmail.com>
Sun, 28 Jul 2019 06:24:07 +0000 (06:24 +0000)
committerRaphael Isemann <teemperor@gmail.com>
Sun, 28 Jul 2019 06:24:07 +0000 (06:24 +0000)
Summary:
Right now our CommandOptions.inc only generates the initializer for the options list but
not the array declaration boilerplate around it. As the array definition is identical for all arrays,
we might as well also let the CommandOptions.inc generate it alongside the initializers.

This patch will also allow us to generate additional declarations related to that option list in
the future (e.g. a enum class representing the specific options which would make our
handling code less prone).

This patch also fixes a few option tables that didn't follow our naming style.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D65331

llvm-svn: 367186

20 files changed:
lldb/source/Commands/CommandObjectBreakpoint.cpp
lldb/source/Commands/CommandObjectBreakpointCommand.cpp
lldb/source/Commands/CommandObjectCommands.cpp
lldb/source/Commands/CommandObjectDisassemble.cpp
lldb/source/Commands/CommandObjectExpression.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Commands/CommandObjectHelp.cpp
lldb/source/Commands/CommandObjectLog.cpp
lldb/source/Commands/CommandObjectMemory.cpp
lldb/source/Commands/CommandObjectPlatform.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Commands/CommandObjectRegister.cpp
lldb/source/Commands/CommandObjectSettings.cpp
lldb/source/Commands/CommandObjectSource.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Commands/CommandObjectType.cpp
lldb/source/Commands/CommandObjectWatchpoint.cpp
lldb/source/Commands/CommandObjectWatchpointCommand.cpp
lldb/utils/TableGen/LLDBOptionDefEmitter.cpp

index bd38e0e..d23c969 100644 (file)
@@ -44,10 +44,9 @@ static void AddBreakpointDescription(Stream *s, Breakpoint *bp,
 
 // Modifiable Breakpoint Options
 #pragma mark Modify::CommandOptions
-static constexpr OptionDefinition g_breakpoint_modify_options[] = {
 #define LLDB_OPTIONS_breakpoint_modify
 #include "CommandOptions.inc"
-};
+
 class lldb_private::BreakpointOptionGroup : public OptionGroup
 {
 public:
@@ -181,10 +180,9 @@ public:
   BreakpointOptions m_bp_opts;
 
 };
-static constexpr OptionDefinition g_breakpoint_dummy_options[] = {
+
 #define LLDB_OPTIONS_breakpoint_dummy
 #include "CommandOptions.inc"
-};
 
 class BreakpointDummyOptionGroup : public OptionGroup
 {
@@ -224,10 +222,8 @@ public:
 
 };
 
-static constexpr OptionDefinition g_breakpoint_set_options[] = {
 #define LLDB_OPTIONS_breakpoint_set
 #include "CommandOptions.inc"
-};
 
 // CommandObjectBreakpointSet
 
@@ -1154,10 +1150,8 @@ protected:
 // CommandObjectBreakpointList
 
 #pragma mark List::CommandOptions
-static constexpr OptionDefinition g_breakpoint_list_options[] = {
 #define LLDB_OPTIONS_breakpoint_list
 #include "CommandOptions.inc"
-};
 
 #pragma mark List
 
@@ -1311,10 +1305,8 @@ private:
 // CommandObjectBreakpointClear
 #pragma mark Clear::CommandOptions
 
-static constexpr OptionDefinition g_breakpoint_clear_options[] = {
 #define LLDB_OPTIONS_breakpoint_clear
 #include "CommandOptions.inc"
-};
 
 #pragma mark Clear
 
@@ -1462,10 +1454,8 @@ private:
 };
 
 // CommandObjectBreakpointDelete
-static constexpr OptionDefinition g_breakpoint_delete_options[] = {
 #define LLDB_OPTIONS_breakpoint_delete
 #include "CommandOptions.inc"
-};
 
 #pragma mark Delete
 
@@ -1614,11 +1604,9 @@ private:
 };
 
 // CommandObjectBreakpointName
-
-static constexpr OptionDefinition g_breakpoint_name_options[] = {
 #define LLDB_OPTIONS_breakpoint_name
 #include "CommandOptions.inc"
-};
+
 class BreakpointNameOptionGroup : public OptionGroup {
 public:
   BreakpointNameOptionGroup()
@@ -1680,10 +1668,8 @@ public:
   OptionValueString m_help_string;
 };
 
-static constexpr OptionDefinition g_breakpoint_access_options[] = {
 #define LLDB_OPTIONS_breakpoint_access
 #include "CommandOptions.inc"
-};
 
 class BreakpointAccessOptionGroup : public OptionGroup {
 public:
@@ -2142,10 +2128,8 @@ public:
 
 // CommandObjectBreakpointRead
 #pragma mark Read::CommandOptions
-static constexpr OptionDefinition g_breakpoint_read_options[] = {
 #define LLDB_OPTIONS_breakpoint_read
 #include "CommandOptions.inc"
-};
 
 #pragma mark Read
 
@@ -2269,10 +2253,8 @@ private:
 
 // CommandObjectBreakpointWrite
 #pragma mark Write::CommandOptions
-static constexpr OptionDefinition g_breakpoint_write_options[] = {
 #define LLDB_OPTIONS_breakpoint_write
 #include "CommandOptions.inc"
-};
 
 #pragma mark Write
 class CommandObjectBreakpointWrite : public CommandObjectParsed {
index ec72a04..68039ed 100644 (file)
@@ -44,10 +44,8 @@ static constexpr OptionEnumValues ScriptOptionEnum() {
   return OptionEnumValues(g_script_option_enumeration);
 }
 
-static constexpr OptionDefinition g_breakpoint_add_options[] = {
 #define LLDB_OPTIONS_breakpoint_command_add
 #include "CommandOptions.inc"
-};
 
 class CommandObjectBreakpointCommandAdd : public CommandObjectParsed,
                                           public IOHandlerDelegateMultiline {
@@ -286,7 +284,8 @@ are no syntax errors may indicate that a function was declared but never called.
 
       case 's':
         m_script_language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum(
-            option_arg, g_breakpoint_add_options[option_idx].enum_values,
+            option_arg,
+            g_breakpoint_command_add_options[option_idx].enum_values,
             eScriptLanguageNone, error);
 
         if (m_script_language == eScriptLanguagePython ||
@@ -336,7 +335,7 @@ are no syntax errors may indicate that a function was declared but never called.
     }
 
     llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
-      return llvm::makeArrayRef(g_breakpoint_add_options);
+      return llvm::makeArrayRef(g_breakpoint_command_add_options);
     }
 
     // Instance variables to hold the values for command options.
@@ -464,10 +463,8 @@ const char *CommandObjectBreakpointCommandAdd::g_reader_instructions =
 
 // CommandObjectBreakpointCommandDelete
 
-static constexpr OptionDefinition g_breakpoint_delete_options[] = {
 #define LLDB_OPTIONS_breakpoint_command_delete
 #include "CommandOptions.inc"
-};
 
 class CommandObjectBreakpointCommandDelete : public CommandObjectParsed {
 public:
@@ -525,7 +522,7 @@ public:
     }
 
     llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
-      return llvm::makeArrayRef(g_breakpoint_delete_options);
+      return llvm::makeArrayRef(g_breakpoint_command_delete_options);
     }
 
     // Instance variables to hold the values for command options.
index 943f508..7404424 100644 (file)
@@ -31,10 +31,8 @@ using namespace lldb_private;
 
 // CommandObjectCommandsSource
 
-static constexpr OptionDefinition g_history_options[] = {
 #define LLDB_OPTIONS_history
 #include "CommandOptions.inc"
-};
 
 class CommandObjectCommandsHistory : public CommandObjectParsed {
 public:
@@ -184,10 +182,8 @@ protected:
 
 // CommandObjectCommandsSource
 
-static constexpr OptionDefinition g_source_options[] = {
 #define LLDB_OPTIONS_source
 #include "CommandOptions.inc"
-};
 
 class CommandObjectCommandsSource : public CommandObjectParsed {
 public:
@@ -336,10 +332,8 @@ protected:
 #pragma mark CommandObjectCommandsAlias
 // CommandObjectCommandsAlias
 
-static constexpr OptionDefinition g_alias_options[] = {
 #define LLDB_OPTIONS_alias
 #include "CommandOptions.inc"
-};
 
 static const char *g_python_command_instructions =
     "Enter your Python command(s). Type 'DONE' to end.\n"
@@ -902,10 +896,8 @@ protected:
 
 // CommandObjectCommandsAddRegex
 
-static constexpr OptionDefinition g_regex_options[] = {
 #define LLDB_OPTIONS_regex
 #include "CommandOptions.inc"
-};
 
 #pragma mark CommandObjectCommandsAddRegex
 
@@ -1374,11 +1366,8 @@ private:
 };
 
 // CommandObjectCommandsScriptImport
-
-static constexpr OptionDefinition g_script_import_options[] = {
 #define LLDB_OPTIONS_script_import
 #include "CommandOptions.inc"
-};
 
 class CommandObjectCommandsScriptImport : public CommandObjectParsed {
 public:
@@ -1508,10 +1497,8 @@ static constexpr OptionEnumValues ScriptSynchroType() {
   return OptionEnumValues(g_script_synchro_type);
 }
 
-static constexpr OptionDefinition g_script_add_options[] = {
 #define LLDB_OPTIONS_script_add
 #include "CommandOptions.inc"
-};
 
 class CommandObjectCommandsScriptAdd : public CommandObjectParsed,
                                        public IOHandlerDelegateMultiline {
index 34d3f63..8a781a7 100644 (file)
 using namespace lldb;
 using namespace lldb_private;
 
-static constexpr OptionDefinition g_disassemble_options[] = {
 #define LLDB_OPTIONS_disassemble
 #include "CommandOptions.inc"
-};
 
 CommandObjectDisassemble::CommandOptions::CommandOptions()
     : Options(), num_lines_context(0), num_instructions(0), func_name(),
index a10f42d..99cf167 100644 (file)
@@ -47,10 +47,8 @@ static constexpr OptionEnumValues DescriptionVerbosityTypes() {
   return OptionEnumValues(g_description_verbosity_type);
 }
 
-static constexpr OptionDefinition g_expression_options[] = {
 #define LLDB_OPTIONS_expression
 #include "CommandOptions.inc"
-};
 
 Status CommandObjectExpression::CommandOptions::SetOptionValue(
     uint32_t option_idx, llvm::StringRef option_arg,
index 8cd5962..8592e74 100644 (file)
@@ -53,10 +53,8 @@ using namespace lldb_private;
 
 // CommandObjectFrameDiagnose
 
-static constexpr OptionDefinition g_frame_diag_options[] = {
 #define LLDB_OPTIONS_frame_diag
 #include "CommandOptions.inc"
-};
 
 class CommandObjectFrameDiagnose : public CommandObjectParsed {
 public:
@@ -234,10 +232,8 @@ protected:
 
 // CommandObjectFrameSelect
 
-static OptionDefinition g_frame_select_options[] = {
 #define LLDB_OPTIONS_frame_select
 #include "CommandOptions.inc"
-};
 
 class CommandObjectFrameSelect : public CommandObjectParsed {
 public:
@@ -739,10 +735,8 @@ protected:
 
 #pragma mark CommandObjectFrameRecognizer
 
-static OptionDefinition g_frame_recognizer_add_options[] = {
 #define LLDB_OPTIONS_frame_recognizer_add
 #include "CommandOptions.inc"
-};
 
 class CommandObjectFrameRecognizerAdd : public CommandObjectParsed {
 private:
index ab55791..1100ddf 100644 (file)
@@ -65,10 +65,8 @@ CommandObjectHelp::CommandObjectHelp(CommandInterpreter &interpreter)
 
 CommandObjectHelp::~CommandObjectHelp() = default;
 
-static constexpr OptionDefinition g_help_options[] = {
 #define LLDB_OPTIONS_help
 #include "CommandOptions.inc"
-};
 
 llvm::ArrayRef<OptionDefinition>
 CommandObjectHelp::CommandOptions::GetDefinitions() {
index e096836..2a591d2 100644 (file)
 using namespace lldb;
 using namespace lldb_private;
 
-static constexpr OptionDefinition g_log_options[] = {
 #define LLDB_OPTIONS_log
 #include "CommandOptions.inc"
-};
 
 class CommandObjectLogEnable : public CommandObjectParsed {
 public:
index 7409915..ac6abc3 100644 (file)
 using namespace lldb;
 using namespace lldb_private;
 
-static constexpr OptionDefinition g_read_memory_options[] = {
 #define LLDB_OPTIONS_memory_read
 #include "CommandOptions.inc"
-};
 
 class OptionGroupReadMemory : public OptionGroup {
 public:
@@ -60,13 +58,13 @@ public:
   ~OptionGroupReadMemory() override = default;
 
   llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
-    return llvm::makeArrayRef(g_read_memory_options);
+    return llvm::makeArrayRef(g_memory_read_options);
   }
 
   Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
                         ExecutionContext *execution_context) override {
     Status error;
-    const int short_option = g_read_memory_options[option_idx].short_option;
+    const int short_option = g_memory_read_options[option_idx].short_option;
 
     switch (short_option) {
     case 'l':
@@ -896,10 +894,8 @@ protected:
   CompilerType m_prev_compiler_type;
 };
 
-static constexpr OptionDefinition g_memory_find_option_table[] = {
 #define LLDB_OPTIONS_memory_find
 #include "CommandOptions.inc"
-};
 
 // Find the specified data in memory
 class CommandObjectMemoryFind : public CommandObjectParsed {
@@ -911,14 +907,13 @@ public:
     ~OptionGroupFindMemory() override = default;
 
     llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
-      return llvm::makeArrayRef(g_memory_find_option_table);
+      return llvm::makeArrayRef(g_memory_find_options);
     }
 
     Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
                           ExecutionContext *execution_context) override {
       Status error;
-      const int short_option =
-          g_memory_find_option_table[option_idx].short_option;
+      const int short_option = g_memory_find_options[option_idx].short_option;
 
       switch (short_option) {
       case 'e':
@@ -1189,10 +1184,8 @@ protected:
   OptionGroupFindMemory m_memory_options;
 };
 
-static constexpr OptionDefinition g_memory_write_option_table[] = {
 #define LLDB_OPTIONS_memory_write
 #include "CommandOptions.inc"
-};
 
 // Write memory to the inferior process
 class CommandObjectMemoryWrite : public CommandObjectParsed {
@@ -1204,14 +1197,13 @@ public:
     ~OptionGroupWriteMemory() override = default;
 
     llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
-      return llvm::makeArrayRef(g_memory_write_option_table);
+      return llvm::makeArrayRef(g_memory_write_options);
     }
 
     Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
                           ExecutionContext *execution_context) override {
       Status error;
-      const int short_option =
-          g_memory_write_option_table[option_idx].short_option;
+      const int short_option = g_memory_write_options[option_idx].short_option;
 
       switch (short_option) {
       case 'i':
index 1088384..9080ced 100644 (file)
@@ -58,10 +58,8 @@ static mode_t ParsePermissionString(llvm::StringRef permissions) {
   return user | group | world;
 }
 
-static constexpr OptionDefinition g_permissions_options[] = {
 #define LLDB_OPTIONS_permissions
 #include "CommandOptions.inc"
-};
 
 class OptionPermissions : public OptionGroup {
 public:
@@ -574,10 +572,8 @@ public:
 
 // "platform fread"
 
-static constexpr OptionDefinition g_platform_fread_options[] = {
 #define LLDB_OPTIONS_platform_fread
 #include "CommandOptions.inc"
-};
 
 class CommandObjectPlatformFRead : public CommandObjectParsed {
 public:
@@ -665,10 +661,8 @@ protected:
 
 // "platform fwrite"
 
-static constexpr OptionDefinition g_platform_fwrite_options[] = {
 #define LLDB_OPTIONS_platform_fwrite
 #include "CommandOptions.inc"
-};
 
 class CommandObjectPlatformFWrite : public CommandObjectParsed {
 public:
@@ -1042,10 +1036,8 @@ protected:
 // "platform process list"
 
 static PosixPlatformCommandOptionValidator posix_validator;
-static constexpr OptionDefinition g_platform_process_list_options[] = {
 #define LLDB_OPTIONS_platform_process_list
 #include "CommandOptions.inc"
-};
 
 class CommandObjectPlatformProcessList : public CommandObjectParsed {
 public:
@@ -1391,10 +1383,8 @@ protected:
   }
 };
 
-static constexpr OptionDefinition g_platform_process_attach_options[] = {
 #define LLDB_OPTIONS_platform_process_attach
 #include "CommandOptions.inc"
-};
 
 class CommandObjectPlatformProcessAttach : public CommandObjectParsed {
 public:
@@ -1566,10 +1556,8 @@ private:
 };
 
 // "platform shell"
-static constexpr OptionDefinition g_platform_shell_options[] = {
 #define LLDB_OPTIONS_platform_shell
 #include "CommandOptions.inc"
-};
 
 class CommandObjectPlatformShell : public CommandObjectRaw {
 public:
index 7228602..3d7a599 100644 (file)
@@ -255,10 +255,8 @@ protected:
   ProcessLaunchCommandOptions m_options;
 };
 
-static constexpr OptionDefinition g_process_attach_options[] = {
 #define LLDB_OPTIONS_process_attach
 #include "CommandOptions.inc"
-};
 
 #pragma mark CommandObjectProcessAttach
 class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach {
@@ -499,10 +497,8 @@ protected:
 
 // CommandObjectProcessContinue
 
-static constexpr OptionDefinition g_process_continue_options[] = {
 #define LLDB_OPTIONS_process_continue
 #include "CommandOptions.inc"
-};
 
 #pragma mark CommandObjectProcessContinue
 
@@ -659,10 +655,8 @@ protected:
 };
 
 // CommandObjectProcessDetach
-static constexpr OptionDefinition g_process_detach_options[] = {
 #define LLDB_OPTIONS_process_detach
 #include "CommandOptions.inc"
-};
 
 #pragma mark CommandObjectProcessDetach
 
@@ -754,11 +748,8 @@ protected:
 };
 
 // CommandObjectProcessConnect
-
-static constexpr OptionDefinition g_process_connect_options[] = {
 #define LLDB_OPTIONS_process_connect
 #include "CommandOptions.inc"
-};
 
 #pragma mark CommandObjectProcessConnect
 
@@ -878,11 +869,8 @@ public:
 };
 
 // CommandObjectProcessLoad
-
-static constexpr OptionDefinition g_process_load_options[] = {
 #define LLDB_OPTIONS_process_load
 #include "CommandOptions.inc"
-};
 
 #pragma mark CommandObjectProcessLoad
 
@@ -1261,11 +1249,8 @@ public:
 };
 
 // CommandObjectProcessHandle
-
-static constexpr OptionDefinition g_process_handle_options[] = {
 #define LLDB_OPTIONS_process_handle
 #include "CommandOptions.inc"
-};
 
 #pragma mark CommandObjectProcessHandle
 
index 62b1731..2b38de8 100644 (file)
@@ -32,11 +32,8 @@ using namespace lldb;
 using namespace lldb_private;
 
 // "register read"
-
-static constexpr OptionDefinition g_register_read_options[] = {
 #define LLDB_OPTIONS_register_read
 #include "CommandOptions.inc"
-};
 
 class CommandObjectRegisterRead : public CommandObjectParsed {
 public:
index 55a0002..d756e03 100644 (file)
@@ -20,11 +20,8 @@ using namespace lldb;
 using namespace lldb_private;
 
 // CommandObjectSettingsSet
-
-static constexpr OptionDefinition g_settings_set_options[] = {
 #define LLDB_OPTIONS_settings_set
 #include "CommandOptions.inc"
-};
 
 class CommandObjectSettingsSet : public CommandObjectRaw {
 public:
@@ -309,11 +306,8 @@ protected:
 };
 
 // CommandObjectSettingsWrite -- Write settings to file
-
-static constexpr OptionDefinition g_settings_write_options[] = {
 #define LLDB_OPTIONS_settings_write
 #include "CommandOptions.inc"
-};
 
 class CommandObjectSettingsWrite : public CommandObjectParsed {
 public:
@@ -432,11 +426,8 @@ private:
 };
 
 // CommandObjectSettingsRead -- Read settings from file
-
-static constexpr OptionDefinition g_settings_read_options[] = {
 #define LLDB_OPTIONS_settings_read
 #include "CommandOptions.inc"
-};
 
 class CommandObjectSettingsRead : public CommandObjectParsed {
 public:
index 7aab513..417dedc 100644 (file)
@@ -33,11 +33,8 @@ using namespace lldb_private;
 
 #pragma mark CommandObjectSourceInfo
 // CommandObjectSourceInfo - debug line entries dumping command
-
-static constexpr OptionDefinition g_source_info_options[] = {
 #define LLDB_OPTIONS_source_info
 #include "CommandOptions.inc"
-};
 
 class CommandObjectSourceInfo : public CommandObjectParsed {
   class CommandOptions : public Options {
@@ -636,11 +633,8 @@ protected:
 
 #pragma mark CommandObjectSourceList
 // CommandObjectSourceList
-
-static constexpr OptionDefinition g_source_list_options[] = {
 #define LLDB_OPTIONS_source_list
 #include "CommandOptions.inc"
-};
 
 class CommandObjectSourceList : public CommandObjectParsed {
   class CommandOptions : public Options {
index 889f95a..cf464d2 100644 (file)
@@ -144,10 +144,8 @@ static constexpr OptionEnumValueElement g_dependents_enumaration[] = {
     {eLoadDependentsYes, "false",
      "Load dependents, even if the target is not an executable."}};
 
-static constexpr OptionDefinition g_dependents_options[] = {
 #define LLDB_OPTIONS_target_dependents
 #include "CommandOptions.inc"
-};
 
 class OptionGroupDependents : public OptionGroup {
 public:
@@ -156,7 +154,7 @@ public:
   ~OptionGroupDependents() override {}
 
   llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
-    return llvm::makeArrayRef(g_dependents_options);
+    return llvm::makeArrayRef(g_target_dependents_options);
   }
 
   Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
@@ -169,11 +167,13 @@ public:
       return error;
     }
 
-    const char short_option = g_dependents_options[option_idx].short_option;
+    const char short_option =
+        g_target_dependents_options[option_idx].short_option;
     if (short_option == 'd') {
       LoadDependentFiles tmp_load_dependents;
       tmp_load_dependents = (LoadDependentFiles)OptionArgParser::ToOptionEnum(
-          option_value, g_dependents_options[option_idx].enum_values, 0, error);
+          option_value, g_target_dependents_options[option_idx].enum_values, 0,
+          error);
       if (error.Success())
         m_load_dependent_files = tmp_load_dependents;
     } else {
@@ -1964,10 +1964,8 @@ static constexpr OptionEnumValueElement g_sort_option_enumeration[] = {
     {eSortOrderByAddress, "address", "Sort output by symbol address."},
     {eSortOrderByName, "name", "Sort output by symbol name."} };
 
-static constexpr OptionDefinition g_target_modules_dump_symtab_options[] = {
 #define LLDB_OPTIONS_target_modules_dump_symtab
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTargetModulesDumpSymtab
     : public CommandObjectTargetModulesModuleAutoComplete {
@@ -2364,6 +2362,8 @@ protected:
 };
 
 #pragma mark CommandObjectTargetModulesDumpLineTable
+#define LLDB_OPTIONS_target_modules_dump
+#include "CommandOptions.inc"
 
 // Image debug line table dumping command
 
@@ -2452,11 +2452,7 @@ protected:
     }
 
     llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
-      static constexpr OptionDefinition g_options[] = {
-#define LLDB_OPTIONS_target_modules_dump
-#include "CommandOptions.inc"
-      };
-      return llvm::makeArrayRef(g_options);
+      return llvm::makeArrayRef(g_target_modules_dump_options);
     }
 
     bool m_verbose;
@@ -2958,11 +2954,8 @@ protected:
 };
 
 // List images with associated information
-
-static constexpr OptionDefinition g_target_modules_list_options[] = {
 #define LLDB_OPTIONS_target_modules_list
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTargetModulesList : public CommandObjectParsed {
 public:
@@ -3307,11 +3300,8 @@ protected:
 #pragma mark CommandObjectTargetModulesShowUnwind
 
 // Lookup unwind information in images
-
-static constexpr OptionDefinition g_target_modules_show_unwind_options[] = {
 #define LLDB_OPTIONS_target_modules_show_unwind
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTargetModulesShowUnwind : public CommandObjectParsed {
 public:
@@ -3616,11 +3606,8 @@ protected:
 };
 
 // Lookup information in images
-
-static constexpr OptionDefinition g_target_modules_lookup_options[] = {
 #define LLDB_OPTIONS_target_modules_lookup
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTargetModulesLookup : public CommandObjectParsed {
 public:
@@ -4471,11 +4458,8 @@ private:
 #pragma mark CommandObjectTargetStopHookAdd
 
 // CommandObjectTargetStopHookAdd
-
-static constexpr OptionDefinition g_target_stop_hook_add_options[] = {
 #define LLDB_OPTIONS_target_stop_hook_add
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTargetStopHookAdd : public CommandObjectParsed,
                                        public IOHandlerDelegateMultiline {
index ed7cf0a..55d0d3f 100644 (file)
@@ -237,11 +237,8 @@ protected:
 };
 
 // CommandObjectThreadBacktrace
-
-static constexpr OptionDefinition g_thread_backtrace_options[] = {
 #define LLDB_OPTIONS_thread_backtrace
 #include "CommandOptions.inc"
-};
 
 class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads {
 public:
@@ -403,10 +400,8 @@ static constexpr OptionEnumValues TriRunningModes() {
   return OptionEnumValues(g_tri_running_mode);
 }
 
-static constexpr OptionDefinition g_thread_step_scope_options[] = {
 #define LLDB_OPTIONS_thread_step_scope
 #include "CommandOptions.inc"
-};
 
 class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed {
 public:
@@ -983,10 +978,8 @@ static constexpr OptionEnumValues DuoRunningModes() {
   return OptionEnumValues(g_duo_running_mode);
 }
 
-static constexpr OptionDefinition g_thread_until_options[] = {
 #define LLDB_OPTIONS_thread_until
 #include "CommandOptions.inc"
-};
 
 class CommandObjectThreadUntil : public CommandObjectParsed {
 public:
@@ -1402,11 +1395,8 @@ protected:
 };
 
 // CommandObjectThreadInfo
-
-static constexpr OptionDefinition g_thread_info_options[] = {
 #define LLDB_OPTIONS_thread_info
 #include "CommandOptions.inc"
-};
 
 class CommandObjectThreadInfo : public CommandObjectIterateOverThreads {
 public:
@@ -1536,11 +1526,8 @@ class CommandObjectThreadException : public CommandObjectIterateOverThreads {
 };
 
 // CommandObjectThreadReturn
-
-static constexpr OptionDefinition g_thread_return_options[] = {
 #define LLDB_OPTIONS_thread_return
 #include "CommandOptions.inc"
-};
 
 class CommandObjectThreadReturn : public CommandObjectRaw {
 public:
@@ -1711,11 +1698,8 @@ protected:
 };
 
 // CommandObjectThreadJump
-
-static constexpr OptionDefinition g_thread_jump_options[] = {
 #define LLDB_OPTIONS_thread_jump
 #include "CommandOptions.inc"
-};
 
 class CommandObjectThreadJump : public CommandObjectParsed {
 public:
@@ -1854,11 +1838,8 @@ protected:
 // Next are the subcommands of CommandObjectMultiwordThreadPlan
 
 // CommandObjectThreadPlanList
-
-static constexpr OptionDefinition g_thread_plan_list_options[] = {
 #define LLDB_OPTIONS_thread_plan_list
 #include "CommandOptions.inc"
-};
 
 class CommandObjectThreadPlanList : public CommandObjectIterateOverThreads {
 public:
index 98a43f5..496f856 100644 (file)
@@ -95,10 +95,8 @@ static bool WarnOnPotentialUnquotedUnsignedType(Args &command,
   return false;
 }
 
-static constexpr OptionDefinition g_type_summary_add_options[] = {
 #define LLDB_OPTIONS_type_summary_add
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTypeSummaryAdd : public CommandObjectParsed,
                                     public IOHandlerDelegateMultiline {
@@ -282,10 +280,8 @@ static const char *g_synth_addreader_instructions =
     "        '''Optional'''\n"
     "class synthProvider:\n";
 
-static constexpr OptionDefinition g_type_synth_add_options[] = {
 #define LLDB_OPTIONS_type_synth_add
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTypeSynthAdd : public CommandObjectParsed,
                                   public IOHandlerDelegateMultiline {
@@ -503,10 +499,8 @@ public:
 
 // CommandObjectTypeFormatAdd
 
-static constexpr OptionDefinition g_type_format_add_options[] = {
 #define LLDB_OPTIONS_type_format_add
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTypeFormatAdd : public CommandObjectParsed {
 private:
@@ -720,10 +714,8 @@ protected:
   }
 };
 
-static constexpr OptionDefinition g_type_formatter_delete_options[] = {
 #define LLDB_OPTIONS_type_formatter_delete
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTypeFormatterDelete : public CommandObjectParsed {
 protected:
@@ -859,10 +851,8 @@ protected:
   }
 };
 
-static constexpr OptionDefinition g_type_formatter_clear_options[] = {
 #define LLDB_OPTIONS_type_formatter_clear
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTypeFormatterClear : public CommandObjectParsed {
 private:
@@ -971,11 +961,8 @@ public:
             "type format clear", "Delete all existing format styles.") {}
 };
 
-
-static constexpr OptionDefinition g_type_formatter_list_options[] = {
 #define LLDB_OPTIONS_type_formatter_list
 #include "CommandOptions.inc"
-};
 
 template <typename FormatterType>
 class CommandObjectTypeFormatterList : public CommandObjectParsed {
@@ -1731,11 +1718,8 @@ protected:
 };
 
 // CommandObjectTypeCategoryDefine
-
-static constexpr OptionDefinition g_type_category_define_options[] = {
 #define LLDB_OPTIONS_type_category_define
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTypeCategoryDefine : public CommandObjectParsed {
   class CommandOptions : public Options {
@@ -1834,11 +1818,8 @@ protected:
 };
 
 // CommandObjectTypeCategoryEnable
-
-static constexpr OptionDefinition g_type_category_enable_options[] = {
 #define LLDB_OPTIONS_type_category_enable
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTypeCategoryEnable : public CommandObjectParsed {
   class CommandOptions : public Options {
@@ -2006,11 +1987,8 @@ protected:
 };
 
 // CommandObjectTypeCategoryDisable
-
-OptionDefinition constexpr g_type_category_disable_options[] = {
 #define LLDB_OPTIONS_type_category_disable
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTypeCategoryDisable : public CommandObjectParsed {
   class CommandOptions : public Options {
@@ -2415,11 +2393,8 @@ bool CommandObjectTypeSynthAdd::AddSynth(ConstString type_name,
 }
 
 #endif // LLDB_DISABLE_PYTHON
-
-static constexpr OptionDefinition g_type_filter_add_options[] = {
 #define LLDB_OPTIONS_type_filter_add
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTypeFilterAdd : public CommandObjectParsed {
 private:
@@ -2663,10 +2638,8 @@ protected:
 };
 
 // "type lookup"
-static constexpr OptionDefinition g_type_lookup_options[] = {
 #define LLDB_OPTIONS_type_lookup
 #include "CommandOptions.inc"
-};
 
 class CommandObjectTypeLookup : public CommandObjectRaw {
 protected:
index 98e758b..a7097af 100644 (file)
@@ -146,11 +146,8 @@ bool CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
 
 // CommandObjectWatchpointList::Options
 #pragma mark List::CommandOptions
-
-static constexpr OptionDefinition g_watchpoint_list_options[] = {
 #define LLDB_OPTIONS_watchpoint_list
 #include "CommandOptions.inc"
-};
 
 #pragma mark List
 
@@ -507,10 +504,8 @@ protected:
 // CommandObjectWatchpointIgnore
 
 #pragma mark Ignore::CommandOptions
-static constexpr OptionDefinition g_watchpoint_ignore_options[] = {
 #define LLDB_OPTIONS_watchpoint_ignore
 #include "CommandOptions.inc"
-};
 
 class CommandObjectWatchpointIgnore : public CommandObjectParsed {
 public:
@@ -625,11 +620,8 @@ private:
 // CommandObjectWatchpointModify
 
 #pragma mark Modify::CommandOptions
-
-static constexpr OptionDefinition g_watchpoint_modify_options[] = {
 #define LLDB_OPTIONS_watchpoint_modify
 #include "CommandOptions.inc"
-};
 
 #pragma mark Modify
 
index 2be0b5b..52cd73b 100644 (file)
@@ -42,10 +42,8 @@ static constexpr OptionEnumValues ScriptOptionEnum() {
   return OptionEnumValues(g_script_option_enumeration);
 }
 
-static constexpr OptionDefinition g_watchpoint_command_add_options[] = {
 #define LLDB_OPTIONS_watchpoint_command_add
 #include "CommandOptions.inc"
-};
 
 class CommandObjectWatchpointCommandAdd : public CommandObjectParsed,
                                           public IOHandlerDelegateMultiline {
index 844d258..92dc80f 100644 (file)
@@ -129,18 +129,21 @@ static void emitOption(Record *Option, raw_ostream &OS) {
 /// Emits all option initializers to the raw_ostream.
 static void emitOptions(std::string Command, std::vector<Record *> Option,
                         raw_ostream &OS) {
+  std::string ID = Command;
+  std::replace(ID.begin(), ID.end(), ' ', '_');
   // Generate the macro that the user needs to define before including the
   // *.inc file.
-  std::string NeededMacro = "LLDB_OPTIONS_" + Command;
-  std::replace(NeededMacro.begin(), NeededMacro.end(), ' ', '_');
+  std::string NeededMacro = "LLDB_OPTIONS_" + ID;
 
   // All options are in one file, so we need put them behind macros and ask the
   // user to define the macro for the options that are needed.
   OS << "// Options for " << Command << "\n";
   OS << "#ifdef " << NeededMacro << "\n";
+  OS << "constexpr static OptionDefinition g_" + ID + "_options[] = {\n";
   for (Record *R : Option)
     emitOption(R, OS);
   // We undefine the macro for the user like Clang's include files are doing it.
+  OS << "};\n";
   OS << "#undef " << NeededMacro << "\n";
   OS << "#endif // " << Command << " command\n\n";
 }