[Lldb-commits] [lldb] r283384 - Convert CommandObject constructors to StringRef.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 5 14:14:39 PDT 2016
Author: zturner
Date: Wed Oct 5 16:14:38 2016
New Revision: 283384
URL: http://llvm.org/viewvc/llvm-project?rev=283384&view=rev
Log:
Convert CommandObject constructors to StringRef.
Modified:
lldb/trunk/include/lldb/Core/Stream.h
lldb/trunk/include/lldb/Interpreter/Args.h
lldb/trunk/include/lldb/Interpreter/CommandAlias.h
lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
lldb/trunk/include/lldb/Interpreter/CommandObject.h
lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h
lldb/trunk/source/API/SBCommandInterpreter.cpp
lldb/trunk/source/Commands/CommandObjectArgs.cpp
lldb/trunk/source/Commands/CommandObjectCommands.cpp
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Commands/CommandObjectHelp.cpp
lldb/trunk/source/Commands/CommandObjectMultiword.cpp
lldb/trunk/source/Commands/CommandObjectSettings.cpp
lldb/trunk/source/Commands/CommandObjectSource.cpp
lldb/trunk/source/Commands/CommandObjectSyntax.cpp
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp
lldb/trunk/source/Core/Stream.cpp
lldb/trunk/source/Interpreter/Args.cpp
lldb/trunk/source/Interpreter/CommandAlias.cpp
lldb/trunk/source/Interpreter/CommandInterpreter.cpp
lldb/trunk/source/Interpreter/CommandObject.cpp
lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp
lldb/trunk/source/Interpreter/Options.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Target/LanguageRuntime.cpp
Modified: lldb/trunk/include/lldb/Core/Stream.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Stream.h?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Stream.h (original)
+++ lldb/trunk/include/lldb/Core/Stream.h Wed Oct 5 16:14:38 2016
@@ -441,6 +441,7 @@ public:
/// output the indentation characters.
//------------------------------------------------------------------
size_t Indent(const char *s = nullptr);
+ size_t Indent(llvm::StringRef s);
//------------------------------------------------------------------
/// Decrement the current indentation level.
Modified: lldb/trunk/include/lldb/Interpreter/Args.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Args.h?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/Args.h (original)
+++ lldb/trunk/include/lldb/Interpreter/Args.h Wed Oct 5 16:14:38 2016
@@ -322,12 +322,12 @@ public:
bool IsPositionalArgument(const char *arg);
// The following works almost identically to ParseOptions, except that no
- // option is required to have arguments,
- // and it builds up the option_arg_vector as it parses the options.
+ // option is required to have arguments, and it builds up the
+ // option_arg_vector as it parses the options.
- void ParseAliasOptions(Options &options, CommandReturnObject &result,
- OptionArgVector *option_arg_vector,
- std::string &raw_input_line);
+ std::string ParseAliasOptions(Options &options, CommandReturnObject &result,
+ OptionArgVector *option_arg_vector,
+ llvm::StringRef raw_input_line);
void ParseArgsForCompletion(Options &options,
OptionElementVector &option_element_vector,
Modified: lldb/trunk/include/lldb/Interpreter/CommandAlias.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandAlias.h?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandAlias.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandAlias.h Wed Oct 5 16:14:38 2016
@@ -26,9 +26,9 @@ public:
typedef std::unique_ptr<CommandAlias> UniquePointer;
CommandAlias(CommandInterpreter &interpreter, lldb::CommandObjectSP cmd_sp,
- const char *options_args, const char *name,
- const char *help = nullptr, const char *syntax = nullptr,
- uint32_t flags = 0);
+ llvm::StringRef options_args, llvm::StringRef name,
+ llvm::StringRef help = llvm::StringRef(),
+ llvm::StringRef syntax = llvm::StringRef(), uint32_t flags = 0);
void GetAliasExpansion(StreamString &help_string);
Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Wed Oct 5 16:14:38 2016
@@ -195,20 +195,18 @@ public:
void SourceInitFile(bool in_cwd, CommandReturnObject &result);
- bool AddCommand(const char *name, const lldb::CommandObjectSP &cmd_sp,
+ bool AddCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp,
bool can_replace);
+ bool AddCommand(const char *, const lldb::CommandObjectSP &, bool) = delete;
bool AddUserCommand(std::string name, const lldb::CommandObjectSP &cmd_sp,
bool can_replace);
- lldb::CommandObjectSP GetCommandSPExact(const char *cmd,
- bool include_aliases);
+ lldb::CommandObjectSP GetCommandSPExact(llvm::StringRef cmd,
+ bool include_aliases) const;
- CommandObject *GetCommandObjectExact(const char *cmd_cstr,
- bool include_aliases);
-
- CommandObject *GetCommandObject(const char *cmd,
- StringList *matches = nullptr);
+ CommandObject *GetCommandObject(llvm::StringRef cmd,
+ StringList *matches = nullptr) const;
bool CommandExists(const char *cmd);
@@ -385,13 +383,13 @@ public:
void SetScriptLanguage(lldb::ScriptLanguage lang);
- bool HasCommands();
+ bool HasCommands() const;
- bool HasAliases();
+ bool HasAliases() const;
- bool HasUserCommands();
+ bool HasUserCommands() const;
- bool HasAliasOptions();
+ bool HasAliasOptions() const;
void BuildAliasCommandArgs(CommandObject *alias_cmd_obj,
const char *alias_name, Args &cmd_args,
@@ -510,10 +508,10 @@ protected:
void SetSynchronous(bool value);
- lldb::CommandObjectSP GetCommandSP(const char *cmd,
+ lldb::CommandObjectSP GetCommandSP(llvm::StringRef cmd,
bool include_aliases = true,
bool exact = true,
- StringList *matches = nullptr);
+ StringList *matches = nullptr) const;
private:
Error PreprocessCommand(std::string &command);
Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Wed Oct 5 16:14:38 2016
@@ -35,11 +35,11 @@ namespace lldb_private {
// added.
template <typename ValueType>
-int AddNamesMatchingPartialString(std::map<std::string, ValueType> &in_map,
- const char *cmd_str, StringList &matches) {
+int AddNamesMatchingPartialString(const std::map<std::string, ValueType> &in_map,
+ llvm::StringRef cmd_str, StringList &matches) {
int number_added = 0;
- const bool add_all = ((cmd_str == nullptr) || (cmd_str[0] == 0));
+ const bool add_all = cmd_str.empty();
for (auto iter = in_map.begin(), end = in_map.end(); iter != end; iter++) {
if (add_all || (iter->first.find(cmd_str, 0) == 0)) {
@@ -108,9 +108,8 @@ public:
typedef std::map<std::string, lldb::CommandObjectSP> CommandMap;
- // TODO: Change arguments and all derived classes to use StringRef.
- CommandObject(CommandInterpreter &interpreter, const char *name,
- const char *help = nullptr, const char *syntax = nullptr,
+ CommandObject(CommandInterpreter &interpreter, llvm::StringRef name,
+ llvm::StringRef help = "", llvm::StringRef syntax = "",
uint32_t flags = 0);
virtual ~CommandObject();
@@ -129,7 +128,7 @@ public:
virtual const char *GetSyntax();
- const char *GetCommandName();
+ llvm::StringRef GetCommandName() const;
virtual void SetHelp(const char *str);
@@ -482,8 +481,8 @@ protected:
class CommandObjectRaw : public CommandObject {
public:
- CommandObjectRaw(CommandInterpreter &interpreter, const char *name,
- const char *help = nullptr, const char *syntax = nullptr,
+ CommandObjectRaw(CommandInterpreter &interpreter, llvm::StringRef name,
+ llvm::StringRef help = "", llvm::StringRef syntax = "",
uint32_t flags = 0)
: CommandObject(interpreter, name, help, syntax, flags) {}
Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h Wed Oct 5 16:14:38 2016
@@ -27,9 +27,8 @@ namespace lldb_private {
class CommandObjectRegexCommand : public CommandObjectRaw {
public:
- // TODO: Convert this class to use StringRefs.
- CommandObjectRegexCommand(CommandInterpreter &interpreter, const char *name,
- const char *help, const char *syntax,
+ CommandObjectRegexCommand(CommandInterpreter &interpreter, llvm::StringRef name,
+ llvm::StringRef help, llvm::StringRef syntax,
uint32_t max_matches, uint32_t completion_type_mask,
bool is_removable);
Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommandInterpreter.cpp (original)
+++ lldb/trunk/source/API/SBCommandInterpreter.cpp Wed Oct 5 16:14:38 2016
@@ -538,7 +538,7 @@ SBCommand::SBCommand(lldb::CommandObject
bool SBCommand::IsValid() { return m_opaque_sp.get() != nullptr; }
const char *SBCommand::GetName() {
- return (IsValid() ? m_opaque_sp->GetCommandName() : nullptr);
+ return (IsValid() ? ConstString(m_opaque_sp->GetCommandName()).AsCString() : nullptr);
}
const char *SBCommand::GetHelp() {
Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Wed Oct 5 16:14:38 2016
@@ -148,7 +148,6 @@ bool CommandObjectArgs::DoExecute(Args &
value.SetValueType(Value::eValueTypeScalar);
CompilerType compiler_type;
- llvm::StringRef int_type = arg_type;
std::size_t int_pos = arg_type.find("int");
if (int_pos != llvm::StringRef::npos) {
Encoding encoding = eEncodingSint;
Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Wed Oct 5 16:14:38 2016
@@ -337,7 +337,7 @@ protected:
} else {
result.AppendErrorWithFormat(
"'%s' takes exactly one executable filename argument.\n",
- GetCommandName());
+ GetCommandName().str().c_str());
result.SetStatus(eReturnStatusFailed);
}
return result.Succeeded();
@@ -421,8 +421,7 @@ public:
CommandObjectCommandsAlias(CommandInterpreter &interpreter)
: CommandObjectRaw(
interpreter, "command alias",
- "Define a custom command in terms of an existing command.",
- nullptr),
+ "Define a custom command in terms of an existing command."),
m_option_group(), m_command_options() {
m_option_group.Append(&m_command_options);
m_option_group.Finalize();
@@ -737,7 +736,7 @@ protected:
result.SetStatus(eReturnStatusFailed);
} else {
CommandObjectSP command_obj_sp(
- m_interpreter.GetCommandSPExact(actual_command.c_str(), true));
+ m_interpreter.GetCommandSPExact(actual_command, true));
CommandObjectSP subcommand_obj_sp;
bool use_subcommand = false;
if (command_obj_sp) {
@@ -748,7 +747,7 @@ protected:
while (cmd_obj->IsMultiwordObject() && !args.empty()) {
if (argc >= 3) {
- llvm::StringRef sub_command = args.GetArgumentAtIndex(0);
+ const std::string sub_command = args.GetArgumentAtIndex(0);
assert(!sub_command.empty());
subcommand_obj_sp = cmd_obj->GetSubcommandSP(sub_command.data());
if (subcommand_obj_sp) {
@@ -761,7 +760,7 @@ protected:
result.AppendErrorWithFormat(
"'%s' is not a valid sub-command of '%s'. "
"Unable to create alias.\n",
- sub_command.data(), actual_command.c_str());
+ sub_command.c_str(), actual_command.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -934,7 +933,7 @@ protected:
if (args.empty()) {
result.AppendErrorWithFormat("must call '%s' with one or more valid user "
"defined regular expression command names",
- GetCommandName());
+ GetCommandName().str().c_str());
result.SetStatus(eReturnStatusFailed);
}
@@ -1288,7 +1287,7 @@ public:
CommandObjectPythonFunction(CommandInterpreter &interpreter, std::string name,
std::string funct, std::string help,
ScriptedCommandSynchronicity synch)
- : CommandObjectRaw(interpreter, name.c_str(), nullptr, nullptr),
+ : CommandObjectRaw(interpreter, name),
m_function_name(funct), m_synchro(synch), m_fetched_help_long(false) {
if (!help.empty())
SetHelp(help.c_str());
@@ -1362,7 +1361,7 @@ public:
std::string name,
StructuredData::GenericSP cmd_obj_sp,
ScriptedCommandSynchronicity synch)
- : CommandObjectRaw(interpreter, name.c_str(), nullptr, nullptr),
+ : CommandObjectRaw(interpreter, name),
m_cmd_obj_sp(cmd_obj_sp), m_synchro(synch), m_fetched_help_short(false),
m_fetched_help_long(false) {
StreamString stream;
Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Wed Oct 5 16:14:38 2016
@@ -220,7 +220,7 @@ CommandObjectExpression::CommandObjectEx
interpreter, "expression", "Evaluate an expression on the current "
"thread. Displays any returned value "
"with LLDB's default formatting.",
- nullptr, eCommandProcessMustBePaused | eCommandTryTargetAPILock),
+ "", eCommandProcessMustBePaused | eCommandTryTargetAPILock),
IOHandlerDelegate(IOHandlerDelegate::Completion::Expression),
m_option_group(), m_format_options(eFormatDefault),
m_repl_option(LLDB_OPT_SET_1, false, "repl", 'r', "Drop into REPL", false,
Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Wed Oct 5 16:14:38 2016
@@ -166,7 +166,7 @@ bool CommandObjectHelp::DoExecute(Args &
m_interpreter.GetCommandPrefix(), sub_command.c_str());
result.GetOutputStream().Printf(
"\nThe closest match is '%s'. Help on it follows.\n\n",
- sub_cmd_obj->GetCommandName());
+ sub_cmd_obj->GetCommandName().str().c_str());
}
}
Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Wed Oct 5 16:14:38 2016
@@ -143,7 +143,7 @@ bool CommandObjectMultiword::Execute(con
}
} else {
result.AppendErrorWithFormat("'%s' does not have any subcommands.\n",
- GetCommandName());
+ GetCommandName().str().c_str());
result.SetStatus(eReturnStatusFailed);
}
}
Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Wed Oct 5 16:14:38 2016
@@ -37,8 +37,7 @@ class CommandObjectSettingsSet : public
public:
CommandObjectSettingsSet(CommandInterpreter &interpreter)
: CommandObjectRaw(interpreter, "settings set",
- "Set the value of the specified debugger setting.",
- nullptr),
+ "Set the value of the specified debugger setting."),
m_options() {
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -409,8 +408,7 @@ public:
CommandObjectSettingsRemove(CommandInterpreter &interpreter)
: CommandObjectRaw(interpreter, "settings remove",
"Remove a value from a setting, specified by array "
- "index or dictionary key.",
- nullptr) {
+ "index or dictionary key.") {
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
CommandArgumentData var_name_arg;
@@ -517,8 +515,7 @@ public:
CommandObjectSettingsReplace(CommandInterpreter &interpreter)
: CommandObjectRaw(interpreter, "settings replace",
"Replace the debugger setting value specified by "
- "array index or dictionary key.",
- nullptr) {
+ "array index or dictionary key.") {
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
CommandArgumentEntry arg3;
@@ -629,8 +626,7 @@ public:
: CommandObjectRaw(interpreter, "settings insert-before",
"Insert one or more values into an debugger array "
"setting immediately before the specified element "
- "index.",
- nullptr) {
+ "index.") {
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
CommandArgumentEntry arg3;
@@ -741,8 +737,7 @@ public:
CommandObjectSettingsInsertAfter(CommandInterpreter &interpreter)
: CommandObjectRaw(interpreter, "settings insert-after",
"Insert one or more values into a debugger array "
- "settings after the specified element index.",
- nullptr) {
+ "settings after the specified element index.") {
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
CommandArgumentEntry arg3;
@@ -853,8 +848,7 @@ public:
CommandObjectSettingsAppend(CommandInterpreter &interpreter)
: CommandObjectRaw(interpreter, "settings append",
"Append one or more values to a debugger array, "
- "dictionary, or string setting.",
- nullptr) {
+ "dictionary, or string setting.") {
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
CommandArgumentData var_name_arg;
Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSource.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSource.cpp Wed Oct 5 16:14:38 2016
@@ -585,7 +585,7 @@ protected:
if (argc != 0) {
result.AppendErrorWithFormat("'%s' takes no arguments, only flags.\n",
- GetCommandName());
+ GetCommandName().str().c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -990,7 +990,7 @@ protected:
if (argc != 0) {
result.AppendErrorWithFormat("'%s' takes no arguments, only flags.\n",
- GetCommandName());
+ GetCommandName().str().c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
Modified: lldb/trunk/source/Commands/CommandObjectSyntax.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSyntax.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSyntax.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSyntax.cpp Wed Oct 5 16:14:38 2016
@@ -77,7 +77,7 @@ bool CommandObjectSyntax::DoExecute(Args
output_strm.Printf("\nSyntax: %s\n", cmd_obj->GetSyntax());
output_strm.Printf(
"(Try 'help %s' for more information on command options syntax.)\n",
- cmd_obj->GetCommandName());
+ cmd_obj->GetCommandName().str().c_str());
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else {
output_strm.Printf("\nSyntax: %s\n", cmd_obj->GetSyntax());
Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Wed Oct 5 16:14:38 2016
@@ -3026,7 +3026,7 @@ public:
CommandObjectFormatterInfo(CommandInterpreter &interpreter,
const char *formatter_name,
DiscoveryFunction discovery_func)
- : CommandObjectRaw(interpreter, nullptr, nullptr, nullptr,
+ : CommandObjectRaw(interpreter, "", "", "",
eCommandRequiresFrame),
m_formatter_name(formatter_name ? formatter_name : ""),
m_discovery_function(discovery_func) {
Modified: lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp Wed Oct 5 16:14:38 2016
@@ -990,7 +990,7 @@ public:
"If watchpoint setting fails, consider disable/delete existing "
"ones "
"to free up resources.",
- nullptr,
+ "",
eCommandRequiresFrame | eCommandTryTargetAPILock |
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
m_option_group(), m_option_watchpoint() {
Modified: lldb/trunk/source/Core/Stream.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Stream.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Core/Stream.cpp (original)
+++ lldb/trunk/source/Core/Stream.cpp Wed Oct 5 16:14:38 2016
@@ -205,6 +205,10 @@ size_t Stream::Indent(const char *s) {
return Printf("%*.*s%s", m_indent_level, m_indent_level, "", s ? s : "");
}
+size_t Stream::Indent(llvm::StringRef str) {
+ return Printf("%*.*s%s", m_indent_level, m_indent_level, "", str.str().c_str());
+}
+
//------------------------------------------------------------------
// Stream a character "ch" out to this stream.
//------------------------------------------------------------------
Modified: lldb/trunk/source/Interpreter/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Args.cpp (original)
+++ lldb/trunk/source/Interpreter/Args.cpp Wed Oct 5 16:14:38 2016
@@ -978,9 +978,11 @@ bool Args::IsPositionalArgument(const ch
return is_positional;
}
-void Args::ParseAliasOptions(Options &options, CommandReturnObject &result,
- OptionArgVector *option_arg_vector,
- std::string &raw_input_string) {
+std::string Args::ParseAliasOptions(Options &options,
+ CommandReturnObject &result,
+ OptionArgVector *option_arg_vector,
+ llvm::StringRef raw_input_string) {
+ std::string result_string(raw_input_string);
StreamString sstr;
int i;
Option *long_options = options.GetLongOptions();
@@ -988,7 +990,7 @@ void Args::ParseAliasOptions(Options &op
if (long_options == nullptr) {
result.AppendError("invalid long options");
result.SetStatus(eReturnStatusFailed);
- return;
+ return result_string;
}
for (i = 0; long_options[i].definition != nullptr; ++i) {
@@ -1048,7 +1050,7 @@ void Args::ParseAliasOptions(Options &op
if (long_options_index == -1) {
result.AppendErrorWithFormat("Invalid option with value '%c'.\n", val);
result.SetStatus(eReturnStatusFailed);
- return;
+ return result_string;
}
StreamString option_str;
@@ -1065,7 +1067,7 @@ void Args::ParseAliasOptions(Options &op
"Option '%s' is missing argument specifier.\n",
option_str.GetData());
result.SetStatus(eReturnStatusFailed);
- return;
+ return result_string;
}
LLVM_FALLTHROUGH;
case OptionParser::eOptionalArgument:
@@ -1078,7 +1080,7 @@ void Args::ParseAliasOptions(Options &op
"in has_arg field for option '%c'.\n",
val);
result.SetStatus(eReturnStatusFailed);
- return;
+ return result_string;
}
if (!option_arg)
option_arg = "<no-argument>";
@@ -1092,11 +1094,11 @@ void Args::ParseAliasOptions(Options &op
if (idx == size_t(-1))
continue;
- if (raw_input_string.size() > 0) {
+ if (!result_string.empty()) {
const char *tmp_arg = GetArgumentAtIndex(idx);
- size_t pos = raw_input_string.find(tmp_arg);
+ size_t pos = result_string.find(tmp_arg);
if (pos != std::string::npos)
- raw_input_string.erase(pos, strlen(tmp_arg));
+ result_string.erase(pos, strlen(tmp_arg));
}
ReplaceArgumentAtIndex(idx, llvm::StringRef());
if ((long_options[long_options_index].definition->option_has_arg !=
@@ -1105,15 +1107,16 @@ void Args::ParseAliasOptions(Options &op
(idx + 1 < GetArgumentCount()) &&
(strcmp(OptionParser::GetOptionArgument(),
GetArgumentAtIndex(idx + 1)) == 0)) {
- if (raw_input_string.size() > 0) {
+ if (result_string.size() > 0) {
const char *tmp_arg = GetArgumentAtIndex(idx + 1);
- size_t pos = raw_input_string.find(tmp_arg);
+ size_t pos = result_string.find(tmp_arg);
if (pos != std::string::npos)
- raw_input_string.erase(pos, strlen(tmp_arg));
+ result_string.erase(pos, strlen(tmp_arg));
}
ReplaceArgumentAtIndex(idx + 1, llvm::StringRef());
}
}
+ return result_string;
}
void Args::ParseArgsForCompletion(Options &options,
Modified: lldb/trunk/source/Interpreter/CommandAlias.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandAlias.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandAlias.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandAlias.cpp Wed Oct 5 16:14:38 2016
@@ -1,5 +1,4 @@
-//===-- CommandAlias.cpp ------------------------------------------*- C++
-//-*-===//
+//===-- CommandAlias.cpp -----------------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -22,16 +21,16 @@ using namespace lldb;
using namespace lldb_private;
static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp,
- const char *options_args,
+ llvm::StringRef options_args,
OptionArgVectorSP &option_arg_vector_sp) {
bool success = true;
OptionArgVector *option_arg_vector = option_arg_vector_sp.get();
- if (!options_args || (strlen(options_args) < 1))
+ if (options_args.size() < 1)
return true;
- std::string options_string(options_args);
Args args(options_args);
+ std::string options_string(options_args);
CommandReturnObject result;
// Check to see if the command being aliased can take any command options.
Options *options = cmd_obj_sp->GetOptions();
@@ -42,7 +41,8 @@ static bool ProcessAliasOptionsArgs(lldb
cmd_obj_sp->GetCommandInterpreter().GetExecutionContext();
options->NotifyOptionParsingStarting(&exe_ctx);
args.Unshift(llvm::StringRef("dummy_arg"));
- args.ParseAliasOptions(*options, result, option_arg_vector, options_string);
+ options_string = args.ParseAliasOptions(*options, result, option_arg_vector,
+ options_args);
args.Shift();
if (result.Succeeded())
options->VerifyPartialOptions(result);
@@ -70,11 +70,11 @@ static bool ProcessAliasOptionsArgs(lldb
CommandAlias::CommandAlias(CommandInterpreter &interpreter,
lldb::CommandObjectSP cmd_sp,
- const char *options_args, const char *name,
- const char *help, const char *syntax, uint32_t flags)
+ llvm::StringRef options_args, llvm::StringRef name,
+ llvm::StringRef help, llvm::StringRef syntax,
+ uint32_t flags)
: CommandObject(interpreter, name, help, syntax, flags),
- m_underlying_command_sp(),
- m_option_string(options_args ? options_args : ""),
+ m_underlying_command_sp(), m_option_string(options_args),
m_option_args_sp(new OptionArgVector),
m_is_dashdash_alias(eLazyBoolCalculate), m_did_set_help(false),
m_did_set_help_long(false) {
@@ -85,7 +85,7 @@ CommandAlias::CommandAlias(CommandInterp
i++) {
m_arguments.push_back(*cmd_entry);
}
- if (!help || !help[0]) {
+ if (!help.empty()) {
StreamString sstr;
StreamString translation_and_help;
GetAliasExpansion(sstr);
@@ -144,8 +144,8 @@ bool CommandAlias::Execute(const char *a
}
void CommandAlias::GetAliasExpansion(StreamString &help_string) {
- const char *command_name = m_underlying_command_sp->GetCommandName();
- help_string.Printf("'%s", command_name);
+ llvm::StringRef command_name = m_underlying_command_sp->GetCommandName();
+ help_string.Printf("'%*s", (int)command_name.size(), command_name.data());
if (!m_option_args_sp) {
help_string.Printf("'");
Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Wed Oct 5 16:14:38 2016
@@ -784,17 +784,16 @@ int CommandInterpreter::GetCommandNamesM
return matches.GetSize();
}
-CommandObjectSP CommandInterpreter::GetCommandSP(const char *cmd_cstr,
+CommandObjectSP CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str,
bool include_aliases,
bool exact,
- StringList *matches) {
- CommandObject::CommandMap::iterator pos;
+ StringList *matches) const {
CommandObjectSP command_sp;
- std::string cmd(cmd_cstr);
+ std::string cmd = cmd_str;
if (HasCommands()) {
- pos = m_command_dict.find(cmd);
+ auto pos = m_command_dict.find(cmd);
if (pos != m_command_dict.end())
command_sp = pos->second;
}
@@ -806,7 +805,7 @@ CommandObjectSP CommandInterpreter::GetC
}
if (HasUserCommands()) {
- pos = m_user_dict.find(cmd);
+ auto pos = m_user_dict.find(cmd);
if (pos != m_user_dict.end())
command_sp = pos->second;
}
@@ -831,19 +830,19 @@ CommandObjectSP CommandInterpreter::GetC
if (HasCommands()) {
num_cmd_matches =
- AddNamesMatchingPartialString(m_command_dict, cmd_cstr, *matches);
+ AddNamesMatchingPartialString(m_command_dict, cmd_str, *matches);
}
if (num_cmd_matches == 1) {
cmd.assign(matches->GetStringAtIndex(0));
- pos = m_command_dict.find(cmd);
+ auto pos = m_command_dict.find(cmd);
if (pos != m_command_dict.end())
real_match_sp = pos->second;
}
if (include_aliases && HasAliases()) {
num_alias_matches =
- AddNamesMatchingPartialString(m_alias_dict, cmd_cstr, *matches);
+ AddNamesMatchingPartialString(m_alias_dict, cmd_str, *matches);
}
if (num_alias_matches == 1) {
@@ -855,14 +854,14 @@ CommandObjectSP CommandInterpreter::GetC
if (HasUserCommands()) {
num_user_matches =
- AddNamesMatchingPartialString(m_user_dict, cmd_cstr, *matches);
+ AddNamesMatchingPartialString(m_user_dict, cmd_str, *matches);
}
if (num_user_matches == 1) {
cmd.assign(
matches->GetStringAtIndex(num_cmd_matches + num_alias_matches));
- pos = m_user_dict.find(cmd);
+ auto pos = m_user_dict.find(cmd);
if (pos != m_user_dict.end())
user_match_sp = pos->second;
}
@@ -879,30 +878,32 @@ CommandObjectSP CommandInterpreter::GetC
return user_match_sp;
}
} else if (matches && command_sp) {
- matches->AppendString(cmd_cstr);
+ matches->AppendString(cmd_str);
}
return command_sp;
}
-bool CommandInterpreter::AddCommand(const char *name,
+bool CommandInterpreter::AddCommand(llvm::StringRef name,
const lldb::CommandObjectSP &cmd_sp,
bool can_replace) {
if (cmd_sp.get())
assert((this == &cmd_sp->GetCommandInterpreter()) &&
"tried to add a CommandObject from a different interpreter");
- if (name && name[0]) {
- std::string name_sstr(name);
- bool found = (m_command_dict.find(name_sstr) != m_command_dict.end());
- if (found && !can_replace)
- return false;
- if (found && m_command_dict[name_sstr]->IsRemovable() == false)
+ if (name.empty())
+ return false;
+
+ std::string name_sstr(name);
+ auto name_iter = m_command_dict.find(name_sstr);
+ if (name_iter != m_command_dict.end()) {
+ if (!can_replace || !name_iter->second->IsRemovable())
return false;
+ name_iter->second = cmd_sp;
+ } else {
m_command_dict[name_sstr] = cmd_sp;
- return true;
}
- return false;
+ return true;
}
bool CommandInterpreter::AddUserCommand(std::string name,
@@ -936,21 +937,21 @@ bool CommandInterpreter::AddUserCommand(
return false;
}
-CommandObjectSP CommandInterpreter::GetCommandSPExact(const char *cmd_cstr,
- bool include_aliases) {
- Args cmd_words(cmd_cstr); // Break up the command string into words, in case
+CommandObjectSP CommandInterpreter::GetCommandSPExact(llvm::StringRef cmd_str,
+ bool include_aliases) const {
+ Args cmd_words(cmd_str); // Break up the command string into words, in case
// it's a multi-word command.
CommandObjectSP ret_val; // Possibly empty return value.
- if (cmd_cstr == nullptr)
+ if (cmd_str.empty())
return ret_val;
if (cmd_words.GetArgumentCount() == 1)
- return GetCommandSP(cmd_cstr, include_aliases, true, nullptr);
+ return GetCommandSP(cmd_str, include_aliases, true, nullptr);
else {
// We have a multi-word command (seemingly), so we need to do more work.
// First, get the cmd_obj_sp for the first word in the command.
- CommandObjectSP cmd_obj_sp = GetCommandSP(cmd_words.GetArgumentAtIndex(0),
+ CommandObjectSP cmd_obj_sp = GetCommandSP(llvm::StringRef(cmd_words.GetArgumentAtIndex(0)),
include_aliases, true, nullptr);
if (cmd_obj_sp.get() != nullptr) {
// Loop through the rest of the words in the command (everything passed in
@@ -968,28 +969,22 @@ CommandObjectSP CommandInterpreter::GetC
return ret_val;
} else
// We have more words in the command name, but we don't have a
- // multiword object. Fail and return
- // empty 'ret_val'.
+ // multiword object. Fail and return empty 'ret_val'.
return ret_val;
}
// We successfully looped through all the command words and got valid
- // command objects for them. Assign the
- // last object retrieved to 'ret_val'.
+ // command objects for them. Assign the last object retrieved to
+ // 'ret_val'.
ret_val = cmd_obj_sp;
}
}
return ret_val;
}
-CommandObject *CommandInterpreter::GetCommandObjectExact(const char *cmd_cstr,
- bool include_aliases) {
- return GetCommandSPExact(cmd_cstr, include_aliases).get();
-}
-
-CommandObject *CommandInterpreter::GetCommandObject(const char *cmd_cstr,
- StringList *matches) {
+CommandObject *CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str,
+ StringList *matches) const {
CommandObject *command_obj =
- GetCommandSP(cmd_cstr, false, true, matches).get();
+ GetCommandSP(cmd_str, false, true, matches).get();
// If we didn't find an exact match to the command string in the commands,
// look in
@@ -998,14 +993,14 @@ CommandObject *CommandInterpreter::GetCo
if (command_obj)
return command_obj;
- command_obj = GetCommandSP(cmd_cstr, true, true, matches).get();
+ command_obj = GetCommandSP(cmd_str, true, true, matches).get();
if (command_obj)
return command_obj;
// If there wasn't an exact match then look for an inexact one in just the
// commands
- command_obj = GetCommandSP(cmd_cstr, false, false, nullptr).get();
+ command_obj = GetCommandSP(cmd_str, false, false, nullptr).get();
// Finally, if there wasn't an inexact match among the commands, look for an
// inexact
@@ -1017,7 +1012,7 @@ CommandObject *CommandInterpreter::GetCo
return command_obj;
}
- return GetCommandSP(cmd_cstr, true, false, matches).get();
+ return GetCommandSP(cmd_str, true, false, matches).get();
}
bool CommandInterpreter::CommandExists(const char *cmd) {
@@ -1191,7 +1186,7 @@ CommandInterpreter::GetCommandObjectForC
// 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.
- cmd_obj = GetCommandObject(cmd_word.c_str());
+ 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
// valid sub-command for our object.
@@ -1338,7 +1333,7 @@ CommandObject *CommandInterpreter::Build
(alias_name_str.compare(cmd_args.GetArgumentAtIndex(0)) != 0))
cmd_args.Unshift(alias_name_str);
- result_str.Printf("%s", alias_cmd_obj->GetCommandName());
+ result_str.Printf("%s", alias_cmd_obj->GetCommandName().str().c_str());
if (!option_arg_vector_sp.get()) {
alias_result = result_str.GetData();
@@ -1647,10 +1642,9 @@ bool CommandInterpreter::HandleCommand(c
// Although the user may have abbreviated the command, the command_string now
// has the command expanded to the full name. For example, if the input
// was "br s -n main", command_string is now "breakpoint set -n main".
-
if (log) {
- log->Printf("HandleCommand, cmd_obj : '%s'",
- cmd_obj ? cmd_obj->GetCommandName() : "<not found>");
+ llvm::StringRef command_name = cmd_obj ? cmd_obj->GetCommandName() : "<not found>";
+ log->Printf("HandleCommand, cmd_obj : '%s'", command_name.str().c_str());
log->Printf("HandleCommand, (revised) command_string: '%s'",
command_string.c_str());
const bool wants_raw_input =
@@ -1677,7 +1671,7 @@ bool CommandInterpreter::HandleCommand(c
}
std::string remainder;
- const std::size_t actual_cmd_name_len = strlen(cmd_obj->GetCommandName());
+ const std::size_t actual_cmd_name_len = cmd_obj->GetCommandName().size();
if (actual_cmd_name_len < command_string.length())
remainder = command_string.substr(actual_cmd_name_len);
@@ -1935,13 +1929,13 @@ CommandAlias *CommandInterpreter::GetAli
return nullptr;
}
-bool CommandInterpreter::HasCommands() { return (!m_command_dict.empty()); }
+bool CommandInterpreter::HasCommands() const { return (!m_command_dict.empty()); }
-bool CommandInterpreter::HasAliases() { return (!m_alias_dict.empty()); }
+bool CommandInterpreter::HasAliases() const { return (!m_alias_dict.empty()); }
-bool CommandInterpreter::HasUserCommands() { return (!m_user_dict.empty()); }
+bool CommandInterpreter::HasUserCommands() const { return (!m_user_dict.empty()); }
-bool CommandInterpreter::HasAliasOptions() { return HasAliases(); }
+bool CommandInterpreter::HasAliasOptions() const { return HasAliases(); }
void CommandInterpreter::BuildAliasCommandArgs(CommandObject *alias_cmd_obj,
const char *alias_name,
@@ -2949,7 +2943,7 @@ CommandInterpreter::ResolveCommandImpl(s
if (cmd_obj == nullptr) {
std::string full_name;
bool is_alias = GetAliasFullName(next_word.c_str(), full_name);
- cmd_obj = GetCommandObject(next_word.c_str(), &matches);
+ cmd_obj = GetCommandObject(next_word, &matches);
bool is_real_command =
(is_alias == false) ||
(cmd_obj != nullptr && cmd_obj->IsAlias() == false);
@@ -2961,14 +2955,15 @@ CommandInterpreter::ResolveCommandImpl(s
revised_command_line.Printf("%s", alias_result.c_str());
if (cmd_obj) {
wants_raw_input = cmd_obj->WantsRawCommandString();
- actual_cmd_name_len = strlen(cmd_obj->GetCommandName());
+ actual_cmd_name_len = cmd_obj->GetCommandName().size();
}
} else {
if (!cmd_obj)
- cmd_obj = GetCommandObject(next_word.c_str(), &matches);
+ cmd_obj = GetCommandObject(next_word, &matches);
if (cmd_obj) {
- actual_cmd_name_len += strlen(cmd_obj->GetCommandName());
- revised_command_line.Printf("%s", cmd_obj->GetCommandName());
+ llvm::StringRef cmd_name = cmd_obj->GetCommandName();
+ actual_cmd_name_len += cmd_name.size();
+ revised_command_line.Printf("%s", cmd_name.str().c_str());
wants_raw_input = cmd_obj->WantsRawCommandString();
} else {
revised_command_line.Printf("%s", next_word.c_str());
@@ -2981,9 +2976,10 @@ CommandInterpreter::ResolveCommandImpl(s
if (sub_cmd_obj) {
// The subcommand's name includes the parent command's name,
// so restart rather than append to the revised_command_line.
- actual_cmd_name_len = strlen(sub_cmd_obj->GetCommandName()) + 1;
+ llvm::StringRef sub_cmd_name = sub_cmd_obj->GetCommandName();
+ actual_cmd_name_len = sub_cmd_name.size() + 1;
revised_command_line.Clear();
- revised_command_line.Printf("%s", sub_cmd_obj->GetCommandName());
+ revised_command_line.Printf("%s", sub_cmd_name.str().c_str());
cmd_obj = sub_cmd_obj;
wants_raw_input = cmd_obj->WantsRawCommandString();
} else {
@@ -3034,7 +3030,7 @@ CommandInterpreter::ResolveCommandImpl(s
result.AppendErrorWithFormat(
"command '%s' did not recognize '%s%s%s' as valid (subcommand "
"might be invalid).\n",
- cmd_obj->GetCommandName(),
+ cmd_obj->GetCommandName().str().c_str(),
next_word.empty() ? "" : next_word.c_str(),
next_word.empty() ? " -- " : " ", suffix.c_str());
result.SetStatus(eReturnStatusFailed);
@@ -3074,7 +3070,7 @@ CommandInterpreter::ResolveCommandImpl(s
} else {
result.AppendErrorWithFormat(
"the '%s' command doesn't support the --gdb-format option\n",
- cmd_obj->GetCommandName());
+ cmd_obj->GetCommandName().str().c_str());
result.SetStatus(eReturnStatusFailed);
return nullptr;
}
Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObject.cpp Wed Oct 5 16:14:38 2016
@@ -40,17 +40,14 @@ using namespace lldb_private;
// CommandObject
//-------------------------------------------------------------------------
-CommandObject::CommandObject(CommandInterpreter &interpreter, const char *name,
- const char *help, const char *syntax,
- uint32_t flags)
- : m_interpreter(interpreter), m_cmd_name(name ? name : ""),
+CommandObject::CommandObject(CommandInterpreter &interpreter, llvm::StringRef name,
+ llvm::StringRef help, llvm::StringRef syntax, uint32_t flags)
+ : m_interpreter(interpreter), m_cmd_name(name),
m_cmd_help_short(), m_cmd_help_long(), m_cmd_syntax(), m_flags(flags),
m_arguments(), m_deprecated_command_override_callback(nullptr),
m_command_override_callback(nullptr), m_command_override_baton(nullptr) {
- if (help && help[0])
- m_cmd_help_short = help;
- if (syntax && syntax[0])
- m_cmd_syntax = syntax;
+ m_cmd_help_short = help;
+ m_cmd_syntax = syntax;
}
CommandObject::~CommandObject() {}
@@ -62,7 +59,7 @@ const char *CommandObject::GetHelpLong()
const char *CommandObject::GetSyntax() {
if (m_cmd_syntax.length() == 0) {
StreamString syntax_str;
- syntax_str.Printf("%s", GetCommandName());
+ syntax_str.Printf("%s", GetCommandName().str().c_str());
if (!IsDashDashCommand() && GetOptions() != nullptr)
syntax_str.Printf(" <cmd-options>");
if (m_arguments.size() > 0) {
@@ -78,7 +75,7 @@ const char *CommandObject::GetSyntax() {
return m_cmd_syntax.c_str();
}
-const char *CommandObject::GetCommandName() { return m_cmd_name.c_str(); }
+llvm::StringRef CommandObject::GetCommandName() const { return m_cmd_name; }
void CommandObject::SetCommandName(const char *name) { m_cmd_name = name; }
Modified: lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp Wed Oct 5 16:14:38 2016
@@ -23,8 +23,8 @@ using namespace lldb_private;
// CommandObjectRegexCommand constructor
//----------------------------------------------------------------------
CommandObjectRegexCommand::CommandObjectRegexCommand(
- CommandInterpreter &interpreter, const char *name, const char *help,
- const char *syntax, uint32_t max_matches, uint32_t completion_type_mask,
+ CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help,
+ llvm::StringRef syntax, uint32_t max_matches, uint32_t completion_type_mask,
bool is_removable)
: CommandObjectRaw(interpreter, name, help, syntax),
m_max_matches(max_matches), m_completion_type_mask(completion_type_mask),
Modified: lldb/trunk/source/Interpreter/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Options.cpp (original)
+++ lldb/trunk/source/Interpreter/Options.cpp Wed Oct 5 16:14:38 2016
@@ -406,7 +406,7 @@ void Options::GenerateOptionUsage(Stream
auto opt_defs = GetDefinitions();
const uint32_t save_indent_level = strm.GetIndentLevel();
- const char *name;
+ llvm::StringRef name;
StreamString arguments_str;
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Oct 5 16:14:38 2016
@@ -5058,8 +5058,7 @@ public:
"and print the response."
"The argument passed to this command will be hex "
"encoded into a valid 'qRcmd' packet, sent and the "
- "response will be printed.",
- NULL) {}
+ "response will be printed.") {}
~CommandObjectProcessGDBRemotePacketMonitor() {}
Modified: lldb/trunk/source/Target/LanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/LanguageRuntime.cpp?rev=283384&r1=283383&r2=283384&view=diff
==============================================================================
--- lldb/trunk/source/Target/LanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/LanguageRuntime.cpp Wed Oct 5 16:14:38 2016
@@ -287,12 +287,10 @@ void LanguageRuntime::InitializeCommands
command_callback(parent->GetCommandInterpreter());
if (command) {
// the CommandObject vended by a Language plugin cannot be created once
- // and cached because
- // we may create multiple debuggers and need one instance of the command
- // each - the implementing function
- // is meant to create a new instance of the command each time it is
- // invoked
- parent->LoadSubCommand(command->GetCommandName(), command);
+ // and cached because we may create multiple debuggers and need one
+ // instance of the command each - the implementing function is meant to
+ // create a new instance of the command each time it is invoked.
+ parent->LoadSubCommand(command->GetCommandName().str().c_str(), command);
}
}
}
More information about the lldb-commits
mailing list