From 49bcfd802efb4212fe9d65970eed6ae51e0f8c00 Mon Sep 17 00:00:00 2001 From: Eugene Zelenko Date: Tue, 23 Feb 2016 01:43:44 +0000 Subject: [PATCH] Fix Clang-tidy modernize-use-nullptr and modernize-use-default warnings in some files in source/Commands; other minor fixes. llvm-svn: 261602 --- lldb/source/Commands/CommandObjectProcess.cpp | 273 ++++++++------------- lldb/source/Commands/CommandObjectRegister.cpp | 83 +++---- .../Commands/CommandObjectWatchpointCommand.cpp | 107 ++++---- 3 files changed, 178 insertions(+), 285 deletions(-) diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index a85ea17..cef99b7 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "CommandObjectProcess.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "CommandObjectProcess.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointSite.h" @@ -46,8 +45,9 @@ public: const char *new_process_action) : CommandObjectParsed (interpreter, name, help, syntax, flags), m_new_process_action (new_process_action) {} - - ~CommandObjectProcessLaunchOrAttach () override {} + + ~CommandObjectProcessLaunchOrAttach() override = default; + protected: bool StopProcessIfNecessary (Process *process, StateType &state, CommandReturnObject &result) @@ -81,7 +81,7 @@ protected: if (detach_error.Success()) { result.SetStatus (eReturnStatusSuccessFinishResult); - process = NULL; + process = nullptr; } else { @@ -95,7 +95,7 @@ protected: if (destroy_error.Success()) { result.SetStatus (eReturnStatusSuccessFinishResult); - process = NULL; + process = nullptr; } else { @@ -108,8 +108,10 @@ protected: } return result.Succeeded(); } + std::string m_new_process_action; }; + //------------------------------------------------------------------------- // CommandObjectProcessLaunch //------------------------------------------------------------------------- @@ -117,14 +119,13 @@ protected: class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach { public: - CommandObjectProcessLaunch (CommandInterpreter &interpreter) : - CommandObjectProcessLaunchOrAttach (interpreter, - "process launch", - "Launch the executable in the debugger.", - NULL, - eCommandRequiresTarget, - "restart"), + CommandObjectProcessLaunchOrAttach(interpreter, + "process launch", + "Launch the executable in the debugger.", + nullptr, + eCommandRequiresTarget, + "restart"), m_options (interpreter) { CommandArgumentEntry arg; @@ -141,10 +142,7 @@ public: m_arguments.push_back (arg); } - - ~CommandObjectProcessLaunch () override - { - } + ~CommandObjectProcessLaunch() override = default; int HandleArgumentCompletion (Args &input, @@ -159,14 +157,14 @@ public: std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eDiskFileCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::eDiskFileCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + nullptr, + word_complete, + matches); return matches.GetSize(); } @@ -189,10 +187,10 @@ protected: { Debugger &debugger = m_interpreter.GetDebugger(); Target *target = debugger.GetSelectedTarget().get(); - // If our listener is NULL, users aren't allows to launch + // If our listener is nullptr, users aren't allows to launch ModuleSP exe_module_sp = target->GetExecutableModule(); - if (exe_module_sp == NULL) + if (exe_module_sp == nullptr) { result.AppendError ("no file in target, create a debug target using the 'target create' command"); result.SetStatus (eReturnStatusFailed); @@ -305,15 +303,15 @@ protected: //OptionDefinition //CommandObjectProcessLaunch::CommandOptions::g_option_table[] = //{ -//{ SET1 | SET2 | SET3, false, "stop-at-entry", 's', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."}, -//{ SET1 , false, "stdin", 'i', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stdin for the process to ."}, -//{ SET1 , false, "stdout", 'o', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stdout for the process to ."}, -//{ SET1 , false, "stderr", 'e', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stderr for the process to ."}, -//{ SET1 | SET2 | SET3, false, "plugin", 'p', OptionParser::eRequiredArgument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, -//{ SET2 , false, "tty", 't', OptionParser::eOptionalArgument, NULL, 0, eArgTypeDirectoryName, "Start the process in a terminal. If is specified, look for a terminal whose name contains , else start the process in a new terminal."}, -//{ SET3, false, "no-stdio", 'n', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."}, -//{ SET1 | SET2 | SET3, false, "working-dir", 'w', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Set the current working directory to when running the inferior."}, -//{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } +//{ SET1 | SET2 | SET3, false, "stop-at-entry", 's', OptionParser::eNoArgument, nullptr, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."}, +//{ SET1 , false, "stdin", 'i', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Redirect stdin for the process to ."}, +//{ SET1 , false, "stdout", 'o', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Redirect stdout for the process to ."}, +//{ SET1 , false, "stderr", 'e', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Redirect stderr for the process to ."}, +//{ SET1 | SET2 | SET3, false, "plugin", 'p', OptionParser::eRequiredArgument, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, +//{ SET2 , false, "tty", 't', OptionParser::eOptionalArgument, nullptr, 0, eArgTypeDirectoryName, "Start the process in a terminal. If is specified, look for a terminal whose name contains , else start the process in a new terminal."}, +//{ SET3, false, "no-stdio", 'n', OptionParser::eNoArgument, nullptr, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."}, +//{ SET1 | SET2 | SET3, false, "working-dir", 'w', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Set the current working directory to when running the inferior."}, +//{ 0, false, nullptr, 0, 0, nullptr, 0, eArgTypeNone, nullptr } //}; // //#undef SET1 @@ -327,11 +325,9 @@ protected: class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach { public: - class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { @@ -339,9 +335,7 @@ public: OptionParsingStarting (); } - ~CommandOptions () override - { - } + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -428,7 +422,7 @@ public: // Look to see if there is a -P argument provided, and if so use that plugin, otherwise // use the default plugin. - const char *partial_name = NULL; + const char *partial_name = nullptr; partial_name = input.GetArgumentAtIndex(opt_arg_pos); PlatformSP platform_sp (m_interpreter.GetPlatform (true)); @@ -445,7 +439,7 @@ public: const size_t num_matches = process_infos.GetSize(); if (num_matches > 0) { - for (size_t i=0; i to launch."}, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +{ LLDB_OPT_SET_ALL, false, "continue",'c', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Immediately continue the process once attached."}, +{ LLDB_OPT_SET_ALL, false, "plugin", 'P', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, +{ LLDB_OPT_SET_1, false, "pid", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePid, "The process ID of an existing process to attach to."}, +{ LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeProcessName, "The name of the process to attach to."}, +{ LLDB_OPT_SET_2, false, "include-existing", 'i', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Include existing processes when doing attach -w."}, +{ LLDB_OPT_SET_2, false, "waitfor", 'w', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Wait for the process with to launch."}, +{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; //------------------------------------------------------------------------- @@ -632,7 +623,6 @@ CommandObjectProcessAttach::CommandOptions::g_option_table[] = class CommandObjectProcessContinue : public CommandObjectParsed { public: - CommandObjectProcessContinue (CommandInterpreter &interpreter) : CommandObjectParsed (interpreter, "process continue", @@ -646,17 +636,12 @@ public: { } - - ~CommandObjectProcessContinue () override - { - } + ~CommandObjectProcessContinue() override = default; protected: - class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { @@ -664,9 +649,7 @@ protected: OptionParsingStarting (); } - ~CommandOptions () override - { - } + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -814,15 +797,14 @@ protected: } CommandOptions m_options; - }; OptionDefinition CommandObjectProcessContinue::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_ALL, false, "ignore-count",'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeUnsignedInteger, +{ LLDB_OPT_SET_ALL, false, "ignore-count",'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger, "Ignore crossings of the breakpoint (if it exists) for the currently selected thread."}, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; //------------------------------------------------------------------------- @@ -836,16 +818,13 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options (interpreter) { OptionParsingStarting (); } - ~CommandOptions () override - { - } + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -908,9 +887,7 @@ public: { } - ~CommandObjectProcessDetach () override - { - } + ~CommandObjectProcessDetach() override = default; Options * GetOptions () override @@ -918,7 +895,6 @@ public: return &m_options; } - protected: bool DoExecute (Args& command, CommandReturnObject &result) override @@ -929,10 +905,7 @@ protected: if (m_options.m_keep_stopped == eLazyBoolCalculate) { // Check the process default: - if (process->GetDetachKeepsStopped()) - keep_stopped = true; - else - keep_stopped = false; + keep_stopped = process->GetDetachKeepsStopped(); } else if (m_options.m_keep_stopped == eLazyBoolYes) keep_stopped = true; @@ -959,8 +932,8 @@ protected: OptionDefinition CommandObjectProcessDetach::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." }, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +{ LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." }, +{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; //------------------------------------------------------------------------- @@ -971,22 +944,18 @@ CommandObjectProcessDetach::CommandOptions::g_option_table[] = class CommandObjectProcessConnect : public CommandObjectParsed { public: - class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { // Keep default values of all options in one place: OptionParsingStarting () OptionParsingStarting (); } - - ~CommandOptions () override - { - } - + + ~CommandOptions() override = default; + Error SetOptionValue (uint32_t option_idx, const char *option_arg) override { @@ -1036,12 +1005,9 @@ public: m_options (interpreter) { } - - ~CommandObjectProcessConnect () override - { - } - + ~CommandObjectProcessConnect() override = default; + Options * GetOptions () override { @@ -1061,7 +1027,6 @@ protected: return false; } - Process *process = m_exe_ctx.GetProcessPtr(); if (process && process->IsAlive()) { @@ -1098,8 +1063,8 @@ protected: OptionDefinition CommandObjectProcessConnect::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, - { 0, false, NULL, 0 , 0, NULL, NULL, 0, eArgTypeNone, NULL } + { LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, + { 0, false, nullptr, 0 , 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; //------------------------------------------------------------------------- @@ -1110,7 +1075,6 @@ CommandObjectProcessConnect::CommandOptions::g_option_table[] = class CommandObjectProcessPlugin : public CommandObjectProxy { public: - CommandObjectProcessPlugin (CommandInterpreter &interpreter) : CommandObjectProxy (interpreter, "process plugin", @@ -1119,10 +1083,8 @@ public: 0) { } - - ~CommandObjectProcessPlugin () override - { - } + + ~CommandObjectProcessPlugin() override = default; CommandObject * GetProxyCommandObject() override @@ -1130,11 +1092,10 @@ public: Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process) return process->GetPluginCommandObject(); - return NULL; + return nullptr; } }; - //------------------------------------------------------------------------- // CommandObjectProcessLoad //------------------------------------------------------------------------- @@ -1153,7 +1114,7 @@ public: OptionParsingStarting (); } - ~CommandOptions () override = default; + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -1208,7 +1169,7 @@ public: { } - ~CommandObjectProcessLoad () override = default; + ~CommandObjectProcessLoad() override = default; Options * GetOptions () override @@ -1223,7 +1184,7 @@ protected: Process *process = m_exe_ctx.GetProcessPtr(); const size_t argc = command.GetArgumentCount(); - for (uint32_t i=0; iGetTarget().GetPlatform(); @@ -1293,9 +1254,7 @@ public: { } - ~CommandObjectProcessUnload () override - { - } + ~CommandObjectProcessUnload() override = default; protected: bool @@ -1305,7 +1264,7 @@ protected: const size_t argc = command.GetArgumentCount(); - for (uint32_t i=0; i 0) { - for (size_t i=0; iGetUInt64Value (UINT32_MAX, NULL); + set_idx = m_command_options.set_indexes[i]->GetUInt64Value(UINT32_MAX, nullptr); if (set_idx < reg_ctx->GetRegisterSetCount()) { if (!DumpRegisterSet (m_exe_ctx, strm, reg_ctx, set_idx)) @@ -234,7 +231,7 @@ protected: else { const char *arg_cstr; - for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx) + for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx) { // in most LLDB commands we accept $rbx as the name for register RBX - and here we would // reject it and non-existant. we should be more consistent towards the user and allow them @@ -269,12 +266,9 @@ protected: alternate_name (false, false) { } - - ~CommandOptions () override - { - } - - + + ~CommandOptions() override = default; + uint32_t GetNumDefinitions () override; @@ -350,9 +344,9 @@ protected: const OptionDefinition CommandObjectRegisterRead::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "alternate", 'A', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone , "Display register names using the alternate register name if there is one."}, - { LLDB_OPT_SET_1 , false, "set" , 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeIndex , "Specify which register sets to dump by index."}, - { LLDB_OPT_SET_2 , false, "all" , 'a', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone , "Show all register sets."}, + { LLDB_OPT_SET_ALL, false, "alternate", 'A', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone , "Display register names using the alternate register name if there is one."}, + { LLDB_OPT_SET_1 , false, "set" , 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeIndex , "Specify which register sets to dump by index."}, + { LLDB_OPT_SET_2 , false, "all" , 'a', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone , "Show all register sets."}, }; uint32_t @@ -361,7 +355,6 @@ CommandObjectRegisterRead::CommandOptions::GetNumDefinitions () return llvm::array_lengthof(g_option_table); } - //---------------------------------------------------------------------- // "register write" //---------------------------------------------------------------------- @@ -369,14 +362,14 @@ class CommandObjectRegisterWrite : public CommandObjectParsed { public: CommandObjectRegisterWrite (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "register write", - "Modify a single register value.", - NULL, - eCommandRequiresFrame | - eCommandRequiresRegContext | - eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused) + CommandObjectParsed(interpreter, + "register write", + "Modify a single register value.", + nullptr, + eCommandRequiresFrame | + eCommandRequiresRegContext | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused) { CommandArgumentEntry arg1; CommandArgumentEntry arg2; @@ -402,9 +395,7 @@ public: m_arguments.push_back (arg2); } - ~CommandObjectRegisterWrite () override - { - } + ~CommandObjectRegisterWrite() override = default; protected: bool @@ -422,8 +413,7 @@ protected: { const char *reg_name = command.GetArgumentAtIndex(0); const char *value_str = command.GetArgumentAtIndex(1); - - + // in most LLDB commands we accept $rbx as the name for register RBX - and here we would // reject it and non-existant. we should be more consistent towards the user and allow them // to say reg write $rbx - internally, however, we should be strict and not allow ourselves @@ -474,7 +464,6 @@ protected: } }; - //---------------------------------------------------------------------- // CommandObjectRegister constructor //---------------------------------------------------------------------- @@ -488,10 +477,4 @@ CommandObjectRegister::CommandObjectRegister(CommandInterpreter &interpreter) : LoadSubCommand ("write", CommandObjectSP (new CommandObjectRegisterWrite (interpreter))); } - -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -CommandObjectRegister::~CommandObjectRegister() -{ -} +CommandObjectRegister::~CommandObjectRegister() = default; diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp index 2fa849f..91e29ee 100644 --- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp @@ -9,11 +9,12 @@ // C Includes // C++ Includes +#include - +// Other libraries and framework includes +// Project includes #include "CommandObjectWatchpointCommand.h" #include "CommandObjectWatchpoint.h" - #include "lldb/Core/IOHandler.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -23,8 +24,6 @@ #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/State.h" -#include - using namespace lldb; using namespace lldb_private; @@ -32,18 +31,16 @@ using namespace lldb_private; // CommandObjectWatchpointCommandAdd //------------------------------------------------------------------------- - class CommandObjectWatchpointCommandAdd : public CommandObjectParsed, public IOHandlerDelegateMultiline { public: - CommandObjectWatchpointCommandAdd (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "add", - "Add a set of commands to a watchpoint, to be executed whenever the watchpoint is hit.", - NULL), + CommandObjectParsed(interpreter, + "add", + "Add a set of commands to a watchpoint, to be executed whenever the watchpoint is hit.", + nullptr), IOHandlerDelegateMultiline("DONE", IOHandlerDelegate::Completion::LLDBCommand), m_options (interpreter) { @@ -169,7 +166,7 @@ are no syntax errors may indicate that a function was declared but never called. m_arguments.push_back (arg); } - ~CommandObjectWatchpointCommandAdd () override {} + ~CommandObjectWatchpointCommandAdd() override = default; Options * GetOptions () override @@ -187,8 +184,7 @@ are no syntax errors may indicate that a function was declared but never called. output_sp->Flush(); } } - - + void IOHandlerInputComplete (IOHandler &io_handler, std::string &line) override { @@ -199,7 +195,7 @@ are no syntax errors may indicate that a function was declared but never called. if (wp_options) { std::unique_ptr data_ap(new WatchpointOptions::CommandData()); - if (data_ap.get()) + if (data_ap) { data_ap->user_source.SplitIntoLines(line); BatonSP baton_sp (new WatchpointOptions::CommandBaton (data_ap.release())); @@ -234,8 +230,6 @@ are no syntax errors may indicate that a function was declared but never called. BatonSP baton_sp (new WatchpointOptions::CommandBaton (data_ap.release())); wp_options->SetCallback (WatchpointOptionsCallbackFunction, baton_sp); - - return; } static bool @@ -244,10 +238,9 @@ are no syntax errors may indicate that a function was declared but never called. lldb::user_id_t watch_id) { bool ret_value = true; - if (baton == NULL) + if (baton == nullptr) return true; - - + WatchpointOptions::CommandData *data = (WatchpointOptions::CommandData *) baton; StringList &commands = data->user_source; @@ -288,7 +281,6 @@ are no syntax errors may indicate that a function was declared but never called. class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options (interpreter), m_use_commands (false), @@ -300,7 +292,7 @@ are no syntax errors may indicate that a function was declared but never called. { } - ~CommandOptions () override {} + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -321,14 +313,8 @@ are no syntax errors may indicate that a function was declared but never called. eScriptLanguageNone, error); - if (m_script_language == eScriptLanguagePython || m_script_language == eScriptLanguageDefault) - { - m_use_script_language = true; - } - else - { - m_use_script_language = false; - } + m_use_script_language = + (m_script_language == eScriptLanguagePython || m_script_language == eScriptLanguageDefault); break; case 'e': @@ -341,11 +327,9 @@ are no syntax errors may indicate that a function was declared but never called. break; case 'F': - { - m_use_one_liner = false; - m_use_script_language = true; - m_function_name.assign(option_arg); - } + m_use_one_liner = false; + m_use_script_language = true; + m_function_name.assign(option_arg); break; default: @@ -353,6 +337,7 @@ are no syntax errors may indicate that a function was declared but never called. } return error; } + void OptionParsingStarting () override { @@ -395,7 +380,7 @@ protected: { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - if (target == NULL) + if (target == nullptr) { result.AppendError ("There is not a current executable; there are no watchpoints to which to add commands"); result.SetStatus (eReturnStatusFailed); @@ -412,7 +397,7 @@ protected: return false; } - if (m_options.m_use_script_language == false && m_options.m_function_name.size()) + if (!m_options.m_use_script_language && !m_options.m_function_name.empty()) { result.AppendError ("need to enable scripting to have a function run as a watchpoint command"); result.SetStatus (eReturnStatusFailed); @@ -436,11 +421,11 @@ protected: { Watchpoint *wp = target->GetWatchpointList().FindByID (cur_wp_id).get(); // Sanity check wp first. - if (wp == NULL) continue; + if (wp == nullptr) continue; WatchpointOptions *wp_options = wp->GetOptions(); // Skip this watchpoint if wp_options is not good. - if (wp_options == NULL) continue; + if (wp_options == nullptr) continue; // If we are using script language, get the script interpreter // in order to set or collect command callback. Otherwise, call @@ -456,7 +441,7 @@ protected: // Special handling for using a Python function by name // instead of extending the watchpoint callback data structures, we just automatize // what the user would do manually: make their watchpoint command be a function call - else if (m_options.m_function_name.size()) + else if (!m_options.m_function_name.empty()) { std::string oneliner(m_options.m_function_name); oneliner += "(frame, wp, internal_dict)"; @@ -489,7 +474,6 @@ private: CommandOptions m_options; }; - // FIXME: "script-type" needs to have its contents determined dynamically, so somebody can add a new scripting // language to lldb and have it pickable here without having to change this enumeration by hand and rebuild lldb proper. @@ -499,25 +483,25 @@ g_script_option_enumeration[4] = { eScriptLanguageNone, "command", "Commands are in the lldb command interpreter language"}, { eScriptLanguagePython, "python", "Commands are in the Python language."}, { eSortOrderByName, "default-script", "Commands are in the default scripting language."}, - { 0, NULL, NULL } + { 0, nullptr, nullptr } }; OptionDefinition CommandObjectWatchpointCommandAdd::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOneLiner, + { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOneLiner, "Specify a one-line watchpoint command inline. Be sure to surround it with quotes." }, - { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, + { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Specify whether watchpoint command execution should terminate on error." }, - { LLDB_OPT_SET_ALL, false, "script-type", 's', OptionParser::eRequiredArgument, NULL, g_script_option_enumeration, 0, eArgTypeNone, + { LLDB_OPT_SET_ALL, false, "script-type", 's', OptionParser::eRequiredArgument, nullptr, g_script_option_enumeration, 0, eArgTypeNone, "Specify the language for the commands - if none is specified, the lldb command interpreter will be used."}, - { LLDB_OPT_SET_2, false, "python-function", 'F', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonFunction, + { LLDB_OPT_SET_2, false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePythonFunction, "Give the name of a Python function to run as command for this watchpoint. Be sure to give a module name if appropriate."}, - { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } + { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; //------------------------------------------------------------------------- @@ -528,10 +512,10 @@ class CommandObjectWatchpointCommandDelete : public CommandObjectParsed { public: CommandObjectWatchpointCommandDelete (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "delete", - "Delete the set of commands from a watchpoint.", - NULL) + CommandObjectParsed(interpreter, + "delete", + "Delete the set of commands from a watchpoint.", + nullptr) { CommandArgumentEntry arg; CommandArgumentData wp_id_arg; @@ -547,8 +531,7 @@ public: m_arguments.push_back (arg); } - - ~CommandObjectWatchpointCommandDelete () override {} + ~CommandObjectWatchpointCommandDelete() override = default; protected: bool @@ -556,7 +539,7 @@ protected: { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - if (target == NULL) + if (target == nullptr) { result.AppendError ("There is not a current executable; there are no watchpoints from which to delete commands"); result.SetStatus (eReturnStatusFailed); @@ -619,10 +602,10 @@ class CommandObjectWatchpointCommandList : public CommandObjectParsed { public: CommandObjectWatchpointCommandList (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "list", - "List the script or set of commands to be executed when the watchpoint is hit.", - NULL) + CommandObjectParsed(interpreter, + "list", + "List the script or set of commands to be executed when the watchpoint is hit.", + nullptr) { CommandArgumentEntry arg; CommandArgumentData wp_id_arg; @@ -638,7 +621,7 @@ public: m_arguments.push_back (arg); } - ~CommandObjectWatchpointCommandList () override {} + ~CommandObjectWatchpointCommandList() override = default; protected: bool @@ -646,7 +629,7 @@ protected: { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - if (target == NULL) + if (target == nullptr) { result.AppendError ("There is not a current executable; there are no watchpoints for which to list commands"); result.SetStatus (eReturnStatusFailed); @@ -744,8 +727,4 @@ CommandObjectWatchpointCommand::CommandObjectWatchpointCommand (CommandInterpret LoadSubCommand ("list", list_command_object); } -CommandObjectWatchpointCommand::~CommandObjectWatchpointCommand () -{ -} - - +CommandObjectWatchpointCommand::~CommandObjectWatchpointCommand() = default; -- 2.7.4