[Lldb-commits] [lldb] r287155 - Update GenerateAdditionalHelpAvenues to take StringRef.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 16 13:34:22 PST 2016


Author: zturner
Date: Wed Nov 16 15:34:22 2016
New Revision: 287155

URL: http://llvm.org/viewvc/llvm-project?rev=287155&view=rev
Log:
Update GenerateAdditionalHelpAvenues to take StringRef.

Modified:
    lldb/trunk/source/Commands/CommandObjectCommands.cpp
    lldb/trunk/source/Commands/CommandObjectHelp.cpp
    lldb/trunk/source/Commands/CommandObjectHelp.h
    lldb/trunk/source/Commands/CommandObjectSyntax.cpp

Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=287155&r1=287154&r2=287155&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Wed Nov 16 15:34:22 2016
@@ -946,7 +946,7 @@ protected:
       const bool generate_apropos = true;
       const bool generate_type_lookup = false;
       CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage(
-          &error_msg_stream, command_name, nullptr, nullptr, generate_apropos,
+          &error_msg_stream, command_name, llvm::StringRef(), llvm::StringRef(), generate_apropos,
           generate_type_lookup);
       result.AppendError(error_msg_stream.GetString());
       result.SetStatus(eReturnStatusFailed);

Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=287155&r1=287154&r2=287155&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Wed Nov 16 15:34:22 2016
@@ -25,21 +25,26 @@ using namespace lldb_private;
 //-------------------------------------------------------------------------
 
 void CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage(
-    Stream *s, const char *command, const char *prefix, const char *subcommand,
+    Stream *s, llvm::StringRef command, llvm::StringRef prefix, llvm::StringRef subcommand,
     bool include_apropos, bool include_type_lookup) {
-  if (s && command && *command) {
-    s->Printf("'%s' is not a known command.\n", command);
-    s->Printf("Try '%shelp' to see a current list of commands.\n",
-              prefix ? prefix : "");
-    if (include_apropos) {
-      s->Printf("Try '%sapropos %s' for a list of related commands.\n",
-                prefix ? prefix : "", subcommand ? subcommand : command);
-    }
-    if (include_type_lookup) {
-      s->Printf("Try '%stype lookup %s' for information on types, methods, "
-                "functions, modules, etc.",
-                prefix ? prefix : "", subcommand ? subcommand : command);
-    }
+  if (!s || command.empty())
+    return;
+
+  std::string command_str = command.str();
+  std::string prefix_str = prefix.str();
+  std::string subcommand_str = subcommand.str();
+  const std::string &lookup_str = !subcommand_str.empty() ? subcommand_str : command_str;
+  s->Printf("'%s' is not a known command.\n", command_str.c_str());
+  s->Printf("Try '%shelp' to see a current list of commands.\n",
+            prefix.str().c_str());
+  if (include_apropos) {
+    s->Printf("Try '%sapropos %s' for a list of related commands.\n",
+      prefix_str.c_str(), lookup_str.c_str());
+  }
+  if (include_type_lookup) {
+    s->Printf("Try '%stype lookup %s' for information on types, methods, "
+              "functions, modules, etc.",
+      prefix_str.c_str(), lookup_str.c_str());
   }
 }
 
@@ -198,7 +203,7 @@ bool CommandObjectHelp::DoExecute(Args &
         StreamString error_msg_stream;
         GenerateAdditionalHelpAvenuesMessage(&error_msg_stream,
                                              command.GetArgumentAtIndex(0),
-                                             m_interpreter.GetCommandPrefix());
+                                             m_interpreter.GetCommandPrefix(), "");
         result.AppendError(error_msg_stream.GetString());
         result.SetStatus(eReturnStatusFailed);
       }

Modified: lldb/trunk/source/Commands/CommandObjectHelp.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.h?rev=287155&r1=287154&r2=287155&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectHelp.h (original)
+++ lldb/trunk/source/Commands/CommandObjectHelp.h Wed Nov 16 15:34:22 2016
@@ -35,8 +35,8 @@ public:
                        StringList &matches) override;
 
   static void GenerateAdditionalHelpAvenuesMessage(
-      Stream *s, const char *command, const char *prefix = nullptr,
-      const char *subcommand = nullptr, bool include_apropos = true,
+      Stream *s, llvm::StringRef command, llvm::StringRef prefix,
+      llvm::StringRef subcommand, bool include_apropos = true,
       bool include_type_lookup = true);
 
   class CommandOptions : public Options {

Modified: lldb/trunk/source/Commands/CommandObjectSyntax.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSyntax.cpp?rev=287155&r1=287154&r2=287155&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSyntax.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSyntax.cpp Wed Nov 16 15:34:22 2016
@@ -93,7 +93,7 @@ bool CommandObjectSyntax::DoExecute(Args
       const bool generate_apropos = true;
       const bool generate_type_lookup = false;
       CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage(
-          &error_msg_stream, cmd_string.c_str(), nullptr, nullptr,
+          &error_msg_stream, cmd_string, "", "",
           generate_apropos, generate_type_lookup);
       result.AppendErrorWithFormat("%s", error_msg_stream.GetData());
       result.SetStatus(eReturnStatusFailed);




More information about the lldb-commits mailing list