diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-02-24 02:05:55 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-02-24 02:05:55 +0000 |
commit | 3f18ea0e38f95a28309c55ba2a6acb84437cc526 (patch) | |
tree | 1d2408daa991a4a91632dc48a8473a3bbca30ce0 /lldb/source/Commands/CommandObjectSettings.cpp | |
parent | ee7023f79af7db796bc6de5f095a84336d665aa4 (diff) | |
download | llvm-3f18ea0e38f95a28309c55ba2a6acb84437cc526.zip llvm-3f18ea0e38f95a28309c55ba2a6acb84437cc526.tar.gz llvm-3f18ea0e38f95a28309c55ba2a6acb84437cc526.tar.bz2 |
Fix Clang-tidy modernize-use-nullptr and modernize-use-default warnings in some files in source/Commands; other minor fixes.
llvm-svn: 261716
Diffstat (limited to 'lldb/source/Commands/CommandObjectSettings.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectSettings.cpp | 290 |
1 files changed, 142 insertions, 148 deletions
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index 890d770..b2c4743 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -12,6 +12,8 @@ // C Includes // C++ Includes // Other libraries and framework includes +#include "llvm/ADT/StringRef.h" + // Project includes #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -20,7 +22,6 @@ using namespace lldb; using namespace lldb_private; -#include "llvm/ADT/StringRef.h" //------------------------------------------------------------------------- // CommandObjectSettingsSet @@ -30,10 +31,10 @@ class CommandObjectSettingsSet : public CommandObjectRaw { public: CommandObjectSettingsSet (CommandInterpreter &interpreter) : - CommandObjectRaw (interpreter, - "settings set", - "Set or change the value of a single debugger setting variable.", - NULL), + CommandObjectRaw(interpreter, + "settings set", + "Set or change the value of a single debugger setting variable.", + nullptr), m_options (interpreter) { CommandArgumentEntry arg1; @@ -82,8 +83,7 @@ insert-before or insert-after." } - - ~CommandObjectSettingsSet () override {} + ~CommandObjectSettingsSet() override = default; // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString. bool @@ -98,14 +98,13 @@ insert-before or insert-after." class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options (interpreter), m_global (false) { } - ~CommandOptions () override {} + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -160,7 +159,7 @@ insert-before or insert-after." std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); const size_t argc = input.GetArgumentCount(); - const char *arg = NULL; + const char *arg = nullptr; int setting_var_idx; for (setting_var_idx = 1; setting_var_idx < static_cast<int>(argc); ++setting_var_idx) @@ -172,14 +171,14 @@ insert-before or insert-after." if (cursor_index == setting_var_idx) { // Attempting to complete setting variable name - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + nullptr, + word_complete, + matches); } else { @@ -231,7 +230,7 @@ protected: } const char *var_name = cmd_args.GetArgumentAtIndex (0); - if ((var_name == NULL) || (var_name[0] == '\0')) + if ((var_name == nullptr) || (var_name[0] == '\0')) { result.AppendError ("'settings set' command requires a valid variable name"); result.SetStatus (eReturnStatusFailed); @@ -246,10 +245,10 @@ protected: Error error; if (m_options.m_global) { - error = m_interpreter.GetDebugger().SetPropertyValue (NULL, - eVarSetOperationAssign, - var_name, - var_value_cstr); + error = m_interpreter.GetDebugger().SetPropertyValue(nullptr, + eVarSetOperationAssign, + var_name, + var_value_cstr); } if (error.Success()) @@ -280,6 +279,7 @@ protected: return result.Succeeded(); } + private: CommandOptions m_options; }; @@ -287,11 +287,10 @@ private: OptionDefinition CommandObjectSettingsSet::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_2, false, "global", 'g', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Apply the new value to the global default value." }, - { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } + { LLDB_OPT_SET_2, false, "global", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Apply the new value to the global default value." }, + { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; - //------------------------------------------------------------------------- // CommandObjectSettingsShow -- Show current values //------------------------------------------------------------------------- @@ -300,10 +299,10 @@ class CommandObjectSettingsShow : public CommandObjectParsed { public: CommandObjectSettingsShow (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "settings show", - "Show the specified internal debugger setting variable and its value, or show all the currently set variables and their values, if nothing is specified.", - NULL) + CommandObjectParsed(interpreter, + "settings show", + "Show the specified internal debugger setting variable and its value, or show all the currently set variables and their values, if nothing is specified.", + nullptr) { CommandArgumentEntry arg1; CommandArgumentData var_name_arg; @@ -319,8 +318,7 @@ public: m_arguments.push_back (arg1); } - ~CommandObjectSettingsShow () override {} - + ~CommandObjectSettingsShow() override = default; int HandleArgumentCompletion (Args &input, @@ -334,14 +332,14 @@ public: { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + nullptr, + word_complete, + matches); return matches.GetSize(); } @@ -354,7 +352,7 @@ protected: const size_t argc = args.GetArgumentCount (); if (argc > 0) { - for (size_t i=0; i<argc; ++i) + for (size_t i = 0; i < argc; ++i) { const char *property_path = args.GetArgumentAtIndex (i); @@ -387,10 +385,10 @@ class CommandObjectSettingsList : public CommandObjectParsed { public: CommandObjectSettingsList (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "settings list", - "List and describe all the internal debugger settings variables that are available to the user to 'set' or 'show', or describe a particular variable or set of variables (by specifying the variable name or a common prefix).", - NULL) + CommandObjectParsed(interpreter, + "settings list", + "List and describe all the internal debugger settings variables that are available to the user to 'set' or 'show', or describe a particular variable or set of variables (by specifying the variable name or a common prefix).", + nullptr) { CommandArgumentEntry arg; CommandArgumentData var_name_arg; @@ -411,7 +409,7 @@ public: m_arguments.push_back (arg); } - ~CommandObjectSettingsList () override {} + ~CommandObjectSettingsList() override = default; int HandleArgumentCompletion (Args &input, @@ -425,14 +423,14 @@ public: { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + nullptr, + word_complete, + matches); return matches.GetSize(); } @@ -448,7 +446,7 @@ protected: { const bool dump_qualified_name = true; - for (size_t i=0; i<argc; ++i) + for (size_t i = 0; i < argc; ++i) { const char *property_path = args.GetArgumentAtIndex (i); @@ -482,10 +480,10 @@ class CommandObjectSettingsRemove : public CommandObjectRaw { public: CommandObjectSettingsRemove (CommandInterpreter &interpreter) : - CommandObjectRaw (interpreter, - "settings remove", - "Remove the specified element from an array or dictionary settings variable.", - NULL) + CommandObjectRaw(interpreter, + "settings remove", + "Remove the specified element from an array or dictionary settings variable.", + nullptr) { CommandArgumentEntry arg1; CommandArgumentEntry arg2; @@ -517,7 +515,7 @@ public: m_arguments.push_back (arg2); } - ~CommandObjectSettingsRemove () override {} + ~CommandObjectSettingsRemove() override = default; int HandleArgumentCompletion (Args &input, @@ -533,14 +531,14 @@ public: // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + nullptr, + word_complete, + matches); return matches.GetSize(); } @@ -566,7 +564,7 @@ protected: } const char *var_name = cmd_args.GetArgumentAtIndex (0); - if ((var_name == NULL) || (var_name[0] == '\0')) + if ((var_name == nullptr) || (var_name[0] == '\0')) { result.AppendError ("'settings set' command requires a valid variable name"); result.SetStatus (eReturnStatusFailed); @@ -601,10 +599,10 @@ class CommandObjectSettingsReplace : public CommandObjectRaw { public: CommandObjectSettingsReplace (CommandInterpreter &interpreter) : - CommandObjectRaw (interpreter, - "settings replace", - "Replace the specified element from an internal debugger settings array or dictionary variable with the specified new value.", - NULL) + CommandObjectRaw(interpreter, + "settings replace", + "Replace the specified element from an internal debugger settings array or dictionary variable with the specified new value.", + nullptr) { CommandArgumentEntry arg1; CommandArgumentEntry arg2; @@ -646,8 +644,7 @@ public: m_arguments.push_back (arg3); } - - ~CommandObjectSettingsReplace () override {} + ~CommandObjectSettingsReplace() override = default; // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString. bool @@ -667,14 +664,14 @@ public: // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + nullptr, + word_complete, + matches); return matches.GetSize(); } @@ -687,14 +684,13 @@ protected: Args cmd_args(command); const char *var_name = cmd_args.GetArgumentAtIndex (0); - if ((var_name == NULL) || (var_name[0] == '\0')) + if ((var_name == nullptr) || (var_name[0] == '\0')) { result.AppendError ("'settings replace' command requires a valid variable name; No value supplied"); result.SetStatus (eReturnStatusFailed); return false; } - // Split the raw command into var_name, index_value, and value triple. llvm::StringRef raw_str(command); std::string var_value_string = raw_str.split(var_name).second.str(); @@ -728,10 +724,10 @@ class CommandObjectSettingsInsertBefore : public CommandObjectRaw { public: CommandObjectSettingsInsertBefore (CommandInterpreter &interpreter) : - CommandObjectRaw (interpreter, - "settings insert-before", - "Insert value(s) into an internal debugger settings array variable, immediately before the specified element.", - NULL) + CommandObjectRaw(interpreter, + "settings insert-before", + "Insert value(s) into an internal debugger settings array variable, immediately before the specified element.", + nullptr) { CommandArgumentEntry arg1; CommandArgumentEntry arg2; @@ -767,7 +763,7 @@ public: m_arguments.push_back (arg3); } - ~CommandObjectSettingsInsertBefore () override {} + ~CommandObjectSettingsInsertBefore() override = default; // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString. bool @@ -787,14 +783,14 @@ public: // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + nullptr, + word_complete, + matches); return matches.GetSize(); } @@ -816,7 +812,7 @@ protected: } const char *var_name = cmd_args.GetArgumentAtIndex (0); - if ((var_name == NULL) || (var_name[0] == '\0')) + if ((var_name == nullptr) || (var_name[0] == '\0')) { result.AppendError ("'settings insert-before' command requires a valid variable name; No value supplied"); result.SetStatus (eReturnStatusFailed); @@ -851,10 +847,10 @@ class CommandObjectSettingsInsertAfter : public CommandObjectRaw { public: CommandObjectSettingsInsertAfter (CommandInterpreter &interpreter) : - CommandObjectRaw (interpreter, - "settings insert-after", - "Insert value(s) into an internal debugger settings array variable, immediately after the specified element.", - NULL) + CommandObjectRaw(interpreter, + "settings insert-after", + "Insert value(s) into an internal debugger settings array variable, immediately after the specified element.", + nullptr) { CommandArgumentEntry arg1; CommandArgumentEntry arg2; @@ -890,7 +886,7 @@ public: m_arguments.push_back (arg3); } - ~CommandObjectSettingsInsertAfter () override {} + ~CommandObjectSettingsInsertAfter() override = default; // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString. bool @@ -910,14 +906,14 @@ public: // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + nullptr, + word_complete, + matches); return matches.GetSize(); } @@ -939,7 +935,7 @@ protected: } const char *var_name = cmd_args.GetArgumentAtIndex (0); - if ((var_name == NULL) || (var_name[0] == '\0')) + if ((var_name == nullptr) || (var_name[0] == '\0')) { result.AppendError ("'settings insert-after' command requires a valid variable name; No value supplied"); result.SetStatus (eReturnStatusFailed); @@ -974,10 +970,10 @@ class CommandObjectSettingsAppend : public CommandObjectRaw { public: CommandObjectSettingsAppend (CommandInterpreter &interpreter) : - CommandObjectRaw (interpreter, - "settings append", - "Append a new value to the end of an internal debugger settings array, dictionary or string variable.", - NULL) + CommandObjectRaw(interpreter, + "settings append", + "Append a new value to the end of an internal debugger settings array, dictionary or string variable.", + nullptr) { CommandArgumentEntry arg1; CommandArgumentEntry arg2; @@ -1003,7 +999,7 @@ public: m_arguments.push_back (arg2); } - ~CommandObjectSettingsAppend () override {} + ~CommandObjectSettingsAppend() override = default; // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString. bool @@ -1023,14 +1019,14 @@ public: // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + nullptr, + word_complete, + matches); return matches.GetSize(); } @@ -1051,7 +1047,7 @@ protected: } const char *var_name = cmd_args.GetArgumentAtIndex (0); - if ((var_name == NULL) || (var_name[0] == '\0')) + if ((var_name == nullptr) || (var_name[0] == '\0')) { result.AppendError ("'settings append' command requires a valid variable name; No value supplied"); result.SetStatus (eReturnStatusFailed); @@ -1089,10 +1085,10 @@ class CommandObjectSettingsClear : public CommandObjectParsed { public: CommandObjectSettingsClear (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "settings clear", - "Erase all the contents of an internal debugger settings variables; this is only valid for variables with clearable types, i.e. strings, arrays or dictionaries.", - NULL) + CommandObjectParsed(interpreter, + "settings clear", + "Erase all the contents of an internal debugger settings variables; this is only valid for variables with clearable types, i.e. strings, arrays or dictionaries.", + nullptr) { CommandArgumentEntry arg; CommandArgumentData var_name_arg; @@ -1108,7 +1104,7 @@ public: m_arguments.push_back (arg); } - ~CommandObjectSettingsClear () override {} + ~CommandObjectSettingsClear() override = default; int HandleArgumentCompletion (Args &input, @@ -1124,14 +1120,14 @@ public: // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eSettingsNameCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + nullptr, + word_complete, + matches); return matches.GetSize(); } @@ -1151,17 +1147,17 @@ protected: } const char *var_name = command.GetArgumentAtIndex (0); - if ((var_name == NULL) || (var_name[0] == '\0')) + if ((var_name == nullptr) || (var_name[0] == '\0')) { result.AppendError ("'settings clear' command requires a valid variable name; No value supplied"); result.SetStatus (eReturnStatusFailed); return false; } - Error error (m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx, - eVarSetOperationClear, - var_name, - NULL)); + Error error(m_interpreter.GetDebugger().SetPropertyValue(&m_exe_ctx, + eVarSetOperationClear, + var_name, + nullptr)); if (error.Fail()) { result.AppendError (error.AsCString()); @@ -1194,6 +1190,4 @@ CommandObjectMultiwordSettings::CommandObjectMultiwordSettings (CommandInterpret LoadSubCommand ("clear", CommandObjectSP (new CommandObjectSettingsClear (interpreter))); } -CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings () -{ -} +CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings() = default; |