diff options
Diffstat (limited to 'lldb')
| -rw-r--r-- | lldb/include/lldb/Interpreter/CommandInterpreter.h | 2 | ||||
| -rw-r--r-- | lldb/source/API/SBCommandInterpreter.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectCommands.cpp | 25 | ||||
| -rw-r--r-- | lldb/source/Expression/REPL.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 19 | ||||
| -rw-r--r-- | lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp | 2 |
6 files changed, 22 insertions, 30 deletions
diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index c57d743f2c3..58b847f9c2e 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -287,7 +287,7 @@ public: CommandInterpreterRunOptions &options, CommandReturnObject &result); - CommandObject *GetCommandObjectForCommand(std::string &command_line); + CommandObject *GetCommandObjectForCommand(llvm::StringRef &command_line); // This handles command line completion. You are given a pointer to the // command string buffer, to the current cursor, diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 3ca5c0aad8c..45f8ab364b2 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -481,7 +481,7 @@ bool SBCommandInterpreter::SetCommandOverrideCallback( const char *command_name, lldb::CommandOverrideCallback callback, void *baton) { if (command_name && command_name[0] && IsValid()) { - std::string command_name_str(command_name); + llvm::StringRef command_name_str = command_name; CommandObject *cmd_obj = m_opaque_ptr->GetCommandObjectForCommand(command_name_str); if (cmd_obj) { diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index c24e05d0eec..abf2c745490 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -595,8 +595,8 @@ protected: if (nullptr == remainder) remainder = raw_command_line; - std::string raw_command_string(remainder); - Args args(raw_command_string.c_str()); + llvm::StringRef raw_command_string(remainder); + Args args(raw_command_string); if (args.GetArgumentCount() < 2) { result.AppendError("'command alias' requires at least two arguments"); @@ -644,10 +644,9 @@ protected: } // Get CommandObject that is being aliased. The command name is read from - // the front of raw_command_string. - // raw_command_string is returned with the name of the command object - // stripped off the front. - std::string original_raw_command_string(raw_command_string); + // the front of raw_command_string. raw_command_string is returned with the + // name of the command object stripped off the front. + llvm::StringRef original_raw_command_string = raw_command_string; CommandObject *cmd_obj = m_interpreter.GetCommandObjectForCommand(raw_command_string); @@ -655,7 +654,7 @@ protected: result.AppendErrorWithFormat("invalid command given to 'command alias'. " "'%s' does not begin with a valid command." " No alias created.", - original_raw_command_string.c_str()); + original_raw_command_string.str().c_str()); result.SetStatus(eReturnStatusFailed); return false; } else if (!cmd_obj->WantsRawCommandString()) { @@ -671,8 +670,8 @@ protected: return result.Succeeded(); } - bool HandleAliasingRawCommand(const std::string &alias_command, - std::string &raw_command_string, + bool HandleAliasingRawCommand(llvm::StringRef alias_command, + llvm::StringRef raw_command_string, CommandObject &cmd_obj, CommandReturnObject &result) { // Verify & handle any options/arguments passed to the alias command @@ -682,14 +681,14 @@ protected: if (CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact(cmd_obj.GetCommandName(), false)) { - if (m_interpreter.AliasExists(alias_command.c_str()) || - m_interpreter.UserCommandExists(alias_command.c_str())) { + if (m_interpreter.AliasExists(alias_command) || + m_interpreter.UserCommandExists(alias_command)) { result.AppendWarningWithFormat( "Overwriting existing definition for '%s'.\n", - alias_command.c_str()); + alias_command.str().c_str()); } if (CommandAlias *alias = m_interpreter.AddAlias( - alias_command.c_str(), cmd_obj_sp, raw_command_string.c_str())) { + alias_command, cmd_obj_sp, raw_command_string)) { if (m_command_options.m_help.OptionWasSet()) alias->SetHelp(m_command_options.m_help.GetCurrentValue()); if (m_command_options.m_long_help.OptionWasSet()) diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp index d7f2d74b846..36095deba7b 100644 --- a/lldb/source/Expression/REPL.cpp +++ b/lldb/source/Expression/REPL.cpp @@ -552,7 +552,7 @@ Error REPL::RunLoop() { // dedicated REPL mode... m_dedicated_repl_mode = true; debugger.StartIOHandlerThread(); - std::string command_name_str("quit"); + llvm::StringRef command_name_str("quit"); CommandObject *cmd_obj = debugger.GetCommandInterpreter().GetCommandObjectForCommand( command_name_str); diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 1850f8739ad..6e845fa4050 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -1162,8 +1162,8 @@ void CommandInterpreter::GetHelp(CommandReturnObject &result, GetCommandPrefix()); } -CommandObject * -CommandInterpreter::GetCommandObjectForCommand(std::string &command_string) { +CommandObject *CommandInterpreter::GetCommandObjectForCommand( + llvm::StringRef &command_string) { // This function finds the final, lowest-level, alias-resolved command object // whose 'Execute' function will // eventually be invoked by the given command line. @@ -1182,8 +1182,7 @@ CommandInterpreter::GetCommandObjectForCommand(std::string &command_string) { if (cmd_obj == nullptr) // Since cmd_obj is NULL we are on our first time through this loop. - // Check to see if cmd_word is a valid - // command or alias. + // Check to see if cmd_word is a valid command or alias. cmd_obj = GetCommandObject(cmd_word); else if (cmd_obj->IsMultiwordObject()) { // Our current object is a multi-word object; see if the cmd_word is a @@ -1199,10 +1198,8 @@ CommandInterpreter::GetCommandObjectForCommand(std::string &command_string) { done = true; // If we didn't find a valid command object, or our command object is not - // a multi-word object, or - // we are at the end of the command_string, then we are done. Otherwise, - // find the start of the - // next word. + // a multi-word object, or we are at the end of the command_string, then + // we are done. Otherwise, find the start of the next word. if (!cmd_obj || !cmd_obj->IsMultiwordObject() || end >= command_string.size()) @@ -1214,11 +1211,7 @@ CommandInterpreter::GetCommandObjectForCommand(std::string &command_string) { done = true; } - if (end == command_string.size()) - command_string.clear(); - else - command_string = command_string.substr(end); - + command_string = command_string.substr(end); return cmd_obj; } diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp index 4895962d47b..ed86dfcf813 100644 --- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -1447,7 +1447,7 @@ void StructuredDataDarwinLog::DebuggerInitialize(Debugger &debugger) { // Get parent command. auto &interpreter = debugger.GetCommandInterpreter(); - std::string parent_command_text = "plugin structured-data"; + llvm::StringRef parent_command_text = "plugin structured-data"; auto parent_command = interpreter.GetCommandObjectForCommand(parent_command_text); if (!parent_command) { |

