Fix some occurrences of passing StringRef to Printf.
authorZachary Turner <zturner@google.com>
Fri, 9 Dec 2016 01:20:58 +0000 (01:20 +0000)
committerZachary Turner <zturner@google.com>
Fri, 9 Dec 2016 01:20:58 +0000 (01:20 +0000)
Hopefully these will all disappear in the future once we move
to formatv.

llvm-svn: 289168

lldb/source/Commands/CommandObjectApropos.cpp
lldb/source/Commands/CommandObjectCommands.cpp
lldb/source/Commands/CommandObjectFrame.cpp

index c70d021..b04d08f 100644 (file)
@@ -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);
index 9e9c81b..aa07c10 100644 (file)
@@ -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;
     }
index b2202ad..5a35054 100644 (file)
@@ -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());