Change some more CommandObject functions to StringRef.
authorZachary Turner <zturner@google.com>
Sun, 13 Nov 2016 02:50:32 +0000 (02:50 +0000)
committerZachary Turner <zturner@google.com>
Sun, 13 Nov 2016 02:50:32 +0000 (02:50 +0000)
llvm-svn: 286742

lldb/include/lldb/Interpreter/CommandObject.h
lldb/include/lldb/Interpreter/CommandObjectMultiword.h
lldb/source/Commands/CommandObjectMultiword.cpp
lldb/source/Interpreter/CommandObject.cpp

index 344e9b6..e73fce8 100644 (file)
@@ -152,18 +152,18 @@ public:
   // hint to the help system that one cannot pass options to this command
   virtual bool IsDashDashCommand() { return false; }
 
-  virtual lldb::CommandObjectSP GetSubcommandSP(const char *sub_cmd,
+  virtual lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
                                                 StringList *matches = nullptr) {
     return lldb::CommandObjectSP();
   }
 
-  virtual CommandObject *GetSubcommandObject(const char *sub_cmd,
+  virtual CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
                                              StringList *matches = nullptr) {
     return nullptr;
   }
 
-  virtual void AproposAllSubCommands(const char *prefix,
-                                     const char *search_word,
+  virtual void AproposAllSubCommands(llvm::StringRef prefix,
+                                     llvm::StringRef search_word,
                                      StringList &commands_found,
                                      StringList &commands_help) {}
 
@@ -177,7 +177,7 @@ public:
   // transparently try and load subcommands - it will fail on
   // anything but a multiword command, but it avoids us doing
   // type checkings and casts
-  virtual bool LoadSubCommand(const char *cmd_name,
+  virtual bool LoadSubCommand(llvm::StringRef cmd_name,
                               const lldb::CommandObjectSP &command_obj) {
     return false;
   }
@@ -324,7 +324,7 @@ public:
     return 0;
   }
 
-  bool HelpTextContainsWord(const char *search_word,
+  bool HelpTextContainsWord(llvm::StringRef search_word,
                             bool search_short_help = true,
                             bool search_long_help = true,
                             bool search_syntax = true,
index c36f9d1..947272f 100644 (file)
@@ -38,18 +38,19 @@ public:
 
   CommandObjectMultiword *GetAsMultiwordCommand() override { return this; }
 
-  bool LoadSubCommand(const char *cmd_name,
+  bool LoadSubCommand(llvm::StringRef cmd_name,
                       const lldb::CommandObjectSP &command_obj) override;
 
   void GenerateHelpText(Stream &output_stream) override;
 
-  lldb::CommandObjectSP GetSubcommandSP(const char *sub_cmd,
+  lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
                                         StringList *matches = nullptr) override;
 
-  CommandObject *GetSubcommandObject(const char *sub_cmd,
+  CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
                                      StringList *matches = nullptr) override;
 
-  void AproposAllSubCommands(const char *prefix, const char *search_word,
+  void AproposAllSubCommands(llvm::StringRef prefix,
+                             llvm::StringRef search_word,
                              StringList &commands_found,
                              StringList &commands_help) override;
 
@@ -100,17 +101,18 @@ public:
 
   void GenerateHelpText(Stream &result) override;
 
-  lldb::CommandObjectSP GetSubcommandSP(const char *sub_cmd,
+  lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
                                         StringList *matches = nullptr) override;
 
-  CommandObject *GetSubcommandObject(const char *sub_cmd,
+  CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
                                      StringList *matches = nullptr) override;
 
-  void AproposAllSubCommands(const char *prefix, const char *search_word,
+  void AproposAllSubCommands(llvm::StringRef prefix,
+                             llvm::StringRef search_word,
                              StringList &commands_found,
                              StringList &commands_help) override;
 
-  bool LoadSubCommand(const char *cmd_name,
+  bool LoadSubCommand(llvm::StringRef cmd_name,
                       const lldb::CommandObjectSP &command_obj) override;
 
   bool WantsRawCommandString() override;
index 249863b..bcc0229 100644 (file)
@@ -34,7 +34,7 @@ CommandObjectMultiword::CommandObjectMultiword(CommandInterpreter &interpreter,
 
 CommandObjectMultiword::~CommandObjectMultiword() = default;
 
-CommandObjectSP CommandObjectMultiword::GetSubcommandSP(const char *sub_cmd,
+CommandObjectSP CommandObjectMultiword::GetSubcommandSP(llvm::StringRef sub_cmd,
                                                         StringList *matches) {
   CommandObjectSP return_cmd_sp;
   CommandObject::CommandMap::iterator pos;
@@ -69,12 +69,12 @@ CommandObjectSP CommandObjectMultiword::GetSubcommandSP(const char *sub_cmd,
 }
 
 CommandObject *
-CommandObjectMultiword::GetSubcommandObject(const char *sub_cmd,
+CommandObjectMultiword::GetSubcommandObject(llvm::StringRef sub_cmd,
                                             StringList *matches) {
   return GetSubcommandSP(sub_cmd, matches).get();
 }
 
-bool CommandObjectMultiword::LoadSubCommand(const char *name,
+bool CommandObjectMultiword::LoadSubCommand(llvm::StringRef name,
                                             const CommandObjectSP &cmd_obj) {
   if (cmd_obj)
     assert((&GetCommandInterpreter() == &cmd_obj->GetCommandInterpreter()) &&
@@ -246,8 +246,8 @@ const char *CommandObjectMultiword::GetRepeatCommand(Args &current_command_args,
   return sub_command_object->GetRepeatCommand(current_command_args, index);
 }
 
-void CommandObjectMultiword::AproposAllSubCommands(const char *prefix,
-                                                   const char *search_word,
+void CommandObjectMultiword::AproposAllSubCommands(llvm::StringRef prefix,
+                                                   llvm::StringRef search_word,
                                                    StringList &commands_found,
                                                    StringList &commands_help) {
   CommandObject::CommandMap::const_iterator pos;
@@ -265,7 +265,7 @@ void CommandObjectMultiword::AproposAllSubCommands(const char *prefix,
     }
 
     if (sub_cmd_obj->IsMultiwordObject())
-      sub_cmd_obj->AproposAllSubCommands(complete_command_name.GetData(),
+      sub_cmd_obj->AproposAllSubCommands(complete_command_name.GetString(),
                                          search_word, commands_found,
                                          commands_help);
   }
@@ -313,15 +313,16 @@ void CommandObjectProxy::GenerateHelpText(Stream &result) {
     return proxy_command->GenerateHelpText(result);
 }
 
-lldb::CommandObjectSP CommandObjectProxy::GetSubcommandSP(const char *sub_cmd,
-                                                          StringList *matches) {
+lldb::CommandObjectSP
+CommandObjectProxy::GetSubcommandSP(llvm::StringRef sub_cmd,
+                                    StringList *matches) {
   CommandObject *proxy_command = GetProxyCommandObject();
   if (proxy_command)
     return proxy_command->GetSubcommandSP(sub_cmd, matches);
   return lldb::CommandObjectSP();
 }
 
-CommandObject *CommandObjectProxy::GetSubcommandObject(const char *sub_cmd,
+CommandObject *CommandObjectProxy::GetSubcommandObject(llvm::StringRef sub_cmd,
                                                        StringList *matches) {
   CommandObject *proxy_command = GetProxyCommandObject();
   if (proxy_command)
@@ -329,8 +330,8 @@ CommandObject *CommandObjectProxy::GetSubcommandObject(const char *sub_cmd,
   return nullptr;
 }
 
-void CommandObjectProxy::AproposAllSubCommands(const char *prefix,
-                                               const char *search_word,
+void CommandObjectProxy::AproposAllSubCommands(llvm::StringRef prefix,
+                                               llvm::StringRef search_word,
                                                StringList &commands_found,
                                                StringList &commands_help) {
   CommandObject *proxy_command = GetProxyCommandObject();
@@ -340,7 +341,7 @@ void CommandObjectProxy::AproposAllSubCommands(const char *prefix,
 }
 
 bool CommandObjectProxy::LoadSubCommand(
-    const char *cmd_name, const lldb::CommandObjectSP &command_sp) {
+    llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_sp) {
   CommandObject *proxy_command = GetProxyCommandObject();
   if (proxy_command)
     return proxy_command->LoadSubCommand(cmd_name, command_sp);
index e71c109..c9337a5 100644 (file)
@@ -316,7 +316,7 @@ int CommandObject::HandleCompletion(Args &input, int &cursor_index,
   }
 }
 
-bool CommandObject::HelpTextContainsWord(const char *search_word,
+bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word,
                                          bool search_short_help,
                                          bool search_long_help,
                                          bool search_syntax,
@@ -341,9 +341,9 @@ bool CommandObject::HelpTextContainsWord(const char *search_word,
     GetOptions()->GenerateOptionUsage(
         usage_help, this,
         GetCommandInterpreter().GetDebugger().GetTerminalWidth());
-    if (usage_help.GetSize() > 0) {
-      const char *usage_text = usage_help.GetData();
-      if (strcasestr(usage_text, search_word))
+    if (!usage_help.Empty()) {
+      llvm::StringRef usage_text = usage_help.GetString();
+      if (usage_text.contains_lower(search_word))
         found_word = true;
     }
   }