[Lldb-commits] [lldb] r367186 - [lldb] Also include the array definition in CommandOptions.inc

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Sat Jul 27 23:24:07 PDT 2019


Author: teemperor
Date: Sat Jul 27 23:24:07 2019
New Revision: 367186

URL: http://llvm.org/viewvc/llvm-project?rev=367186&view=rev
Log:
[lldb] Also include the array definition in CommandOptions.inc

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

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

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Sat Jul 27 23:24:07 2019
@@ -44,10 +44,9 @@ static void AddBreakpointDescription(Str
 
 // 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 {

Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Sat Jul 27 23:24:07 2019
@@ -44,10 +44,8 @@ static constexpr OptionEnumValues Script
   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
 
       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
     }
 
     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 *CommandObjectBreakpointComma
 
 // 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.

Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Sat Jul 27 23:24:07 2019
@@ -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 Script
   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 {

Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Sat Jul 27 23:24:07 2019
@@ -30,10 +30,8 @@
 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(),

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Sat Jul 27 23:24:07 2019
@@ -47,10 +47,8 @@ static constexpr OptionEnumValues Descri
   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,

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Sat Jul 27 23:24:07 2019
@@ -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:

Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Sat Jul 27 23:24:07 2019
@@ -65,10 +65,8 @@ CommandObjectHelp::CommandObjectHelp(Com
 
 CommandObjectHelp::~CommandObjectHelp() = default;
 
-static constexpr OptionDefinition g_help_options[] = {
 #define LLDB_OPTIONS_help
 #include "CommandOptions.inc"
-};
 
 llvm::ArrayRef<OptionDefinition>
 CommandObjectHelp::CommandOptions::GetDefinitions() {

Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectLog.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectLog.cpp Sat Jul 27 23:24:07 2019
@@ -31,10 +31,8 @@
 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:

Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Sat Jul 27 23:24:07 2019
@@ -46,10 +46,8 @@
 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':

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Sat Jul 27 23:24:07 2019
@@ -58,10 +58,8 @@ static mode_t ParsePermissionString(llvm
   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:

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Sat Jul 27 23:24:07 2019
@@ -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
 

Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Sat Jul 27 23:24:07 2019
@@ -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:

Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Sat Jul 27 23:24:07 2019
@@ -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:

Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSource.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSource.cpp Sat Jul 27 23:24:07 2019
@@ -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 {

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Sat Jul 27 23:24:07 2019
@@ -144,10 +144,8 @@ static constexpr OptionEnumValueElement
     {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
     {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 {

Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectThread.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectThread.cpp Sat Jul 27 23:24:07 2019
@@ -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 TriRun
   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 DuoRun
   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 : pub
 };
 
 // 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:

Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Sat Jul 27 23:24:07 2019
@@ -95,10 +95,8 @@ static bool WarnOnPotentialUnquotedUnsig
   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_ins
     "        '''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
 }
 
 #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:

Modified: lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp Sat Jul 27 23:24:07 2019
@@ -146,11 +146,8 @@ bool CommandObjectMultiwordWatchpoint::V
 
 // 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
 

Modified: lldb/trunk/source/Commands/CommandObjectWatchpointCommand.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpointCommand.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectWatchpointCommand.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectWatchpointCommand.cpp Sat Jul 27 23:24:07 2019
@@ -42,10 +42,8 @@ static constexpr OptionEnumValues Script
   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 {

Modified: lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp?rev=367186&r1=367185&r2=367186&view=diff
==============================================================================
--- lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp (original)
+++ lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp Sat Jul 27 23:24:07 2019
@@ -129,18 +129,21 @@ static void emitOption(Record *Option, r
 /// 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";
 }




More information about the lldb-commits mailing list