From: Eugene Zelenko Date: Sat, 20 Feb 2016 00:58:29 +0000 (+0000) Subject: Fix Clang-tidy modernize-use-nullptr and modernize-use-default warnings in some files... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=26cac3af0b83c59a201d91c96e2810e3b2554704;p=platform%2Fupstream%2Fllvm.git Fix Clang-tidy modernize-use-nullptr and modernize-use-default warnings in some files in source/Commands; other minor fixes. llvm-svn: 261389 --- diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index 100d869..9e01fe8 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "CommandObjectDisassemble.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "CommandObjectDisassemble.h" #include "lldb/Core/AddressRange.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/Module.h" @@ -54,9 +53,7 @@ CommandObjectDisassemble::CommandOptions::CommandOptions (CommandInterpreter &in OptionParsingStarting(); } -CommandObjectDisassemble::CommandOptions::~CommandOptions () -{ -} +CommandObjectDisassemble::CommandOptions::~CommandOptions() = default; Error CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) @@ -105,6 +102,7 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, c some_location_specified = true; } break; + case 'n': func_name.assign (option_arg); some_location_specified = true; @@ -139,6 +137,7 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, c error.SetErrorStringWithFormat("Disassembler flavors are currently only supported for x86 and x86_64 targets."); break; } + case 'r': raw = true; break; @@ -218,7 +217,6 @@ CommandObjectDisassemble::CommandOptions::OptionParsingFinished () if (!some_location_specified) current_function = true; return Error(); - } const OptionDefinition* @@ -230,33 +228,31 @@ CommandObjectDisassemble::CommandOptions::GetDefinitions () OptionDefinition CommandObjectDisassemble::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_ALL, false, "bytes" , 'b', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Show opcode bytes when disassembling."}, -{ LLDB_OPT_SET_ALL, false, "context" , 'C', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeNumLines, "Number of context lines of source to show."}, -{ LLDB_OPT_SET_ALL, false, "mixed" , 'm', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Enable mixed source and assembly display."}, -{ LLDB_OPT_SET_ALL, false, "raw" , 'r', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Print raw disassembly with no symbol information."}, -{ LLDB_OPT_SET_ALL, false, "plugin" , 'P', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypePlugin, "Name of the disassembler plugin you want to use."}, -{ LLDB_OPT_SET_ALL, false, "flavor" , 'F', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeDisassemblyFlavor, "Name of the disassembly flavor you want to use. " +{ LLDB_OPT_SET_ALL, false, "bytes" , 'b', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Show opcode bytes when disassembling."}, +{ LLDB_OPT_SET_ALL, false, "context" , 'C', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeNumLines, "Number of context lines of source to show."}, +{ LLDB_OPT_SET_ALL, false, "mixed" , 'm', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Enable mixed source and assembly display."}, +{ LLDB_OPT_SET_ALL, false, "raw" , 'r', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Print raw disassembly with no symbol information."}, +{ LLDB_OPT_SET_ALL, false, "plugin" , 'P', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypePlugin, "Name of the disassembler plugin you want to use."}, +{ LLDB_OPT_SET_ALL, false, "flavor" , 'F', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeDisassemblyFlavor, "Name of the disassembly flavor you want to use. " "Currently the only valid options are default, and for Intel" " architectures, att and intel."}, -{ LLDB_OPT_SET_ALL, false, "arch" , 'A', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeArchitecture,"Specify the architecture to use from cross disassembly."}, +{ LLDB_OPT_SET_ALL, false, "arch" , 'A', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeArchitecture,"Specify the architecture to use from cross disassembly."}, { LLDB_OPT_SET_1 | - LLDB_OPT_SET_2 , true , "start-address", 's', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeAddressOrExpression,"Address at which to start disassembling."}, -{ LLDB_OPT_SET_1 , false, "end-address" , 'e', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeAddressOrExpression, "Address at which to end disassembling."}, + LLDB_OPT_SET_2 , true , "start-address", 's', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeAddressOrExpression,"Address at which to start disassembling."}, +{ LLDB_OPT_SET_1 , false, "end-address" , 'e', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Address at which to end disassembling."}, { LLDB_OPT_SET_2 | LLDB_OPT_SET_3 | LLDB_OPT_SET_4 | - LLDB_OPT_SET_5 , false, "count" , 'c', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeNumLines, "Number of instructions to display."}, -{ LLDB_OPT_SET_3 , false, "name" , 'n', OptionParser::eRequiredArgument , NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, + LLDB_OPT_SET_5 , false, "count" , 'c', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeNumLines, "Number of instructions to display."}, +{ LLDB_OPT_SET_3 , false, "name" , 'n', OptionParser::eRequiredArgument , nullptr, nullptr, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Disassemble entire contents of the given function name."}, -{ LLDB_OPT_SET_4 , false, "frame" , 'f', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Disassemble from the start of the current frame's function."}, -{ LLDB_OPT_SET_5 , false, "pc" , 'p', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Disassemble around the current pc."}, -{ LLDB_OPT_SET_6 , false, "line" , 'l', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Disassemble the current frame's current source line instructions if there is debug line table information, else disassemble around the pc."}, -{ LLDB_OPT_SET_7 , false, "address" , 'a', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeAddressOrExpression, "Disassemble function containing this address."}, -{ 0 , false, NULL , 0, 0 , NULL, NULL, 0, eArgTypeNone, NULL } +{ LLDB_OPT_SET_4 , false, "frame" , 'f', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Disassemble from the start of the current frame's function."}, +{ LLDB_OPT_SET_5 , false, "pc" , 'p', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Disassemble around the current pc."}, +{ LLDB_OPT_SET_6 , false, "line" , 'l', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Disassemble the current frame's current source line instructions if there is debug line table information, else disassemble around the pc."}, +{ LLDB_OPT_SET_7 , false, "address" , 'a', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Disassemble function containing this address."}, +{ 0 , false, nullptr , 0, 0 , nullptr, nullptr, 0, eArgTypeNone, nullptr } }; - - //------------------------------------------------------------------------- // CommandObjectDisassemble //------------------------------------------------------------------------- @@ -270,15 +266,13 @@ CommandObjectDisassemble::CommandObjectDisassemble (CommandInterpreter &interpre { } -CommandObjectDisassemble::~CommandObjectDisassemble() -{ -} +CommandObjectDisassemble::~CommandObjectDisassemble() = default; bool CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result) { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - if (target == NULL) + if (target == nullptr) { result.AppendError ("invalid target, create a debug target using the 'target create' command"); result.SetStatus (eReturnStatusFailed); @@ -313,7 +307,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result) result.SetStatus (eReturnStatusFailed); return false; } - else if (flavor_string != NULL && !disassembler->FlavorValidForArchSpec(m_options.arch, flavor_string)) + else if (flavor_string != nullptr && !disassembler->FlavorValidForArchSpec(m_options.arch, flavor_string)) result.AppendWarningWithFormat("invalid disassembler flavor \"%s\", using default.\n", flavor_string); result.SetStatus (eReturnStatusSuccessFinishResult); @@ -346,17 +340,17 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result) { ConstString name(m_options.func_name.c_str()); - if (Disassembler::Disassemble (m_interpreter.GetDebugger(), - m_options.arch, - plugin_name, - flavor_string, - m_exe_ctx, - name, - NULL, // Module * - m_options.num_instructions, - m_options.show_mixed ? m_options.num_lines_context : 0, - options, - result.GetOutputStream())) + if (Disassembler::Disassemble(m_interpreter.GetDebugger(), + m_options.arch, + plugin_name, + flavor_string, + m_exe_ctx, + name, + nullptr, // Module * + m_options.num_instructions, + m_options.show_mixed ? m_options.num_lines_context : 0, + options, + result.GetOutputStream())) { result.SetStatus (eReturnStatusSuccessFinishResult); } @@ -373,7 +367,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result) StackFrame *frame = m_exe_ctx.GetFramePtr(); if (m_options.frame_line) { - if (frame == NULL) + if (frame == nullptr) { result.AppendError ("Cannot disassemble around the current line without a selected frame.\n"); result.SetStatus (eReturnStatusFailed); @@ -392,7 +386,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result) } else if (m_options.current_function) { - if (frame == NULL) + if (frame == nullptr) { result.AppendError ("Cannot disassemble around the current function without a selected frame.\n"); result.SetStatus (eReturnStatusFailed); @@ -412,7 +406,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result) { if (m_options.at_pc) { - if (frame == NULL) + if (frame == nullptr) { result.AppendError ("Cannot disassemble around the current PC without a selected frame.\n"); result.SetStatus (eReturnStatusFailed); @@ -498,7 +492,6 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result) } } } - } } } @@ -509,7 +502,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result) if (m_options.num_instructions != 0) { - if (ranges.size() == 0) + if (ranges.empty()) { // The default action is to disassemble the current frame function. if (frame) @@ -561,7 +554,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result) } else { - if (ranges.size() == 0) + if (ranges.empty()) { // The default action is to disassemble the current frame function. if (frame) diff --git a/lldb/source/Commands/CommandObjectDisassemble.h b/lldb/source/Commands/CommandObjectDisassemble.h index d892824..ef19b3c 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.h +++ b/lldb/source/Commands/CommandObjectDisassemble.h @@ -30,7 +30,6 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter); ~CommandOptions() override; @@ -47,16 +46,14 @@ public: const char * GetPluginName () { - if (plugin_name.empty()) - return NULL; - return plugin_name.c_str(); + return (plugin_name.empty() ? nullptr : plugin_name.c_str()); } const char * GetFlavorString () { if (flavor_string.empty() || flavor_string == "default") - return NULL; + return nullptr; return flavor_string.c_str(); } diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp index 18dc44a..14d1ae5 100644 --- a/lldb/source/Commands/CommandObjectHelp.cpp +++ b/lldb/source/Commands/CommandObjectHelp.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "CommandObjectHelp.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "CommandObjectHelp.h" #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/Options.h" @@ -45,17 +44,15 @@ CommandObjectHelp::CommandObjectHelp (CommandInterpreter &interpreter) : m_arguments.push_back (arg); } -CommandObjectHelp::~CommandObjectHelp() -{ -} +CommandObjectHelp::~CommandObjectHelp() = default; OptionDefinition CommandObjectHelp::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Hide aliases in the command list."}, - { LLDB_OPT_SET_ALL, false, "hide-user-commands", 'u', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Hide user-defined commands from the list."}, - { LLDB_OPT_SET_ALL, false, "show-hidden-commands", 'h', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Include commands prefixed with an underscore."}, - { 0, false, NULL, 0, 0, 0, NULL, 0, eArgTypeNone, NULL } + { LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Hide aliases in the command list."}, + { LLDB_OPT_SET_ALL, false, "hide-user-commands", 'u', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Hide user-defined commands from the list."}, + { LLDB_OPT_SET_ALL, false, "show-hidden-commands", 'h', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Include commands prefixed with an underscore."}, + { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; bool @@ -88,7 +85,7 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result) bool is_alias_command = m_interpreter.AliasExists (command.GetArgumentAtIndex (0)); std::string alias_name = command.GetArgumentAtIndex(0); - if (cmd_obj != NULL) + if (cmd_obj != nullptr) { StringList matches; bool all_okay = true; @@ -107,7 +104,7 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result) { CommandObject *found_cmd; found_cmd = sub_cmd_obj->GetSubcommandObject(sub_command.c_str(), &matches); - if (found_cmd == NULL) + if (found_cmd == nullptr) all_okay = false; else if (matches.GetSize() > 1) all_okay = false; @@ -116,7 +113,7 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result) } } - if (!all_okay || (sub_cmd_obj == NULL)) + if (!all_okay || (sub_cmd_obj == nullptr)) { std::string cmd_string; command.GetCommandString (cmd_string); @@ -198,16 +195,13 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result) } int -CommandObjectHelp::HandleCompletion -( - Args &input, - int &cursor_index, - int &cursor_char_position, - int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches -) +CommandObjectHelp::HandleCompletion(Args &input, + int &cursor_index, + int &cursor_char_position, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) { // Return the completions of the commands in the help system: if (cursor_index == 0) diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp index 8e29cd5..05ecb59 100644 --- a/lldb/source/Commands/CommandObjectLog.cpp +++ b/lldb/source/Commands/CommandObjectLog.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "CommandObjectLog.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "CommandObjectLog.h" #include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" #include "lldb/Host/FileSpec.h" @@ -23,24 +22,20 @@ #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Timer.h" - #include "lldb/Core/Debugger.h" #include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" - #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolVendor.h" - #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; - class CommandObjectLogEnable : public CommandObjectParsed { public: @@ -48,13 +43,12 @@ public: // Constructors and Destructors //------------------------------------------------------------------ CommandObjectLogEnable(CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "log enable", - "Enable logging for a single log channel.", - NULL), + CommandObjectParsed(interpreter, + "log enable", + "Enable logging for a single log channel.", + nullptr), m_options (interpreter) { - CommandArgumentEntry arg1; CommandArgumentEntry arg2; CommandArgumentData channel_arg; @@ -77,9 +71,7 @@ public: m_arguments.push_back (arg2); } - ~CommandObjectLogEnable() override - { - } + ~CommandObjectLogEnable() override = default; Options * GetOptions () override @@ -112,7 +104,6 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options (interpreter), log_file (), @@ -120,10 +111,7 @@ public: { } - - ~CommandOptions () override - { - } + ~CommandOptions () override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -211,17 +199,17 @@ protected: OptionDefinition CommandObjectLogEnable::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFilename, "Set the destination file to log to."}, -{ LLDB_OPT_SET_1, false, "threadsafe", 't', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." }, -{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable verbose logging." }, -{ LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable debug logging." }, -{ LLDB_OPT_SET_1, false, "sequence", 's', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." }, -{ LLDB_OPT_SET_1, false, "timestamp", 'T', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with a timestamp." }, -{ LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." }, -{ LLDB_OPT_SET_1, false, "thread-name",'n', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." }, -{ LLDB_OPT_SET_1, false, "stack", 'S', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Append a stack backtrace to each log line." }, -{ LLDB_OPT_SET_1, false, "append", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Append to the log file instead of overwriting." }, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +{ LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename, "Set the destination file to log to."}, +{ LLDB_OPT_SET_1, false, "threadsafe", 't', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." }, +{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable verbose logging." }, +{ LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable debug logging." }, +{ LLDB_OPT_SET_1, false, "sequence", 's', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." }, +{ LLDB_OPT_SET_1, false, "timestamp", 'T', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with a timestamp." }, +{ LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." }, +{ LLDB_OPT_SET_1, false, "thread-name",'n', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." }, +{ LLDB_OPT_SET_1, false, "stack", 'S', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Append a stack backtrace to each log line." }, +{ LLDB_OPT_SET_1, false, "append", 'a', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Append to the log file instead of overwriting." }, +{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; class CommandObjectLogDisable : public CommandObjectParsed @@ -231,10 +219,10 @@ public: // Constructors and Destructors //------------------------------------------------------------------ CommandObjectLogDisable(CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "log disable", - "Disable one or more log channel categories.", - NULL) + CommandObjectParsed(interpreter, + "log disable", + "Disable one or more log channel categories.", + nullptr) { CommandArgumentEntry arg1; CommandArgumentEntry arg2; @@ -258,9 +246,7 @@ public: m_arguments.push_back (arg2); } - ~CommandObjectLogDisable() override - { - } + ~CommandObjectLogDisable() override = default; protected: bool @@ -310,10 +296,10 @@ public: // Constructors and Destructors //------------------------------------------------------------------ CommandObjectLogList(CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "log list", - "List the log categories for one or more log channels. If none specified, lists them all.", - NULL) + CommandObjectParsed(interpreter, + "log list", + "List the log categories for one or more log channels. If none specified, lists them all.", + nullptr) { CommandArgumentEntry arg; CommandArgumentData channel_arg; @@ -329,9 +315,7 @@ public: m_arguments.push_back (arg); } - ~CommandObjectLogList() override - { - } + ~CommandObjectLogList() override = default; protected: bool @@ -392,9 +376,7 @@ public: { } - ~CommandObjectLogTimer() override - { - } + ~CommandObjectLogTimer() override = default; protected: bool @@ -429,7 +411,6 @@ protected: Timer::ResetCategoryTimes (); result.SetStatus(eReturnStatusSuccessFinishResult); } - } else if (argc == 2) { @@ -470,9 +451,6 @@ protected: } }; -//---------------------------------------------------------------------- -// CommandObjectLog constructor -//---------------------------------------------------------------------- CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter) : CommandObjectMultiword (interpreter, "log", @@ -485,13 +463,4 @@ CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter) : LoadSubCommand ("timers", CommandObjectSP (new CommandObjectLogTimer (interpreter))); } -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -CommandObjectLog::~CommandObjectLog() -{ -} - - - - +CommandObjectLog::~CommandObjectLog() = default; diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 7a82ec1..7a0da83 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "CommandObjectMemory.h" - // C Includes #include @@ -17,6 +15,7 @@ #include "clang/AST/Decl.h" // Project includes +#include "CommandObjectMemory.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Debugger.h" @@ -50,21 +49,18 @@ using namespace lldb_private; static OptionDefinition g_option_table[] = { - { LLDB_OPT_SET_1, false, "num-per-line" ,'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."}, - { LLDB_OPT_SET_2, false, "binary" ,'b', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."}, - { LLDB_OPT_SET_3, true , "type" ,'t', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."}, - { LLDB_OPT_SET_3, false , "offset" ,'E', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount ,"How many elements of the specified type to skip before starting to display data."}, + { LLDB_OPT_SET_1, false, "num-per-line" ,'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeNumberPerLine ,"The number of items per line to display."}, + { LLDB_OPT_SET_2, false, "binary" ,'b', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."}, + { LLDB_OPT_SET_3, true , "type" ,'t', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeNone ,"The name of a type to view memory as."}, + { LLDB_OPT_SET_3, false , "offset" ,'E', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount ,"How many elements of the specified type to skip before starting to display data."}, { LLDB_OPT_SET_1| LLDB_OPT_SET_2| - LLDB_OPT_SET_3, false, "force" ,'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone ,"Necessary if reading over target.max-memory-read-size bytes."}, + LLDB_OPT_SET_3, false, "force" ,'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone ,"Necessary if reading over target.max-memory-read-size bytes."}, }; - - class OptionGroupReadMemory : public OptionGroup { public: - OptionGroupReadMemory () : m_num_per_line (1,1), m_output_as_binary (false), @@ -73,11 +69,8 @@ public: { } - ~OptionGroupReadMemory () override - { - } - - + ~OptionGroupReadMemory() override = default; + uint32_t GetNumDefinitions () override { @@ -221,6 +214,7 @@ public: if (!count_option_set) format_options.GetCountValue() = 32; break; + case eFormatCharArray: case eFormatChar: case eFormatCharPrintable: @@ -231,6 +225,7 @@ public: if (!count_option_set) format_options.GetCountValue() = 64; break; + case eFormatComplex: if (!byte_size_option_set) byte_size_value = 8; @@ -239,6 +234,7 @@ public: if (!count_option_set) format_options.GetCountValue() = 8; break; + case eFormatComplexInteger: if (!byte_size_option_set) byte_size_value = 8; @@ -247,6 +243,7 @@ public: if (!count_option_set) format_options.GetCountValue() = 8; break; + case eFormatHex: if (!byte_size_option_set) byte_size_value = 4; @@ -313,21 +310,18 @@ public: OptionValueUInt64 m_offset; }; - - //---------------------------------------------------------------------- // Read memory from the inferior process //---------------------------------------------------------------------- class CommandObjectMemoryRead : public CommandObjectParsed { public: - CommandObjectMemoryRead (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "memory read", - "Read from the memory of the process being debugged.", - NULL, - eCommandRequiresTarget | eCommandProcessMustBePaused), + CommandObjectParsed(interpreter, + "memory read", + "Read from the memory of the process being debugged.", + nullptr, + eCommandRequiresTarget | eCommandProcessMustBePaused), m_option_group (interpreter), m_format_options (eFormatBytesWithASCII, 1, 8), m_memory_options (), @@ -380,9 +374,7 @@ public: m_option_group.Finalize(); } - ~CommandObjectMemoryRead () override - { - } + ~CommandObjectMemoryRead() override = default; Options * GetOptions () override @@ -558,7 +550,7 @@ protected: } } - if (clang_ast_type.IsValid() == false) + if (!clang_ast_type.IsValid()) { if (type_list.GetSize() == 0) { @@ -669,7 +661,8 @@ protected: if (argc == 2) { - lldb::addr_t end_addr = Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(1), LLDB_INVALID_ADDRESS, 0); + lldb::addr_t end_addr = Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(1), + LLDB_INVALID_ADDRESS, nullptr); if (end_addr == LLDB_INVALID_ADDRESS) { result.AppendError("invalid end address expression."); @@ -709,7 +702,7 @@ protected: if (clang_ast_type.GetOpaqueQualType()) { // Make sure we don't display our type as ASCII bytes like the default memory read - if (m_format_options.GetFormatValue().OptionWasSet() == false) + if (!m_format_options.GetFormatValue().OptionWasSet()) m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault); bytes_read = clang_ast_type.GetByteSize(nullptr) * m_format_options.GetCountValue().GetCurrentValue(); @@ -720,14 +713,14 @@ protected: else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString) { data_sp.reset (new DataBufferHeap (total_byte_size, '\0')); - if (data_sp->GetBytes() == NULL) + if (data_sp->GetBytes() == nullptr) { result.AppendErrorWithFormat ("can't allocate 0x%" PRIx32 " bytes for the memory read buffer, specify a smaller size to read", (uint32_t)total_byte_size); result.SetStatus(eReturnStatusFailed); return false; } - Address address(addr, NULL); + Address address(addr, nullptr); bytes_read = target->ReadMemory(address, false, data_sp->GetBytes (), data_sp->GetByteSize(), error); if (bytes_read == 0) { @@ -757,7 +750,7 @@ protected: if (!m_format_options.GetCountValue().OptionWasSet()) item_count = 1; data_sp.reset (new DataBufferHeap ((item_byte_size+1) * item_count, '\0')); // account for NULLs as necessary - if (data_sp->GetBytes() == NULL) + if (data_sp->GetBytes() == nullptr) { result.AppendErrorWithFormat ("can't allocate 0x%" PRIx64 " bytes for the memory read buffer, specify a smaller size to read", (uint64_t)((item_byte_size+1) * item_count)); result.SetStatus(eReturnStatusFailed); @@ -811,7 +804,7 @@ protected: m_prev_clang_ast_type = clang_ast_type; StreamFile outfile_stream; - Stream *output_stream = NULL; + Stream *output_stream = nullptr; const FileSpec &outfile_spec = m_outfile_options.GetFile().GetCurrentValue(); if (outfile_spec) { @@ -862,7 +855,6 @@ protected: output_stream = &result.GetOutputStream(); } - ExecutionContextScope *exe_scope = m_exe_ctx.GetBestExecutionContextScope(); if (clang_ast_type.GetOpaqueQualType()) { @@ -909,7 +901,7 @@ protected: && (item_byte_size != 1)) { // if a count was not passed, or it is 1 - if (m_format_options.GetCountValue().OptionWasSet() == false || item_count == 1) + if (!m_format_options.GetCountValue().OptionWasSet() || item_count == 1) { // this turns requests such as // memory read -fc -s10 -c1 *charPtrPtr @@ -963,10 +955,10 @@ protected: OptionDefinition g_memory_find_option_table[] = { - { LLDB_OPT_SET_1, false, "expression", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeExpression, "Evaluate an expression to obtain a byte pattern."}, - { LLDB_OPT_SET_2, false, "string", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Use text to find a byte pattern."}, - { LLDB_OPT_SET_1|LLDB_OPT_SET_2, false, "count", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount, "How many times to perform the search."}, - { LLDB_OPT_SET_1|LLDB_OPT_SET_2, false, "dump-offset", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset, "When dumping memory for a match, an offset from the match location to start dumping from."}, + { LLDB_OPT_SET_1, false, "expression", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeExpression, "Evaluate an expression to obtain a byte pattern."}, + { LLDB_OPT_SET_2, false, "string", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Use text to find a byte pattern."}, + { LLDB_OPT_SET_1|LLDB_OPT_SET_2, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount, "How many times to perform the search."}, + { LLDB_OPT_SET_1|LLDB_OPT_SET_2, false, "dump-offset", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOffset, "When dumping memory for a match, an offset from the match location to start dumping from."}, }; //---------------------------------------------------------------------- @@ -975,7 +967,6 @@ g_memory_find_option_table[] = class CommandObjectMemoryFind : public CommandObjectParsed { public: - class OptionGroupFindMemory : public OptionGroup { public: @@ -985,11 +976,9 @@ public: m_offset(0) { } - - ~OptionGroupFindMemory () override - { - } - + + ~OptionGroupFindMemory() override = default; + uint32_t GetNumDefinitions () override { @@ -1052,11 +1041,11 @@ public: }; CommandObjectMemoryFind (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "memory find", - "Find a value in the memory of the process being debugged.", - NULL, - eCommandRequiresProcess | eCommandProcessMustBeLaunched), + CommandObjectParsed(interpreter, + "memory find", + "Find a value in the memory of the process being debugged.", + nullptr, + eCommandRequiresProcess | eCommandProcessMustBeLaunched), m_option_group (interpreter), m_memory_options () { @@ -1086,11 +1075,9 @@ public: m_option_group.Append (&m_memory_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_2); m_option_group.Finalize(); } - - ~CommandObjectMemoryFind () override - { - } - + + ~CommandObjectMemoryFind() override = default; + Options * GetOptions () override { @@ -1143,7 +1130,7 @@ protected: StackFrame* frame = m_exe_ctx.GetFramePtr(); ValueObjectSP result_sp; if ((eExpressionCompleted == process->GetTarget().EvaluateExpression(m_memory_options.m_expr.GetStringValue(), frame, result_sp)) && - result_sp.get()) + result_sp) { uint64_t value = result_sp->GetValueAsUnsigned(0); switch (result_sp->GetCompilerType().GetByteSize(nullptr)) @@ -1253,12 +1240,11 @@ protected: OptionGroupFindMemory m_memory_options; }; - OptionDefinition g_memory_write_option_table[] = { -{ LLDB_OPT_SET_1, true, "infile", 'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFilename, "Write memory using the contents of a file."}, -{ LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset, "Start writing bytes from an offset within the input file."}, +{ LLDB_OPT_SET_1, true, "infile", 'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename, "Write memory using the contents of a file."}, +{ LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOffset, "Start writing bytes from an offset within the input file."}, }; //---------------------------------------------------------------------- @@ -1267,7 +1253,6 @@ g_memory_write_option_table[] = class CommandObjectMemoryWrite : public CommandObjectParsed { public: - class OptionGroupWriteMemory : public OptionGroup { public: @@ -1276,9 +1261,7 @@ public: { } - ~OptionGroupWriteMemory () override - { - } + ~OptionGroupWriteMemory() override = default; uint32_t GetNumDefinitions () override @@ -1341,11 +1324,11 @@ public: }; CommandObjectMemoryWrite (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "memory write", - "Write to the memory of the process being debugged.", - NULL, - eCommandRequiresProcess | eCommandProcessMustBeLaunched), + CommandObjectParsed(interpreter, + "memory write", + "Write to the memory of the process being debugged.", + nullptr, + eCommandRequiresProcess | eCommandProcessMustBeLaunched), m_option_group (interpreter), m_format_options (eFormatBytes, 1, UINT64_MAX), m_memory_options () @@ -1377,12 +1360,9 @@ public: m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_SIZE , LLDB_OPT_SET_1|LLDB_OPT_SET_2); m_option_group.Append (&m_memory_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_2); m_option_group.Finalize(); - } - ~CommandObjectMemoryWrite () override - { - } + ~CommandObjectMemoryWrite() override = default; Options * GetOptions () override @@ -1558,7 +1538,6 @@ protected: case eFormatHex: case eFormatHexUppercase: case eFormatPointer: - // Decode hex bytes uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 16, &success); if (!success) @@ -1706,13 +1685,13 @@ protected: class CommandObjectMemoryHistory : public CommandObjectParsed { public: - CommandObjectMemoryHistory (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "memory history", - "Prints out the recorded stack traces for allocation/deallocation of a memory address.", - NULL, - eCommandRequiresTarget | eCommandRequiresProcess | eCommandProcessMustBePaused | eCommandProcessMustBeLaunched) + CommandObjectParsed(interpreter, + "memory history", + "Prints out the recorded stack traces for allocation/deallocation of a memory address.", + nullptr, + eCommandRequiresTarget | eCommandRequiresProcess | eCommandProcessMustBePaused | + eCommandProcessMustBeLaunched) { CommandArgumentEntry arg1; CommandArgumentData addr_arg; @@ -1727,11 +1706,9 @@ public: // Push the data for the first argument into the m_arguments vector. m_arguments.push_back (arg1); } - - ~CommandObjectMemoryHistory () override - { - } - + + ~CommandObjectMemoryHistory() override = default; + const char * GetRepeatCommand (Args ¤t_command_args, uint32_t index) override { @@ -1770,7 +1747,7 @@ protected: const ProcessSP &process_sp = m_exe_ctx.GetProcessSP(); const MemoryHistorySP &memory_history = MemoryHistory::FindPlugin(process_sp); - if (! memory_history.get()) + if (!memory_history) { result.AppendError("no available memory history provider"); result.SetStatus(eReturnStatusFailed); @@ -1787,10 +1764,8 @@ protected: return true; } - }; - //------------------------------------------------------------------------- // CommandObjectMemory //------------------------------------------------------------------------- @@ -1807,6 +1782,4 @@ CommandObjectMemory::CommandObjectMemory (CommandInterpreter &interpreter) : LoadSubCommand ("history", CommandObjectSP (new CommandObjectMemoryHistory (interpreter))); } -CommandObjectMemory::~CommandObjectMemory () -{ -} +CommandObjectMemory::~CommandObjectMemory() = default; diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index ed70551..6d35c9c 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -7,11 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Interpreter/CommandObjectMultiword.h" // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/Options.h" @@ -24,22 +24,17 @@ using namespace lldb_private; // CommandObjectMultiword //------------------------------------------------------------------------- -CommandObjectMultiword::CommandObjectMultiword -( - CommandInterpreter &interpreter, - const char *name, - const char *help, - const char *syntax, - uint32_t flags -) : +CommandObjectMultiword::CommandObjectMultiword(CommandInterpreter &interpreter, + const char *name, + const char *help, + const char *syntax, + uint32_t flags) : CommandObject (interpreter, name, help, syntax, flags), m_can_be_removed(false) { } -CommandObjectMultiword::~CommandObjectMultiword () -{ -} +CommandObjectMultiword::~CommandObjectMultiword() = default; CommandObjectSP CommandObjectMultiword::GetSubcommandSP (const char *sub_cmd, StringList *matches) @@ -58,9 +53,8 @@ CommandObjectMultiword::GetSubcommandSP (const char *sub_cmd, StringList *matche } else { - StringList local_matches; - if (matches == NULL) + if (matches == nullptr) matches = &local_matches; int num_matches = CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, sub_cmd, *matches); @@ -86,13 +80,10 @@ CommandObjectMultiword::GetSubcommandObject (const char *sub_cmd, StringList *ma } bool -CommandObjectMultiword::LoadSubCommand -( - const char *name, - const CommandObjectSP& cmd_obj -) +CommandObjectMultiword::LoadSubCommand(const char *name, + const CommandObjectSP& cmd_obj) { - if (cmd_obj.get()) + if (cmd_obj) assert((&GetCommandInterpreter() == &cmd_obj->GetCommandInterpreter()) && "tried to add a CommandObject from a different interpreter"); CommandMap::iterator pos; @@ -132,7 +123,7 @@ CommandObjectMultiword::Execute(const char *args_string, CommandReturnObject &re { StringList matches; CommandObject *sub_cmd_obj = GetSubcommandObject(sub_command, &matches); - if (sub_cmd_obj != NULL) + if (sub_cmd_obj != nullptr) { // Now call CommandObject::Execute to process and options in 'rest_of_line'. From there // the command-specific version of Execute will be called, with the processed arguments. @@ -221,16 +212,13 @@ CommandObjectMultiword::GenerateHelpText (Stream &output_stream) } int -CommandObjectMultiword::HandleCompletion -( - Args &input, - int &cursor_index, - int &cursor_char_position, - int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches -) +CommandObjectMultiword::HandleCompletion(Args &input, + int &cursor_index, + int &cursor_char_position, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) { // Any of the command matches will provide a complete word, otherwise the individual // completers will override this. @@ -244,13 +232,13 @@ CommandObjectMultiword::HandleCompletion matches); if (matches.GetSize() == 1 - && matches.GetStringAtIndex(0) != NULL + && matches.GetStringAtIndex(0) != nullptr && strcmp (arg0, matches.GetStringAtIndex(0)) == 0) { StringList temp_matches; CommandObject *cmd_obj = GetSubcommandObject (arg0, &temp_matches); - if (cmd_obj != NULL) + if (cmd_obj != nullptr) { if (input.GetArgumentCount() == 1) { @@ -278,7 +266,7 @@ CommandObjectMultiword::HandleCompletion { CommandObject *sub_command_object = GetSubcommandObject (arg0, &matches); - if (sub_command_object == NULL) + if (sub_command_object == nullptr) { return matches.GetSize(); } @@ -296,7 +284,6 @@ CommandObjectMultiword::HandleCompletion word_complete, matches); } - } } @@ -305,14 +292,13 @@ CommandObjectMultiword::GetRepeatCommand (Args ¤t_command_args, uint32_t i { index++; if (current_command_args.GetArgumentCount() <= index) - return NULL; + return nullptr; CommandObject *sub_command_object = GetSubcommandObject (current_command_args.GetArgumentAtIndex(index)); - if (sub_command_object == NULL) - return NULL; + if (sub_command_object == nullptr) + return nullptr; return sub_command_object->GetRepeatCommand(current_command_args, index); } - void CommandObjectMultiword::AproposAllSubCommands (const char *prefix, const char *search_word, @@ -343,8 +329,6 @@ CommandObjectMultiword::AproposAllSubCommands (const char *prefix, } } - - CommandObjectProxy::CommandObjectProxy (CommandInterpreter &interpreter, const char *name, const char *help, @@ -354,9 +338,7 @@ CommandObjectProxy::CommandObjectProxy (CommandInterpreter &interpreter, { } -CommandObjectProxy::~CommandObjectProxy () -{ -} +CommandObjectProxy::~CommandObjectProxy() = default; const char * CommandObjectProxy::GetHelpLong () @@ -364,7 +346,7 @@ CommandObjectProxy::GetHelpLong () CommandObject *proxy_command = GetProxyCommandObject(); if (proxy_command) return proxy_command->GetHelpLong(); - return NULL; + return nullptr; } bool @@ -408,7 +390,7 @@ CommandObjectProxy::GetSubcommandObject (const char *sub_cmd, StringList *matche CommandObject *proxy_command = GetProxyCommandObject(); if (proxy_command) return proxy_command->GetSubcommandObject(sub_cmd, matches); - return NULL; + return nullptr; } void @@ -453,17 +435,15 @@ CommandObjectProxy::WantsCompletion() return false; } - Options * CommandObjectProxy::GetOptions () { CommandObject *proxy_command = GetProxyCommandObject(); if (proxy_command) return proxy_command->GetOptions (); - return NULL; + return nullptr; } - int CommandObjectProxy::HandleCompletion (Args &input, int &cursor_index, @@ -485,6 +465,7 @@ CommandObjectProxy::HandleCompletion (Args &input, matches.Clear(); return 0; } + int CommandObjectProxy::HandleArgumentCompletion (Args &input, int &cursor_index, @@ -516,7 +497,7 @@ CommandObjectProxy::GetRepeatCommand (Args ¤t_command_args, CommandObject *proxy_command = GetProxyCommandObject(); if (proxy_command) return proxy_command->GetRepeatCommand (current_command_args, index); - return NULL; + return nullptr; } bool @@ -530,5 +511,3 @@ CommandObjectProxy::Execute (const char *args_string, result.SetStatus (eReturnStatusFailed); return false; } - - diff --git a/lldb/source/Commands/CommandObjectPlugin.cpp b/lldb/source/Commands/CommandObjectPlugin.cpp index 4c5a089..3fae35a 100644 --- a/lldb/source/Commands/CommandObjectPlugin.cpp +++ b/lldb/source/Commands/CommandObjectPlugin.cpp @@ -1,4 +1,4 @@ -//===-- CommandObjectPlugin.cpp ----------------------------------*- C++ -*-===// +//===-- CommandObjectPlugin.cpp ---------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,10 +7,12 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "CommandObjectPlugin.h" - #include "lldb/Host/Host.h" - #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -19,13 +21,12 @@ using namespace lldb_private; class CommandObjectPluginLoad : public CommandObjectParsed { -private: public: CommandObjectPluginLoad (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "plugin load", - "Import a dylib that implements an LLDB plugin.", - NULL) + CommandObjectParsed(interpreter, + "plugin load", + "Import a dylib that implements an LLDB plugin.", + nullptr) { CommandArgumentEntry arg1; CommandArgumentData cmd_arg; @@ -40,11 +41,9 @@ public: // Push the data for the first argument into the m_arguments vector. m_arguments.push_back (arg1); } - - ~CommandObjectPluginLoad () override - { - } - + + ~CommandObjectPluginLoad() override = default; + int HandleArgumentCompletion (Args &input, int &cursor_index, @@ -58,14 +57,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(); } @@ -109,6 +108,4 @@ CommandObjectMultiword (interpreter, LoadSubCommand ("load", CommandObjectSP (new CommandObjectPluginLoad (interpreter))); } -CommandObjectPlugin::~CommandObjectPlugin () -{ -} +CommandObjectPlugin::~CommandObjectPlugin() = default; diff --git a/lldb/source/Commands/CommandObjectSyntax.cpp b/lldb/source/Commands/CommandObjectSyntax.cpp index e9fa084..12bfce3 100644 --- a/lldb/source/Commands/CommandObjectSyntax.cpp +++ b/lldb/source/Commands/CommandObjectSyntax.cpp @@ -7,15 +7,13 @@ // //===----------------------------------------------------------------------===// -#include "CommandObjectSyntax.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "CommandObjectSyntax.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/Options.h" - #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/CommandObjectMultiword.h" @@ -47,10 +45,7 @@ CommandObjectSyntax::CommandObjectSyntax (CommandInterpreter &interpreter) : m_arguments.push_back (arg); } -CommandObjectSyntax::~CommandObjectSyntax() -{ -} - +CommandObjectSyntax::~CommandObjectSyntax() = default; bool CommandObjectSyntax::DoExecute (Args& command, CommandReturnObject &result) @@ -82,10 +77,10 @@ CommandObjectSyntax::DoExecute (Args& command, CommandReturnObject &result) } } - if (all_okay && (cmd_obj != NULL)) + if (all_okay && (cmd_obj != nullptr)) { Stream &output_strm = result.GetOutputStream(); - if (cmd_obj->GetOptions() != NULL) + if (cmd_obj->GetOptions() != nullptr) { output_strm.Printf ("\nSyntax: %s\n", cmd_obj->GetSyntax()); output_strm.Printf ("(Try 'help %s' for more information on command options syntax.)\n",