[Lldb-commits] [lldb] r289168 - Fix some occurrences of passing StringRef to Printf.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 8 17:20:59 PST 2016


Author: zturner
Date: Thu Dec  8 19:20:58 2016
New Revision: 289168

URL: http://llvm.org/viewvc/llvm-project?rev=289168&view=rev
Log:
Fix some occurrences of passing StringRef to Printf.

Hopefully these will all disappear in the future once we move
to formatv.

Modified:
    lldb/trunk/source/Commands/CommandObjectApropos.cpp
    lldb/trunk/source/Commands/CommandObjectCommands.cpp
    lldb/trunk/source/Commands/CommandObjectFrame.cpp

Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.cpp?rev=289168&r1=289167&r2=289168&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectApropos.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectApropos.cpp Thu Dec  8 19:20:58 2016
@@ -51,11 +51,10 @@ bool CommandObjectApropos::DoExecute(Arg
   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(Arg
         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(Arg
         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);

Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=289168&r1=289167&r2=289168&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Thu Dec  8 19:20:58 2016
@@ -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;
     }

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=289168&r1=289167&r2=289168&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Thu Dec  8 19:20:58 2016
@@ -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());




More information about the lldb-commits mailing list