[Lldb-commits] [lldb] daed98e - Convert CommandObjectCommands functions to return StringRefs

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 26 03:21:02 PDT 2020


Author: Shivam Mittal
Date: 2020-03-26T11:20:38+01:00
New Revision: daed98e5b5d1b4a2ab29b3f757b53519ed070439

URL: https://github.com/llvm/llvm-project/commit/daed98e5b5d1b4a2ab29b3f757b53519ed070439
DIFF: https://github.com/llvm/llvm-project/commit/daed98e5b5d1b4a2ab29b3f757b53519ed070439.diff

LOG: Convert CommandObjectCommands functions to return StringRefs

Reviewers: jingham, aprantl, labath, jankratochvil

Reviewed By: labath, jankratochvil

Subscribers: labath, jankratochvil, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76569

Added: 
    

Modified: 
    lldb/source/Commands/CommandObjectCommands.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index cf5125dc9306..b12377d71512 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -527,14 +527,13 @@ rather than using a positional placeholder:"
     m_option_group.NotifyOptionParsingStarting(&exe_ctx);
 
     OptionsWithRaw args_with_suffix(raw_command_line);
-    const char *remainder = args_with_suffix.GetRawPart().c_str();
 
     if (args_with_suffix.HasArgs())
       if (!ParseOptionsAndNotify(args_with_suffix.GetArgs(), result,
                                  m_option_group, exe_ctx))
         return false;
 
-    llvm::StringRef raw_command_string(remainder);
+    llvm::StringRef raw_command_string = args_with_suffix.GetRawPart();
     Args args(raw_command_string);
 
     if (args.GetArgumentCount() < 2) {
@@ -1171,14 +1170,9 @@ a number follows 'f':"
       return llvm::makeArrayRef(g_regex_options);
     }
 
-    // TODO: Convert these functions to return StringRefs.
-    const char *GetHelp() {
-      return (m_help.empty() ? nullptr : m_help.c_str());
-    }
+    llvm::StringRef GetHelp() { return m_help; }
 
-    const char *GetSyntax() {
-      return (m_syntax.empty() ? nullptr : m_syntax.c_str());
-    }
+    llvm::StringRef GetSyntax() { return m_syntax; }
 
   protected:
     // Instance variables to hold the values for command options.


        


More information about the lldb-commits mailing list