From 867e7d17655367377137393ea7d2fa68268d3001 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 9 Dec 2016 01:20:58 +0000 Subject: [PATCH] Fix some occurrences of passing StringRef to Printf. Hopefully these will all disappear in the future once we move to formatv. llvm-svn: 289168 --- lldb/source/Commands/CommandObjectApropos.cpp | 13 ++++++------- lldb/source/Commands/CommandObjectCommands.cpp | 15 ++++++++------- lldb/source/Commands/CommandObjectFrame.cpp | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lldb/source/Commands/CommandObjectApropos.cpp b/lldb/source/Commands/CommandObjectApropos.cpp index c70d021..b04d08f 100644 --- a/lldb/source/Commands/CommandObjectApropos.cpp +++ b/lldb/source/Commands/CommandObjectApropos.cpp @@ -51,11 +51,10 @@ bool CommandObjectApropos::DoExecute(Args &args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); if (argc == 1) { - const char *search_word = args.GetArgumentAtIndex(0); - if ((search_word != nullptr) && (strlen(search_word) > 0)) { + auto search_word = args[0].ref; + if (!search_word.empty()) { // The bulk of the work must be done inside the Command Interpreter, since - // the command dictionary - // is private. + // the command dictionary is private. StringList commands_found; StringList commands_help; @@ -66,11 +65,11 @@ bool CommandObjectApropos::DoExecute(Args &args, CommandReturnObject &result) { result.AppendMessageWithFormat("No commands found pertaining to '%s'. " "Try 'help' to see a complete list of " "debugger commands.\n", - search_word); + args[0].c_str()); } else { if (commands_found.GetSize() > 0) { result.AppendMessageWithFormat( - "The following commands may relate to '%s':\n", search_word); + "The following commands may relate to '%s':\n", args[0].c_str()); size_t max_len = 0; for (size_t i = 0; i < commands_found.GetSize(); ++i) { @@ -93,7 +92,7 @@ bool CommandObjectApropos::DoExecute(Args &args, CommandReturnObject &result) { const bool dump_qualified_name = true; result.AppendMessageWithFormat( "\nThe following settings variables may relate to '%s': \n\n", - search_word); + args[0].c_str()); for (size_t i = 0; i < num_properties; ++i) properties[i]->DumpDescription( m_interpreter, result.GetOutputStream(), 0, dump_qualified_name); diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 9e9c81b..aa07c10 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -840,7 +840,7 @@ protected: result.AppendErrorWithFormat( "'%s' is not a known command.\nTry 'help' to see a " "current list of commands.\n", - command_name); + args[0].c_str()); result.SetStatus(eReturnStatusFailed); return false; } @@ -850,11 +850,11 @@ protected: result.AppendErrorWithFormat( "'%s' is not an alias, it is a debugger command which can be " "removed using the 'command delete' command.\n", - command_name); + args[0].c_str()); } else { result.AppendErrorWithFormat( "'%s' is a permanent debugger command and cannot be removed.\n", - command_name); + args[0].c_str()); } result.SetStatus(eReturnStatusFailed); return false; @@ -863,10 +863,11 @@ protected: if (!m_interpreter.RemoveAlias(command_name)) { if (m_interpreter.AliasExists(command_name)) result.AppendErrorWithFormat( - "Error occurred while attempting to unalias '%s'.\n", command_name); + "Error occurred while attempting to unalias '%s'.\n", + args[0].c_str()); else result.AppendErrorWithFormat("'%s' is not an existing alias.\n", - command_name); + args[0].c_str()); result.SetStatus(eReturnStatusFailed); return false; } @@ -932,7 +933,7 @@ protected: if (!m_interpreter.RemoveCommand(command_name)) { result.AppendErrorWithFormat( "'%s' is a permanent debugger command and cannot be removed.\n", - command_name); + args[0].c_str()); result.SetStatus(eReturnStatusFailed); return false; } @@ -1882,7 +1883,7 @@ protected: if (cmd_name.empty() || !m_interpreter.HasUserCommands() || !m_interpreter.UserCommandExists(cmd_name)) { - result.AppendErrorWithFormat("command %s not found", cmd_name); + result.AppendErrorWithFormat("command %s not found", command[0].c_str()); result.SetStatus(eReturnStatusFailed); return false; } diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index b2202ad..5a35054 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -375,7 +375,7 @@ protected: if (command.GetArgumentCount() > 1) { result.AppendErrorWithFormat( "too many arguments; expected frame-index, saw '%s'.\n", - command.GetArgumentAtIndex(0)); + command[0].c_str()); m_options.GenerateOptionUsage( result.GetErrorStream(), this, GetCommandInterpreter().GetDebugger().GetTerminalWidth()); -- 2.7.4