[Lldb-commits] [lldb] r283386 - Convert some more aliasing and CI functions to StringRef.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 5 14:14:57 PDT 2016
Author: zturner
Date: Wed Oct 5 16:14:56 2016
New Revision: 283386
URL: http://llvm.org/viewvc/llvm-project?rev=283386&view=rev
Log:
Convert some more aliasing and CI functions to StringRef.
Modified:
lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
lldb/trunk/source/API/SBCommandInterpreter.cpp
lldb/trunk/source/Commands/CommandObjectCommands.cpp
lldb/trunk/source/Expression/REPL.cpp
lldb/trunk/source/Interpreter/CommandInterpreter.cpp
lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=283386&r1=283385&r2=283386&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Wed Oct 5 16:14:56 2016
@@ -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,
Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=283386&r1=283385&r2=283386&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommandInterpreter.cpp (original)
+++ lldb/trunk/source/API/SBCommandInterpreter.cpp Wed Oct 5 16:14:56 2016
@@ -481,7 +481,7 @@ bool SBCommandInterpreter::SetCommandOve
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) {
Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=283386&r1=283385&r2=283386&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Wed Oct 5 16:14:56 2016
@@ -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())
Modified: lldb/trunk/source/Expression/REPL.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/REPL.cpp?rev=283386&r1=283385&r2=283386&view=diff
==============================================================================
--- lldb/trunk/source/Expression/REPL.cpp (original)
+++ lldb/trunk/source/Expression/REPL.cpp Wed Oct 5 16:14:56 2016
@@ -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);
Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=283386&r1=283385&r2=283386&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Wed Oct 5 16:14:56 2016
@@ -1162,8 +1162,8 @@ void CommandInterpreter::GetHelp(Command
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::GetCommandObjectForC
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::GetCommandObjectForC
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::GetCommandObjectForC
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;
}
Modified: lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp?rev=283386&r1=283385&r2=283386&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp (original)
+++ lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp Wed Oct 5 16:14:56 2016
@@ -1447,7 +1447,7 @@ void StructuredDataDarwinLog::DebuggerIn
// 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) {
More information about the lldb-commits
mailing list