From 1f0f5b5b9eeaea93126583b40070091baf3bc92d Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Thu, 22 Sep 2016 20:22:55 +0000 Subject: Convert option tables to ArrayRefs. This change is very mechanical. All it does is change the signature of `Options::GetDefinitions()` and `OptionGroup:: GetDefinitions()` to return an `ArrayRef` instead of a `const OptionDefinition *`. In the case of the former, it deletes the sentinel entry from every table, and in the case of the latter, it removes the `GetNumDefinitions()` method from the interface. These are no longer necessary as `ArrayRef` carries its own length. In the former case, iteration was done by using a sentinel entry, so there was no knowledge of length. Because of this the individual option tables were allowed to be defined below the corresponding class (after all, only a pointer was needed). Now, however, the length must be known at compile time to construct the `ArrayRef`, and as a result it is necessary to move every option table before its corresponding class. This results in this CL looking very big, but in terms of substance there is not much here. Differential revision: https://reviews.llvm.org/D24834 llvm-svn: 282188 --- lldb/source/Commands/CommandObjectWatchpoint.cpp | 89 +++++++++++------------- 1 file changed, 39 insertions(+), 50 deletions(-) (limited to 'lldb/source/Commands/CommandObjectWatchpoint.cpp') diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index 7ff4cce7457..83eb1dd9b7f 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -152,6 +152,20 @@ bool CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs( //------------------------------------------------------------------------- // CommandObjectWatchpointList //------------------------------------------------------------------------- + +//------------------------------------------------------------------------- +// CommandObjectWatchpointList::Options +//------------------------------------------------------------------------- +#pragma mark List::CommandOptions + +static OptionDefinition g_watchpoint_list_options[] = { + // clang-format off + { LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Give a brief description of the watchpoint (no location info)." }, + { LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Give a full description of the watchpoint and its locations." }, + { LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Explain everything we know about the watchpoint (for debugging debugger bugs)." } + // clang-format on +}; + #pragma mark List class CommandObjectWatchpointList : public CommandObjectParsed { @@ -211,11 +225,9 @@ public: m_level = lldb::eDescriptionLevelFull; } - const OptionDefinition *GetDefinitions() override { return g_option_table; } - - // Options table: Required for subclasses of Options. - - static OptionDefinition g_option_table[]; + llvm::ArrayRef GetDefinitions() override { + return g_watchpoint_list_options; + } // Instance variables to hold the values for command options. @@ -290,21 +302,6 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- -// CommandObjectWatchpointList::Options -//------------------------------------------------------------------------- -#pragma mark List::CommandOptions - -OptionDefinition CommandObjectWatchpointList::CommandOptions::g_option_table[] = - { - // clang-format off - {LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Give a brief description of the watchpoint (no location info)."}, - {LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Give a full description of the watchpoint and its locations."}, - {LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Explain everything we know about the watchpoint (for debugging debugger bugs)."}, - {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr} - // clang-format on -}; - //------------------------------------------------------------------------- // CommandObjectWatchpointEnable //------------------------------------------------------------------------- @@ -531,6 +528,13 @@ protected: // CommandObjectWatchpointIgnore //------------------------------------------------------------------------- +#pragma mark Ignore::CommandOptions +static OptionDefinition g_watchpoint_ignore_options[] = { + // clang-format off + { LLDB_OPT_SET_ALL, true, "ignore-count", 'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount, "Set the number of times this watchpoint is skipped before stopping." } + // clang-format on +}; + class CommandObjectWatchpointIgnore : public CommandObjectParsed { public: CommandObjectWatchpointIgnore(CommandInterpreter &interpreter) @@ -582,11 +586,9 @@ public: m_ignore_count = 0; } - const OptionDefinition *GetDefinitions() override { return g_option_table; } - - // Options table: Required for subclasses of Options. - - static OptionDefinition g_option_table[]; + llvm::ArrayRef GetDefinitions() override { + return g_watchpoint_ignore_options; + } // Instance variables to hold the values for command options. @@ -644,19 +646,18 @@ private: CommandOptions m_options; }; -#pragma mark Ignore::CommandOptions - -OptionDefinition - CommandObjectWatchpointIgnore::CommandOptions::g_option_table[] = { - // clang-format off - {LLDB_OPT_SET_ALL, true, "ignore-count", 'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount, "Set the number of times this watchpoint is skipped before stopping."}, - {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr} - // clang-format on -}; - //------------------------------------------------------------------------- // CommandObjectWatchpointModify //------------------------------------------------------------------------- + +#pragma mark Modify::CommandOptions + +static OptionDefinition g_watchpoint_modify_options[] = { + // clang-format off + { LLDB_OPT_SET_ALL, false, "condition", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeExpression, "The watchpoint stops only if this condition expression evaluates to true." } + // clang-format on +}; + #pragma mark Modify class CommandObjectWatchpointModify : public CommandObjectParsed { @@ -716,11 +717,9 @@ public: m_condition_passed = false; } - const OptionDefinition *GetDefinitions() override { return g_option_table; } - - // Options table: Required for subclasses of Options. - - static OptionDefinition g_option_table[]; + llvm::ArrayRef GetDefinitions() override { + return g_watchpoint_modify_options; + } // Instance variables to hold the values for command options. @@ -781,16 +780,6 @@ private: CommandOptions m_options; }; -#pragma mark Modify::CommandOptions - -OptionDefinition - CommandObjectWatchpointModify::CommandOptions::g_option_table[] = { - // clang-format off - {LLDB_OPT_SET_ALL, false, "condition", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeExpression, "The watchpoint stops only if this condition expression evaluates to true."}, - {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr} - // clang-format on -}; - //------------------------------------------------------------------------- // CommandObjectWatchpointSetVariable //------------------------------------------------------------------------- -- cgit v1.2.3