Make Options::SetOptionValue take a StringRef.

llvm-svn: 286723
diff --git a/lldb/include/lldb/Interpreter/Options.h b/lldb/include/lldb/Interpreter/Options.h
index 2fecd7c..fc5ff97 100644
--- a/lldb/include/lldb/Interpreter/Options.h
+++ b/lldb/include/lldb/Interpreter/Options.h
@@ -192,8 +192,7 @@
   /// @see Args::ParseOptions (Options&)
   /// @see man getopt_long_only
   //------------------------------------------------------------------
-  // TODO: Make this function take a StringRef.
-  virtual Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+  virtual Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                                ExecutionContext *execution_context) = 0;
 
   //------------------------------------------------------------------
@@ -344,7 +343,6 @@
   virtual Error SetOptionValue(uint32_t option_idx,
                                llvm::StringRef option_value,
                                ExecutionContext *execution_context) = 0;
-  Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
 
   virtual void OptionParsingStarting(ExecutionContext *execution_context) = 0;
 
@@ -403,7 +401,7 @@
 
   bool DidFinalize() { return m_did_finalize; }
 
-  Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+  Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                        ExecutionContext *execution_context) override;
 
   void OptionParsingStarting(ExecutionContext *execution_context) override;
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index f2add84..0f06ca7 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -214,12 +214,7 @@
     return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str());
   }
 
-  void SetProcessPluginName(const char *plugin) {
-    if (plugin && plugin[0])
-      m_plugin_name.assign(plugin);
-    else
-      m_plugin_name.clear();
-  }
+  void SetProcessPluginName(llvm::StringRef plugin) { m_plugin_name = plugin; }
 
   void Clear() {
     ProcessInstanceInfo::Clear();
@@ -285,7 +280,7 @@
 
   ~ProcessLaunchCommandOptions() override = default;
 
-  Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+  Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                        ExecutionContext *execution_context) override;
 
   void OptionParsingStarting(ExecutionContext *execution_context) override {
diff --git a/lldb/include/lldb/Target/ProcessLaunchInfo.h b/lldb/include/lldb/Target/ProcessLaunchInfo.h
index 755277a..2c192c2 100644
--- a/lldb/include/lldb/Target/ProcessLaunchInfo.h
+++ b/lldb/include/lldb/Target/ProcessLaunchInfo.h
@@ -69,7 +69,7 @@
 
   const char *GetProcessPluginName() const;
 
-  void SetProcessPluginName(const char *plugin);
+  void SetProcessPluginName(llvm::StringRef plugin);
 
   const FileSpec &GetShell() const;
 
diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp
index 6949139..d98a246 100644
--- a/lldb/source/Commands/CommandObjectArgs.cpp
+++ b/lldb/source/Commands/CommandObjectArgs.cpp
@@ -55,7 +55,7 @@
 CommandObjectArgs::CommandOptions::~CommandOptions() = default;
 
 Error CommandObjectArgs::CommandOptions::SetOptionValue(
-    uint32_t option_idx, const char *option_arg,
+    uint32_t option_idx, llvm::StringRef option_arg,
     ExecutionContext *execution_context) {
   Error error;
 
diff --git a/lldb/source/Commands/CommandObjectArgs.h b/lldb/source/Commands/CommandObjectArgs.h
index 9817c53..a4b3f9f 100644
--- a/lldb/source/Commands/CommandObjectArgs.h
+++ b/lldb/source/Commands/CommandObjectArgs.h
@@ -27,7 +27,7 @@
 
     ~CommandOptions() override;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override;
 
     void OptionParsingStarting(ExecutionContext *execution_context) override;
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index dcf6fa2..a144e1e 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -178,11 +178,10 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
-      llvm::StringRef option_strref(option_arg ? option_arg : "");
 
       switch (short_option) {
       case 'a': {
@@ -199,14 +198,11 @@
         m_func_name_type_mask |= eFunctionNameTypeBase;
         break;
 
-      case 'C': {
-        bool success;
-        m_column = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-        if (!success)
+      case 'C':
+        if (option_arg.getAsInteger(0, m_column))
           error.SetErrorStringWithFormat("invalid column number: %s",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
-      }
 
       case 'c':
         m_condition.assign(option_arg);
@@ -217,8 +213,7 @@
         break;
 
       case 'E': {
-        LanguageType language =
-            Language::GetLanguageTypeFromString(option_strref);
+        LanguageType language = Language::GetLanguageTypeFromString(option_arg);
 
         switch (language) {
         case eLanguageTypeC89:
@@ -243,12 +238,12 @@
         case eLanguageTypeUnknown:
           error.SetErrorStringWithFormat(
               "Unknown language type: '%s' for exception breakpoint",
-              option_arg);
+              option_arg.str().c_str());
           break;
         default:
           error.SetErrorStringWithFormat(
               "Unsupported language type: '%s' for exception breakpoint",
-              option_arg);
+              option_arg.str().c_str());
         }
       } break;
 
@@ -263,10 +258,11 @@
 
       case 'h': {
         bool success;
-        m_catch_bp = Args::StringToBoolean(option_strref, true, &success);
+        m_catch_bp = Args::StringToBoolean(option_arg, true, &success);
         if (!success)
           error.SetErrorStringWithFormat(
-              "Invalid boolean value for on-catch option: '%s'", option_arg);
+              "Invalid boolean value for on-catch option: '%s'",
+              option_arg.str().c_str());
       } break;
 
       case 'H':
@@ -274,16 +270,15 @@
         break;
 
       case 'i':
-        m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
-        if (m_ignore_count == UINT32_MAX)
+        if (option_arg.getAsInteger(0, m_ignore_count))
           error.SetErrorStringWithFormat("invalid ignore count '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
 
       case 'K': {
         bool success;
         bool value;
-        value = Args::StringToBoolean(option_strref, true, &success);
+        value = Args::StringToBoolean(option_arg, true, &success);
         if (value)
           m_skip_prologue = eLazyBoolYes;
         else
@@ -292,29 +287,27 @@
         if (!success)
           error.SetErrorStringWithFormat(
               "Invalid boolean value for skip prologue option: '%s'",
-              option_arg);
+              option_arg.str().c_str());
       } break;
 
-      case 'l': {
-        bool success;
-        m_line_num = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-        if (!success)
+      case 'l':
+        if (option_arg.getAsInteger(0, m_line_num))
           error.SetErrorStringWithFormat("invalid line number: %s.",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
-      }
 
       case 'L':
-        m_language = Language::GetLanguageTypeFromString(option_strref);
+        m_language = Language::GetLanguageTypeFromString(option_arg);
         if (m_language == eLanguageTypeUnknown)
           error.SetErrorStringWithFormat(
-              "Unknown language type: '%s' for breakpoint", option_arg);
+              "Unknown language type: '%s' for breakpoint",
+              option_arg.str().c_str());
         break;
 
       case 'm': {
         bool success;
         bool value;
-        value = Args::StringToBoolean(option_strref, true, &success);
+        value = Args::StringToBoolean(option_arg, true, &success);
         if (value)
           m_move_to_nearest_code = eLazyBoolYes;
         else
@@ -323,7 +316,7 @@
         if (!success)
           error.SetErrorStringWithFormat(
               "Invalid boolean value for move-to-nearest-code option: '%s'",
-              option_arg);
+              option_arg.str().c_str());
         break;
       }
 
@@ -338,11 +331,11 @@
         break;
 
       case 'N': {
-        if (BreakpointID::StringIsBreakpointName(option_strref, error))
+        if (BreakpointID::StringIsBreakpointName(option_arg, error))
           m_breakpoint_names.push_back(option_arg);
         else
           error.SetErrorStringWithFormat("Invalid breakpoint name: %s",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
       }
 
@@ -359,8 +352,8 @@
         break;
 
       case 'O':
-        m_exception_extra_args.AppendArgument(llvm::StringRef("-O"));
-        m_exception_extra_args.AppendArgument(option_strref);
+        m_exception_extra_args.AppendArgument("-O");
+        m_exception_extra_args.AppendArgument(option_arg);
         break;
 
       case 'p':
@@ -385,11 +378,9 @@
         break;
 
       case 't':
-        m_thread_id =
-            StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
-        if (m_thread_id == LLDB_INVALID_THREAD_ID)
+        if (option_arg.getAsInteger(0, m_thread_id))
           error.SetErrorStringWithFormat("invalid thread id string '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
 
       case 'T':
@@ -398,17 +389,17 @@
 
       case 'w': {
         bool success;
-        m_throw_bp = Args::StringToBoolean(option_strref, true, &success);
+        m_throw_bp = Args::StringToBoolean(option_arg, true, &success);
         if (!success)
           error.SetErrorStringWithFormat(
-              "Invalid boolean value for on-throw option: '%s'", option_arg);
+              "Invalid boolean value for on-throw option: '%s'",
+              option_arg.str().c_str());
       } break;
 
       case 'x':
-        m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
-        if (m_thread_id == UINT32_MAX)
+        if (option_arg.getAsInteger(0, m_thread_index))
           error.SetErrorStringWithFormat("invalid thread index string '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
 
       case 'X':
@@ -853,17 +844,14 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
 
       switch (short_option) {
       case 'c':
-        if (option_arg != nullptr)
-          m_condition.assign(option_arg);
-        else
-          m_condition.clear();
+        m_condition = option_arg;
         m_condition_passed = true;
         break;
       case 'd':
@@ -878,48 +866,39 @@
         m_enable_value = true;
         break;
       case 'i':
-        m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
-        if (m_ignore_count == UINT32_MAX)
+        if (option_arg.getAsInteger(0, m_ignore_count))
           error.SetErrorStringWithFormat("invalid ignore count '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
       case 'o': {
         bool value, success;
-        value = Args::StringToBoolean(
-            llvm::StringRef::withNullAsEmpty(option_arg), false, &success);
+        value = Args::StringToBoolean(option_arg, false, &success);
         if (success) {
           m_one_shot_passed = true;
           m_one_shot = value;
         } else
           error.SetErrorStringWithFormat(
-              "invalid boolean value '%s' passed for -o option", option_arg);
+              "invalid boolean value '%s' passed for -o option",
+              option_arg.str().c_str());
       } break;
       case 't':
         if (option_arg[0] == '\0') {
           m_thread_id = LLDB_INVALID_THREAD_ID;
           m_thread_id_passed = true;
         } else {
-          m_thread_id =
-              StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
-          if (m_thread_id == LLDB_INVALID_THREAD_ID)
+          if (option_arg.getAsInteger(0, m_thread_id))
             error.SetErrorStringWithFormat("invalid thread id string '%s'",
-                                           option_arg);
+                                           option_arg.str().c_str());
           else
             m_thread_id_passed = true;
         }
         break;
       case 'T':
-        if (option_arg != nullptr)
-          m_thread_name.assign(option_arg);
-        else
-          m_thread_name.clear();
+        m_thread_name = option_arg;
         m_name_passed = true;
         break;
       case 'q':
-        if (option_arg != nullptr)
-          m_queue_name.assign(option_arg);
-        else
-          m_queue_name.clear();
+        m_queue_name = option_arg;
         m_queue_passed = true;
         break;
       case 'x':
@@ -927,10 +906,9 @@
           m_thread_index = UINT32_MAX;
           m_thread_index_passed = true;
         } else {
-          m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
-          if (m_thread_id == UINT32_MAX)
+          if (option_arg.getAsInteger(0, m_thread_index))
             error.SetErrorStringWithFormat("invalid thread index string '%s'",
-                                           option_arg);
+                                           option_arg.str().c_str());
           else
             m_thread_index_passed = true;
         }
@@ -1327,7 +1305,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -1474,7 +1452,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -1485,7 +1463,7 @@
         break;
 
       case 'l':
-        m_line_num = StringConvert::ToUInt32(option_arg, 0);
+        option_arg.getAsInteger(0, m_line_num);
         break;
 
       default:
@@ -1633,7 +1611,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -1773,29 +1751,29 @@
     return llvm::makeArrayRef(g_breakpoint_name_options);
   }
 
-  Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
+  Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                        ExecutionContext *execution_context) override {
     Error error;
     const int short_option = g_breakpoint_name_options[option_idx].short_option;
 
     switch (short_option) {
     case 'N':
-      if (BreakpointID::StringIsBreakpointName(option_value, error) &&
+      if (BreakpointID::StringIsBreakpointName(option_arg, error) &&
           error.Success())
-        m_name.SetValueFromString(option_value);
+        m_name.SetValueFromString(option_arg);
       break;
 
     case 'B':
-      if (m_breakpoint.SetValueFromString(option_value).Fail())
+      if (m_breakpoint.SetValueFromString(option_arg).Fail())
         error.SetErrorStringWithFormat(
             "unrecognized value \"%s\" for breakpoint",
-            option_value.str().c_str());
+            option_arg.str().c_str());
       break;
     case 'D':
-      if (m_use_dummy.SetValueFromString(option_value).Fail())
+      if (m_use_dummy.SetValueFromString(option_arg).Fail())
         error.SetErrorStringWithFormat(
             "unrecognized value \"%s\" for use-dummy",
-            option_value.str().c_str());
+            option_arg.str().c_str());
       break;
 
     default:
@@ -1805,7 +1783,6 @@
     }
     return error;
   }
-  Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
 
   void OptionParsingStarting(ExecutionContext *execution_context) override {
     m_name.Clear();
@@ -2116,7 +2093,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -2246,7 +2223,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index ab9ed3f..5e4ee0b 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -280,11 +280,10 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
-      auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
 
       switch (short_option) {
       case 'o':
@@ -294,8 +293,7 @@
 
       case 's':
         m_script_language = (lldb::ScriptLanguage)Args::StringToOptionEnum(
-            llvm::StringRef::withNullAsEmpty(option_arg),
-            g_breakpoint_add_options[option_idx].enum_values,
+            option_arg, g_breakpoint_add_options[option_idx].enum_values,
             eScriptLanguageNone, error);
 
         if (m_script_language == eScriptLanguagePython ||
@@ -308,10 +306,11 @@
 
       case 'e': {
         bool success = false;
-        m_stop_on_error = Args::StringToBoolean(option_strref, false, &success);
+        m_stop_on_error = Args::StringToBoolean(option_arg, false, &success);
         if (!success)
           error.SetErrorStringWithFormat(
-              "invalid value for stop-on-error: \"%s\"", option_arg);
+              "invalid value for stop-on-error: \"%s\"",
+              option_arg.str().c_str());
       } break;
 
       case 'F':
@@ -511,7 +510,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index ee7add9..1106b37 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -66,29 +66,26 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
-      llvm::StringRef option_strref =
-          llvm::StringRef::withNullAsEmpty(option_arg);
 
       switch (short_option) {
       case 'c':
-        error =
-            m_count.SetValueFromString(option_strref, eVarSetOperationAssign);
+        error = m_count.SetValueFromString(option_arg, eVarSetOperationAssign);
         break;
       case 's':
-        if (option_arg && strcmp("end", option_arg) == 0) {
+        if (option_arg == "end") {
           m_start_idx.SetCurrentValue(UINT64_MAX);
           m_start_idx.SetOptionWasSet();
         } else
-          error = m_start_idx.SetValueFromString(option_strref,
+          error = m_start_idx.SetValueFromString(option_arg,
                                                  eVarSetOperationAssign);
         break;
       case 'e':
-        error = m_stop_idx.SetValueFromString(option_strref,
-                                              eVarSetOperationAssign);
+        error =
+            m_stop_idx.SetValueFromString(option_arg, eVarSetOperationAssign);
         break;
       case 'C':
         m_clear.SetCurrentValue(true);
@@ -259,24 +256,22 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
-      llvm::StringRef option_strref =
-          llvm::StringRef::withNullAsEmpty(option_arg);
 
       switch (short_option) {
       case 'e':
-        error = m_stop_on_error.SetValueFromString(option_strref);
+        error = m_stop_on_error.SetValueFromString(option_arg);
         break;
 
       case 'c':
-        error = m_stop_on_continue.SetValueFromString(option_strref);
+        error = m_stop_on_continue.SetValueFromString(option_arg);
         break;
 
       case 's':
-        error = m_silent_run.SetValueFromString(option_strref);
+        error = m_silent_run.SetValueFromString(option_arg);
         break;
 
       default:
@@ -401,7 +396,6 @@
 
       return error;
     }
-    Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
 
     void OptionParsingStarting(ExecutionContext *execution_context) override {
       m_help.Clear();
@@ -1229,7 +1223,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -1498,7 +1492,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -1630,32 +1624,32 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
 
       switch (short_option) {
       case 'f':
-        if (option_arg)
-          m_funct_name.assign(option_arg);
+        if (!option_arg.empty())
+          m_funct_name = option_arg;
         break;
       case 'c':
-        if (option_arg)
-          m_class_name.assign(option_arg);
+        if (!option_arg.empty())
+          m_class_name = option_arg;
         break;
       case 'h':
-        if (option_arg)
-          m_short_help.assign(option_arg);
+        if (!option_arg.empty())
+          m_short_help = option_arg;
         break;
       case 's':
         m_synchronicity =
             (ScriptedCommandSynchronicity)Args::StringToOptionEnum(
-                llvm::StringRef::withNullAsEmpty(option_arg),
-                GetDefinitions()[option_idx].enum_values, 0, error);
+                option_arg, GetDefinitions()[option_idx].enum_values, 0, error);
         if (!error.Success())
           error.SetErrorStringWithFormat(
-              "unrecognized value for synchronicity '%s'", option_arg);
+              "unrecognized value for synchronicity '%s'",
+              option_arg.str().c_str());
         break;
       default:
         error.SetErrorStringWithFormat("unrecognized option '%c'",
diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 0795033..fa3a144 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -72,31 +72,28 @@
 CommandObjectDisassemble::CommandOptions::~CommandOptions() = default;
 
 Error CommandObjectDisassemble::CommandOptions::SetOptionValue(
-    uint32_t option_idx, const char *option_arg,
+    uint32_t option_idx, llvm::StringRef option_arg,
     ExecutionContext *execution_context) {
   Error error;
 
   const int short_option = m_getopt_table[option_idx].val;
 
-  bool success;
-
   switch (short_option) {
   case 'm':
     show_mixed = true;
     break;
 
   case 'C':
-    num_lines_context = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-    if (!success)
+    if (option_arg.getAsInteger(0, num_lines_context))
       error.SetErrorStringWithFormat("invalid num context lines string: \"%s\"",
-                                     option_arg);
+                                     option_arg.str().c_str());
     break;
 
   case 'c':
-    num_instructions = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-    if (!success)
+    if (option_arg.getAsInteger(0, num_instructions))
       error.SetErrorStringWithFormat(
-          "invalid num of instructions string: \"%s\"", option_arg);
+          "invalid num of instructions string: \"%s\"",
+          option_arg.str().c_str());
     break;
 
   case 'b':
diff --git a/lldb/source/Commands/CommandObjectDisassemble.h b/lldb/source/Commands/CommandObjectDisassemble.h
index c60f70a..db89aa2 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.h
+++ b/lldb/source/Commands/CommandObjectDisassemble.h
@@ -32,7 +32,7 @@
 
     ~CommandOptions() override;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override;
 
     void OptionParsingStarting(ExecutionContext *execution_context) override;
diff --git a/lldb/source/Commands/CommandObjectExpression.h b/lldb/source/Commands/CommandObjectExpression.h
index 7aacc92..7c21adc 100644
--- a/lldb/source/Commands/CommandObjectExpression.h
+++ b/lldb/source/Commands/CommandObjectExpression.h
@@ -36,7 +36,6 @@
 
     Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
                          ExecutionContext *execution_context) override;
-    Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
 
     void OptionParsingStarting(ExecutionContext *execution_context) override;
 
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index eae5ddc..56e2cc9 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -77,7 +77,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -87,24 +87,20 @@
         break;
 
       case 'a': {
-        bool success = false;
-
-        address = StringConvert::ToUInt64(option_arg, 0, 0, &success);
-        if (!success) {
+        address.emplace();
+        if (option_arg.getAsInteger(0, *address)) {
           address.reset();
           error.SetErrorStringWithFormat("invalid address argument '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         }
       } break;
 
       case 'o': {
-        bool success = false;
-
-        offset = StringConvert::ToSInt64(option_arg, 0, 0, &success);
-        if (!success) {
+        offset.emplace();
+        if (option_arg.getAsInteger(0, *offset)) {
           offset.reset();
           error.SetErrorStringWithFormat("invalid offset argument '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         }
       } break;
 
@@ -268,18 +264,17 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
-      bool success = false;
       const int short_option = m_getopt_table[option_idx].val;
       switch (short_option) {
       case 'r':
-        relative_frame_offset =
-            StringConvert::ToSInt32(option_arg, INT32_MIN, 0, &success);
-        if (!success)
+        if (option_arg.getAsInteger(0, relative_frame_offset)) {
+          relative_frame_offset = INT32_MIN;
           error.SetErrorStringWithFormat("invalid frame offset argument '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
+        }
         break;
 
       default:
diff --git a/lldb/source/Commands/CommandObjectHelp.h b/lldb/source/Commands/CommandObjectHelp.h
index df1c0ab..5e3cf74 100644
--- a/lldb/source/Commands/CommandObjectHelp.h
+++ b/lldb/source/Commands/CommandObjectHelp.h
@@ -45,7 +45,7 @@
 
     ~CommandOptions() override {}
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp
index 34dc710..ab84ac6 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -116,7 +116,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index 8f9f60e..553357f 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -110,7 +110,6 @@
     }
     return error;
   }
-  Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
 
   void OptionParsingStarting(ExecutionContext *execution_context) override {
     m_num_per_line.Clear();
@@ -942,7 +941,6 @@
       }
       return error;
     }
-    Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
 
     void OptionParsingStarting(ExecutionContext *execution_context) override {
       m_expr.Clear();
@@ -1238,7 +1236,6 @@
       }
       return error;
     }
-    Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
 
     void OptionParsingStarting(ExecutionContext *execution_context) override {
       m_infile.Clear();
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 80e21f7..3a47c71 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -667,22 +667,21 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       char short_option = (char)m_getopt_table[option_idx].val;
-      bool success = false;
 
       switch (short_option) {
       case 'o':
-        m_offset = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-        if (!success)
-          error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
+        if (option_arg.getAsInteger(0, m_offset))
+          error.SetErrorStringWithFormat("invalid offset: '%s'",
+                                         option_arg.str().c_str());
         break;
       case 'c':
-        m_count = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-        if (!success)
-          error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
+        if (option_arg.getAsInteger(0, m_count))
+          error.SetErrorStringWithFormat("invalid offset: '%s'",
+                                         option_arg.str().c_str());
         break;
       default:
         error.SetErrorStringWithFormat("unrecognized option '%c'",
@@ -762,17 +761,16 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       char short_option = (char)m_getopt_table[option_idx].val;
-      bool success = false;
 
       switch (short_option) {
       case 'o':
-        m_offset = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-        if (!success)
-          error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
+        if (option_arg.getAsInteger(0, m_offset))
+          error.SetErrorStringWithFormat("invalid offset: '%s'",
+                                         option_arg.str().c_str());
         break;
       case 'd':
         m_data.assign(option_arg);
@@ -1272,59 +1270,60 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
       bool success = false;
 
+      uint32_t id = LLDB_INVALID_PROCESS_ID;
+      success = !option_arg.getAsInteger(0, id);
       switch (short_option) {
-      case 'p':
-        match_info.GetProcessInfo().SetProcessID(StringConvert::ToUInt32(
-            option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
+      case 'p': {
+        match_info.GetProcessInfo().SetProcessID(id);
         if (!success)
           error.SetErrorStringWithFormat("invalid process ID string: '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
-
+      }
       case 'P':
-        match_info.GetProcessInfo().SetParentProcessID(StringConvert::ToUInt32(
-            option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
+        match_info.GetProcessInfo().SetParentProcessID(id);
         if (!success)
           error.SetErrorStringWithFormat(
-              "invalid parent process ID string: '%s'", option_arg);
+              "invalid parent process ID string: '%s'",
+              option_arg.str().c_str());
         break;
 
       case 'u':
-        match_info.GetProcessInfo().SetUserID(
-            StringConvert::ToUInt32(option_arg, UINT32_MAX, 0, &success));
+        match_info.GetProcessInfo().SetUserID(success ? id : UINT32_MAX);
         if (!success)
           error.SetErrorStringWithFormat("invalid user ID string: '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
 
       case 'U':
-        match_info.GetProcessInfo().SetEffectiveUserID(
-            StringConvert::ToUInt32(option_arg, UINT32_MAX, 0, &success));
+        match_info.GetProcessInfo().SetEffectiveUserID(success ? id
+                                                               : UINT32_MAX);
         if (!success)
           error.SetErrorStringWithFormat(
-              "invalid effective user ID string: '%s'", option_arg);
+              "invalid effective user ID string: '%s'",
+              option_arg.str().c_str());
         break;
 
       case 'g':
-        match_info.GetProcessInfo().SetGroupID(
-            StringConvert::ToUInt32(option_arg, UINT32_MAX, 0, &success));
+        match_info.GetProcessInfo().SetGroupID(success ? id : UINT32_MAX);
         if (!success)
           error.SetErrorStringWithFormat("invalid group ID string: '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
 
       case 'G':
-        match_info.GetProcessInfo().SetEffectiveGroupID(
-            StringConvert::ToUInt32(option_arg, UINT32_MAX, 0, &success));
+        match_info.GetProcessInfo().SetEffectiveGroupID(success ? id
+                                                                : UINT32_MAX);
         if (!success)
           error.SetErrorStringWithFormat(
-              "invalid effective group ID string: '%s'", option_arg);
+              "invalid effective group ID string: '%s'",
+              option_arg.str().c_str());
         break;
 
       case 'a': {
@@ -1515,17 +1514,16 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       char short_option = (char)m_getopt_table[option_idx].val;
-      bool success = false;
       switch (short_option) {
       case 'p': {
-        lldb::pid_t pid = StringConvert::ToUInt32(
-            option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
-        if (!success || pid == LLDB_INVALID_PROCESS_ID) {
-          error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg);
+        lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
+        if (option_arg.getAsInteger(0, pid)) {
+          error.SetErrorStringWithFormat("invalid process ID '%s'",
+                                         option_arg.str().c_str());
         } else {
           attach_info.SetProcessID(pid);
         }
@@ -1701,21 +1699,20 @@
       return llvm::makeArrayRef(g_platform_shell_options);
     }
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_value,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
 
       const char short_option = (char)GetDefinitions()[option_idx].short_option;
 
       switch (short_option) {
-      case 't': {
-        bool success;
-        timeout = StringConvert::ToUInt32(option_value, 10, 10, &success);
-        if (!success)
+      case 't':
+        timeout = 10;
+        if (option_arg.getAsInteger(10, timeout))
           error.SetErrorStringWithFormat(
-              "could not convert \"%s\" to a numeric value.", option_value);
+              "could not convert \"%s\" to a numeric value.",
+              option_arg.str().c_str());
         break;
-      }
       default:
         error.SetErrorStringWithFormat("invalid short option character '%c'",
                                        short_option);
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index ef927d8..5d25521 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -337,21 +337,20 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
-      bool success = false;
       switch (short_option) {
       case 'c':
         attach_info.SetContinueOnceAttached(true);
         break;
 
       case 'p': {
-        lldb::pid_t pid = StringConvert::ToUInt32(
-            option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
-        if (!success || pid == LLDB_INVALID_PROCESS_ID) {
-          error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg);
+        lldb::pid_t pid;
+        if (option_arg.getAsInteger(0, pid)) {
+          error.SetErrorStringWithFormat("invalid process ID '%s'",
+                                         option_arg.str().c_str());
         } else {
           attach_info.SetProcessID(pid);
         }
@@ -604,18 +603,16 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
-      bool success = false;
       switch (short_option) {
       case 'i':
-        m_ignore = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-        if (!success)
+        if (option_arg.getAsInteger(0, m_ignore))
           error.SetErrorStringWithFormat(
               "invalid value for ignore option: \"%s\", should be a number.",
-              option_arg);
+              option_arg.str().c_str());
         break;
 
       default:
@@ -755,20 +752,19 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
-      auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
 
       switch (short_option) {
       case 's':
         bool tmp_result;
         bool success;
-        tmp_result = Args::StringToBoolean(option_strref, false, &success);
+        tmp_result = Args::StringToBoolean(option_arg, false, &success);
         if (!success)
           error.SetErrorStringWithFormat("invalid boolean option: \"%s\"",
-                                         option_arg);
+                                         option_arg.str().c_str());
         else {
           if (tmp_result)
             m_keep_stopped = eLazyBoolYes;
@@ -859,7 +855,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -988,14 +984,14 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
       switch (short_option) {
       case 'i':
         do_install = true;
-        if (option_arg && option_arg[0])
+        if (!option_arg.empty())
           install_path.SetFile(option_arg, false);
         break;
       default:
@@ -1382,7 +1378,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp
index 89b1188..e5e8089 100644
--- a/lldb/source/Commands/CommandObjectRegister.cpp
+++ b/lldb/source/Commands/CommandObjectRegister.cpp
@@ -294,7 +294,6 @@
       }
       return error;
     }
-    Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
 
     // Instance variables to hold the values for command options.
     OptionValueArray set_indexes;
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index 21a636f..54efead 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -101,7 +101,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp
index 6f1a50d..e44ef6d 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -59,30 +59,27 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = GetDefinitions()[option_idx].short_option;
       switch (short_option) {
       case 'l':
-        start_line = StringConvert::ToUInt32(option_arg, 0);
-        if (start_line == 0)
+        if (option_arg.getAsInteger(0, start_line))
           error.SetErrorStringWithFormat("invalid line number: '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
 
       case 'e':
-        end_line = StringConvert::ToUInt32(option_arg, 0);
-        if (end_line == 0)
+        if (option_arg.getAsInteger(0, end_line))
           error.SetErrorStringWithFormat("invalid line number: '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
 
       case 'c':
-        num_lines = StringConvert::ToUInt32(option_arg, 0);
-        if (num_lines == 0)
+        if (option_arg.getAsInteger(0, num_lines))
           error.SetErrorStringWithFormat("invalid line count: '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
 
       case 'f':
@@ -686,23 +683,21 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = GetDefinitions()[option_idx].short_option;
       switch (short_option) {
       case 'l':
-        start_line = StringConvert::ToUInt32(option_arg, 0);
-        if (start_line == 0)
+        if (option_arg.getAsInteger(0, start_line))
           error.SetErrorStringWithFormat("invalid line number: '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
 
       case 'c':
-        num_lines = StringConvert::ToUInt32(option_arg, 0);
-        if (num_lines == 0)
+        if (option_arg.getAsInteger(0, num_lines))
           error.SetErrorStringWithFormat("invalid line count: '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
 
       case 'f':
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index a40f9c9..7f351ab 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1972,7 +1972,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -1980,8 +1980,8 @@
       switch (short_option) {
       case 's':
         m_sort_order = (SortOrder)Args::StringToOptionEnum(
-            llvm::StringRef::withNullAsEmpty(option_arg),
-            GetDefinitions()[option_idx].enum_values, eSortOrderNone, error);
+            option_arg, GetDefinitions()[option_idx].enum_values,
+            eSortOrderNone, error);
         break;
 
       default:
@@ -2802,7 +2802,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
 
@@ -2814,8 +2814,7 @@
                                               LLDB_INVALID_ADDRESS, &error);
       } else {
         unsigned long width = 0;
-        if (option_arg)
-          width = strtoul(option_arg, nullptr, 0);
+        option_arg.getAsInteger(0, width);
         m_format_array.push_back(std::make_pair(short_option, width));
       }
       return error;
@@ -3166,7 +3165,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
 
@@ -3180,7 +3179,7 @@
                                        LLDB_INVALID_ADDRESS, &error);
         if (m_addr == LLDB_INVALID_ADDRESS)
           error.SetErrorStringWithFormat("invalid address string '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
       }
 
@@ -3466,7 +3465,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
 
@@ -3480,10 +3479,9 @@
       } break;
 
       case 'o':
-        m_offset = StringConvert::ToUInt64(option_arg, LLDB_INVALID_ADDRESS);
-        if (m_offset == LLDB_INVALID_ADDRESS)
+        if (option_arg.getAsInteger(0, m_offset))
           error.SetErrorStringWithFormat("invalid offset string '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
 
       case 's':
@@ -3501,10 +3499,9 @@
         break;
 
       case 'l':
-        m_line_number = StringConvert::ToUInt32(option_arg, UINT32_MAX);
-        if (m_line_number == UINT32_MAX)
+        if (option_arg.getAsInteger(0, m_line_number))
           error.SetErrorStringWithFormat("invalid line number string '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         else if (m_line_number == 0)
           error.SetErrorString("zero is an invalid line number");
         m_type = eLookupTypeFileLine;
@@ -4345,11 +4342,10 @@
       return llvm::makeArrayRef(g_target_stop_hook_add_options);
     }
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
-      bool success;
 
       switch (short_option) {
       case 'c':
@@ -4358,20 +4354,18 @@
         break;
 
       case 'e':
-        m_line_end = StringConvert::ToUInt32(option_arg, UINT_MAX, 0, &success);
-        if (!success) {
+        if (option_arg.getAsInteger(0, m_line_end)) {
           error.SetErrorStringWithFormat("invalid end line number: \"%s\"",
-                                         option_arg);
+                                         option_arg.str().c_str());
           break;
         }
         m_sym_ctx_specified = true;
         break;
 
       case 'l':
-        m_line_start = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-        if (!success) {
+        if (option_arg.getAsInteger(0, m_line_start)) {
           error.SetErrorStringWithFormat("invalid start line number: \"%s\"",
-                                         option_arg);
+                                         option_arg.str().c_str());
           break;
         }
         m_sym_ctx_specified = true;
@@ -4398,11 +4392,9 @@
         break;
 
       case 't':
-        m_thread_id =
-            StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
-        if (m_thread_id == LLDB_INVALID_THREAD_ID)
+        if (option_arg.getAsInteger(0, m_thread_id))
           error.SetErrorStringWithFormat("invalid thread id string '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         m_thread_specified = true;
         break;
 
@@ -4417,10 +4409,9 @@
         break;
 
       case 'x':
-        m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
-        if (m_thread_id == UINT32_MAX)
+        if (option_arg.getAsInteger(0, m_thread_index))
           error.SetErrorStringWithFormat("invalid thread index string '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         m_thread_specified = true;
         break;
 
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index e5662dd..bfed4ef 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -161,36 +161,30 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
-      auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
 
       switch (short_option) {
       case 'c': {
-        bool success;
-        int32_t input_count =
-            StringConvert::ToSInt32(option_arg, -1, 0, &success);
-        if (!success)
-          error.SetErrorStringWithFormat(
-              "invalid integer value for option '%c'", short_option);
-        if (input_count < -1)
+        int32_t input_count = 0;
+        if (option_arg.getAsInteger(0, m_count)) {
           m_count = UINT32_MAX;
-        else
-          m_count = input_count;
-      } break;
-      case 's': {
-        bool success;
-        m_start = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-        if (!success)
           error.SetErrorStringWithFormat(
               "invalid integer value for option '%c'", short_option);
+        } else if (input_count < 0)
+          m_count = UINT32_MAX;
       } break;
+      case 's':
+        if (option_arg.getAsInteger(0, m_start))
+          error.SetErrorStringWithFormat(
+              "invalid integer value for option '%c'", short_option);
+        break;
       case 'e': {
         bool success;
         m_extended_backtrace =
-            Args::StringToBoolean(option_strref, false, &success);
+            Args::StringToBoolean(option_arg, false, &success);
         if (!success)
           error.SetErrorStringWithFormat(
               "invalid boolean value for option '%c'", short_option);
@@ -335,17 +329,15 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
-      auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
 
       switch (short_option) {
       case 'a': {
         bool success;
-        bool avoid_no_debug =
-            Args::StringToBoolean(option_strref, true, &success);
+        bool avoid_no_debug = Args::StringToBoolean(option_arg, true, &success);
         if (!success)
           error.SetErrorStringWithFormat(
               "invalid boolean value for option '%c'", short_option);
@@ -357,8 +349,7 @@
 
       case 'A': {
         bool success;
-        bool avoid_no_debug =
-            Args::StringToBoolean(option_strref, true, &success);
+        bool avoid_no_debug = Args::StringToBoolean(option_arg, true, &success);
         if (!success)
           error.SetErrorStringWithFormat(
               "invalid boolean value for option '%c'", short_option);
@@ -369,9 +360,9 @@
       } break;
 
       case 'c':
-        m_step_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
-        if (m_step_count == UINT32_MAX)
-          error.SetErrorStringWithFormat("invalid step count '%s'", option_arg);
+        if (option_arg.getAsInteger(0, m_step_count))
+          error.SetErrorStringWithFormat("invalid step count '%s'",
+                                         option_arg.str().c_str());
         break;
 
       case 'C':
@@ -383,23 +374,18 @@
         OptionEnumValueElement *enum_values =
             GetDefinitions()[option_idx].enum_values;
         m_run_mode = (lldb::RunMode)Args::StringToOptionEnum(
-            option_strref, enum_values, eOnlyDuringStepping, error);
+            option_arg, enum_values, eOnlyDuringStepping, error);
       } break;
 
-      case 'e': {
-        if (strcmp(option_arg, "block") == 0) {
+      case 'e':
+        if (option_arg == "block") {
           m_end_line_is_block_end = 1;
           break;
         }
-        uint32_t tmp_end_line =
-            StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
-        if (tmp_end_line == UINT32_MAX)
+        if (option_arg.getAsInteger(0, m_end_line))
           error.SetErrorStringWithFormat("invalid end line number '%s'",
-                                         option_arg);
-        else
-          m_end_line = tmp_end_line;
+                                         option_arg.str().c_str());
         break;
-      } break;
 
       case 'r':
         m_avoid_regexp.clear();
@@ -921,7 +907,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -934,27 +920,24 @@
           m_until_addrs.push_back(tmp_addr);
       } break;
       case 't':
-        m_thread_idx =
-            StringConvert::ToUInt32(option_arg, LLDB_INVALID_INDEX32);
-        if (m_thread_idx == LLDB_INVALID_INDEX32) {
+        if (option_arg.getAsInteger(0, m_thread_idx)) {
+          m_thread_idx = LLDB_INVALID_INDEX32;
           error.SetErrorStringWithFormat("invalid thread index '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         }
         break;
       case 'f':
-        m_frame_idx =
-            StringConvert::ToUInt32(option_arg, LLDB_INVALID_FRAME_ID);
-        if (m_frame_idx == LLDB_INVALID_FRAME_ID) {
+        if (option_arg.getAsInteger(0, m_frame_idx)) {
+          m_frame_idx = LLDB_INVALID_FRAME_ID;
           error.SetErrorStringWithFormat("invalid frame index '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         }
         break;
       case 'm': {
         OptionEnumValueElement *enum_values =
             GetDefinitions()[option_idx].enum_values;
         lldb::RunMode run_mode = (lldb::RunMode)Args::StringToOptionEnum(
-            llvm::StringRef::withNullAsEmpty(option_arg), enum_values,
-            eOnlyDuringStepping, error);
+            option_arg, enum_values, eOnlyDuringStepping, error);
 
         if (error.Success()) {
           if (run_mode == eAllThreads)
@@ -1339,7 +1322,7 @@
       m_json_stopinfo = false;
     }
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       const int short_option = m_getopt_table[option_idx].val;
       Error error;
@@ -1432,21 +1415,21 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
-      auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
 
       switch (short_option) {
       case 'x': {
         bool success;
-        bool tmp_value = Args::StringToBoolean(option_strref, false, &success);
+        bool tmp_value = Args::StringToBoolean(option_arg, false, &success);
         if (success)
           m_from_expression = tmp_value;
         else {
           error.SetErrorStringWithFormat(
-              "invalid boolean value '%s' for 'x' option", option_arg);
+              "invalid boolean value '%s' for 'x' option",
+              option_arg.str().c_str());
         }
       } break;
       default:
@@ -1616,9 +1599,8 @@
       m_force = false;
     }
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
-      bool success;
       const int short_option = m_getopt_table[option_idx].val;
       Error error;
 
@@ -1629,14 +1611,12 @@
           return Error("only one source file expected.");
         break;
       case 'l':
-        m_line_num = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-        if (!success || m_line_num == 0)
-          return Error("invalid line number: '%s'.", option_arg);
+        if (option_arg.getAsInteger(0, m_line_num))
+          return Error("invalid line number: '%s'.", option_arg.str().c_str());
         break;
       case 'b':
-        m_line_offset = StringConvert::ToSInt32(option_arg, 0, 0, &success);
-        if (!success)
-          return Error("invalid line offset: '%s'.", option_arg);
+        if (option_arg.getAsInteger(0, m_line_offset))
+          return Error("invalid line offset: '%s'.", option_arg.str().c_str());
         break;
       case 'a':
         m_load_addr = Args::StringToAddress(execution_context, option_arg,
@@ -1764,7 +1744,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index 2c44ad4..6461429 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -126,7 +126,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override;
 
     void OptionParsingStarting(ExecutionContext *execution_context) override;
@@ -320,7 +320,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -328,11 +328,10 @@
 
       switch (short_option) {
       case 'C':
-        m_cascade = Args::StringToBoolean(
-            llvm::StringRef::withNullAsEmpty(option_arg), true, &success);
+        m_cascade = Args::StringToBoolean(option_arg, true, &success);
         if (!success)
           error.SetErrorStringWithFormat("invalid value for cascade: %s",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
       case 'P':
         handwrite_python = true;
@@ -599,7 +598,6 @@
 
       return error;
     }
-    Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
 
     // Instance variables to hold the values for command options.
 
@@ -770,7 +768,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -783,8 +781,7 @@
         m_category = std::string(option_arg);
         break;
       case 'l':
-        m_language = Language::GetLanguageTypeFromString(
-            llvm::StringRef::withNullAsEmpty(option_arg));
+        m_language = Language::GetLanguageTypeFromString(option_arg);
         break;
       default:
         error.SetErrorStringWithFormat("unrecognized option '%c'",
@@ -911,7 +908,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -1027,19 +1024,17 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
-      llvm::StringRef option_strref =
-          llvm::StringRef::withNullAsEmpty(option_arg);
       switch (short_option) {
       case 'w':
-        m_category_regex.SetCurrentValue(option_strref);
+        m_category_regex.SetCurrentValue(option_arg);
         m_category_regex.SetOptionWasSet();
         break;
       case 'l':
-        error = m_category_language.SetValueFromString(option_strref);
+        error = m_category_language.SetValueFromString(option_arg);
         if (error.Success())
           m_category_language.SetOptionWasSet();
         break;
@@ -1249,7 +1244,7 @@
 #endif // LLDB_DISABLE_PYTHON
 
 Error CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue(
-    uint32_t option_idx, const char *option_arg,
+    uint32_t option_idx, llvm::StringRef option_arg,
     ExecutionContext *execution_context) {
   Error error;
   const int short_option = m_getopt_table[option_idx].val;
@@ -1257,11 +1252,10 @@
 
   switch (short_option) {
   case 'C':
-    m_flags.SetCascades(Args::StringToBoolean(
-        llvm::StringRef::withNullAsEmpty(option_arg), true, &success));
+    m_flags.SetCascades(Args::StringToBoolean(option_arg, true, &success));
     if (!success)
       error.SetErrorStringWithFormat("invalid value for cascade: %s",
-                                     option_arg);
+                                     option_arg.str().c_str());
     break;
   case 'e':
     m_flags.SetDontShowChildren(false);
@@ -1288,14 +1282,14 @@
     m_regex = true;
     break;
   case 'n':
-    m_name.SetCString(option_arg);
+    m_name.SetString(option_arg);
     break;
   case 'o':
-    m_python_script = std::string(option_arg);
+    m_python_script = option_arg;
     m_is_add_script = true;
     break;
   case 'F':
-    m_python_function = std::string(option_arg);
+    m_python_function = option_arg;
     m_is_add_script = true;
     break;
   case 'P':
@@ -1805,7 +1799,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -1815,8 +1809,7 @@
         m_define_enabled.SetValueFromString(llvm::StringRef("true"));
         break;
       case 'l':
-        error = m_cate_language.SetValueFromString(
-            llvm::StringRef::withNullAsEmpty(option_arg));
+        error = m_cate_language.SetValueFromString(option_arg);
         break;
       default:
         error.SetErrorStringWithFormat("unrecognized option '%c'",
@@ -1910,19 +1903,18 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
 
       switch (short_option) {
       case 'l':
-        if (option_arg) {
-          m_language = Language::GetLanguageTypeFromString(
-              llvm::StringRef::withNullAsEmpty(option_arg));
+        if (!option_arg.empty()) {
+          m_language = Language::GetLanguageTypeFromString(option_arg);
           if (m_language == lldb::eLanguageTypeUnknown)
             error.SetErrorStringWithFormat("unrecognized language '%s'",
-                                           option_arg);
+                                           option_arg.str().c_str());
         }
         break;
       default:
@@ -2088,19 +2080,18 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
 
       switch (short_option) {
       case 'l':
-        if (option_arg) {
-          m_language = Language::GetLanguageTypeFromString(
-              llvm::StringRef::withNullAsEmpty(option_arg));
+        if (!option_arg.empty()) {
+          m_language = Language::GetLanguageTypeFromString(option_arg);
           if (m_language == lldb::eLanguageTypeUnknown)
             error.SetErrorStringWithFormat("unrecognized language '%s'",
-                                           option_arg);
+                                           option_arg.str().c_str());
         }
         break;
       default:
@@ -2521,7 +2512,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -2529,11 +2520,10 @@
 
       switch (short_option) {
       case 'C':
-        m_cascade = Args::StringToBoolean(
-            llvm::StringRef::withNullAsEmpty(option_arg), true, &success);
+        m_cascade = Args::StringToBoolean(option_arg, true, &success);
         if (!success)
           error.SetErrorStringWithFormat("invalid value for cascade: %s",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
       case 'c':
         m_expr_paths.push_back(option_arg);
@@ -2820,7 +2810,6 @@
 
       return error;
     }
-    Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
 
     void OptionParsingStarting(ExecutionContext *execution_context) override {
       m_show_help = false;
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index 5979130..f143f5f 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -197,7 +197,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -561,17 +561,16 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
 
       switch (short_option) {
       case 'i':
-        m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
-        if (m_ignore_count == UINT32_MAX)
+        if (option_arg.getAsInteger(0, m_ignore_count))
           error.SetErrorStringWithFormat("invalid ignore count '%s'",
-                                         option_arg);
+                                         option_arg.str().c_str());
         break;
       default:
         error.SetErrorStringWithFormat("unrecognized option '%c'",
@@ -690,17 +689,14 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
 
       switch (short_option) {
       case 'c':
-        if (option_arg != nullptr)
-          m_condition.assign(option_arg);
-        else
-          m_condition.clear();
+        m_condition = option_arg;
         m_condition_passed = true;
         break;
       default:
diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
index dadf2a3..1860d4c 100644
--- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -318,7 +318,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
@@ -331,9 +331,8 @@
 
       case 's':
         m_script_language = (lldb::ScriptLanguage)Args::StringToOptionEnum(
-            llvm::StringRef::withNullAsEmpty(option_arg),
-            GetDefinitions()[option_idx].enum_values, eScriptLanguageNone,
-            error);
+            option_arg, GetDefinitions()[option_idx].enum_values,
+            eScriptLanguageNone, error);
 
         m_use_script_language = (m_script_language == eScriptLanguagePython ||
                                  m_script_language == eScriptLanguageDefault);
@@ -341,11 +340,11 @@
 
       case 'e': {
         bool success = false;
-        m_stop_on_error = Args::StringToBoolean(
-            llvm::StringRef::withNullAsEmpty(option_arg), false, &success);
+        m_stop_on_error = Args::StringToBoolean(option_arg, false, &success);
         if (!success)
           error.SetErrorStringWithFormat(
-              "invalid value for stop-on-error: \"%s\"", option_arg);
+              "invalid value for stop-on-error: \"%s\"",
+              option_arg.str().c_str());
       } break;
 
       case 'F':
diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index 3473c20..c95876f 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -905,7 +905,7 @@
 }
 
 Error OptionGroupOptions::SetOptionValue(uint32_t option_idx,
-                                         const char *option_value,
+                                         llvm::StringRef option_value,
                                          ExecutionContext *execution_context) {
   // After calling OptionGroupOptions::Append(...), you must finalize the groups
   // by calling OptionGroupOptions::Finlize()
@@ -913,8 +913,8 @@
   Error error;
   if (option_idx < m_option_infos.size()) {
     error = m_option_infos[option_idx].option_group->SetOptionValue(
-        m_option_infos[option_idx].option_index,
-        llvm::StringRef::withNullAsEmpty(option_value), execution_context);
+        m_option_infos[option_idx].option_index, option_value,
+        execution_context);
 
   } else {
     error.SetErrorString("invalid option index"); // Shouldn't happen...
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 1a3067d..47bf4ac 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -483,7 +483,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *execution_context) override {
       Error error;
       const int short_option = m_getopt_table[option_idx].val;
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index ff9bf8a..8b83f82 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -4155,23 +4155,23 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_val,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *exe_ctx) override {
       Error err;
       StreamString err_str;
       const int short_option = m_getopt_table[option_idx].val;
       switch (short_option) {
       case 't':
-        if (!ParseReductionTypes(option_val, err_str))
+        if (!ParseReductionTypes(option_arg, err_str))
           err.SetErrorStringWithFormat(
-              "Unable to deduce reduction types for %s: %s", option_val,
-              err_str.GetData());
+              "Unable to deduce reduction types for %s: %s",
+              option_arg.str().c_str(), err_str.GetData());
         break;
       case 'c': {
         auto coord = RSCoordinate{};
-        if (!ParseCoordinate(option_val, coord))
+        if (!ParseCoordinate(option_arg, coord))
           err.SetErrorStringWithFormat("unable to parse coordinate for %s",
-                                       option_val);
+                                       option_arg.str().c_str());
         else {
           m_have_coord = true;
           m_coord = coord;
@@ -4192,7 +4192,8 @@
       return llvm::makeArrayRef(g_renderscript_reduction_bp_set_options);
     }
 
-    bool ParseReductionTypes(const char *option_val, StreamString &err_str) {
+    bool ParseReductionTypes(llvm::StringRef option_val,
+                             StreamString &err_str) {
       m_kernel_types = RSReduceBreakpointResolver::eKernelTypeNone;
       const auto reduce_name_to_type = [](llvm::StringRef name) -> int {
         return llvm::StringSwitch<int>(name)
@@ -4215,7 +4216,7 @@
 
       assert(match_type_list.IsValid());
 
-      if (!match_type_list.Execute(llvm::StringRef(option_val), &match)) {
+      if (!match_type_list.Execute(option_val, &match)) {
         err_str.PutCString(
             "a comma-separated list of kernel types is required");
         return false;
@@ -4310,7 +4311,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *exe_ctx) override {
       Error err;
       const int short_option = m_getopt_table[option_idx].val;
@@ -4321,7 +4322,7 @@
         if (!ParseCoordinate(option_arg, coord))
           err.SetErrorStringWithFormat(
               "Couldn't parse coordinate '%s', should be in format 'x,y,z'.",
-              option_arg);
+              option_arg.str().c_str());
         else {
           m_have_coord = true;
           m_coord = coord;
@@ -4591,7 +4592,7 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *exe_ctx) override {
       Error err;
       const int short_option = m_getopt_table[option_idx].val;
@@ -4601,7 +4602,8 @@
         m_outfile.SetFile(option_arg, true);
         if (m_outfile.Exists()) {
           m_outfile.Clear();
-          err.SetErrorStringWithFormat("file already exists: '%s'", option_arg);
+          err.SetErrorStringWithFormat("file already exists: '%s'",
+                                       option_arg.str().c_str());
         }
         break;
       default:
@@ -4712,16 +4714,14 @@
 
     ~CommandOptions() override = default;
 
-    Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+    Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                          ExecutionContext *exe_ctx) override {
       Error err;
       const int short_option = m_getopt_table[option_idx].val;
 
       switch (short_option) {
       case 'i':
-        bool success;
-        m_id = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-        if (!success)
+        if (option_arg.getAsInteger(0, m_id))
           err.SetErrorStringWithFormat("invalid integer value for option '%c'",
                                        short_option);
         break;
diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
index f477e78..63bfc33 100644
--- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -523,12 +523,11 @@
     m_filter_rules.clear();
   }
 
-  Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+  Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
                        ExecutionContext *execution_context) override {
     Error error;
 
     const int short_option = m_getopt_table[option_idx].val;
-    auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
     switch (short_option) {
     case 'a':
       m_include_any_process = true;
@@ -542,7 +541,7 @@
       break;
 
     case 'b':
-      m_broadcast_events = Args::StringToBoolean(option_strref, true, nullptr);
+      m_broadcast_events = Args::StringToBoolean(option_arg, true, nullptr);
       break;
 
     case 'c':
@@ -558,23 +557,23 @@
       break;
 
     case 'e':
-      m_echo_to_stderr = Args::StringToBoolean(option_strref, false, nullptr);
+      m_echo_to_stderr = Args::StringToBoolean(option_arg, false, nullptr);
       break;
 
     case 'f':
-      return ParseFilterRule(option_strref);
+      return ParseFilterRule(option_arg);
 
     case 'i':
       m_include_info_level = true;
       break;
 
     case 'l':
-      m_live_stream = Args::StringToBoolean(option_strref, false, nullptr);
+      m_live_stream = Args::StringToBoolean(option_arg, false, nullptr);
       break;
 
     case 'n':
       m_filter_fall_through_accepts =
-          Args::StringToBoolean(option_strref, true, nullptr);
+          Args::StringToBoolean(option_arg, true, nullptr);
       break;
 
     case 'r':
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 67c1489..a1f1d95 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -412,11 +412,10 @@
 }
 
 Error ProcessLaunchCommandOptions::SetOptionValue(
-    uint32_t option_idx, const char *option_arg,
+    uint32_t option_idx, llvm::StringRef option_arg,
     ExecutionContext *execution_context) {
   Error error;
   const int short_option = m_getopt_table[option_idx].val;
-  auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
 
   switch (short_option) {
   case 's': // Stop at program entry point
@@ -485,40 +484,38 @@
   {
     bool success;
     const bool disable_aslr_arg =
-        Args::StringToBoolean(option_strref, true, &success);
+        Args::StringToBoolean(option_arg, true, &success);
     if (success)
       disable_aslr = disable_aslr_arg ? eLazyBoolYes : eLazyBoolNo;
     else
       error.SetErrorStringWithFormat(
           "Invalid boolean value for disable-aslr option: '%s'",
-          option_arg ? option_arg : "<null>");
+          option_arg.empty() ? "<null>" : option_arg.str().c_str());
     break;
   }
 
   case 'X': // shell expand args.
   {
     bool success;
-    const bool expand_args =
-        Args::StringToBoolean(option_strref, true, &success);
+    const bool expand_args = Args::StringToBoolean(option_arg, true, &success);
     if (success)
       launch_info.SetShellExpandArguments(expand_args);
     else
       error.SetErrorStringWithFormat(
           "Invalid boolean value for shell-expand-args option: '%s'",
-          option_arg ? option_arg : "<null>");
+          option_arg.empty() ? "<null>" : option_arg.str().c_str());
     break;
   }
 
   case 'c':
-    if (option_arg && option_arg[0])
+    if (!option_arg.empty())
       launch_info.SetShell(FileSpec(option_arg, false));
     else
       launch_info.SetShell(HostInfo::GetDefaultShell());
     break;
 
   case 'v':
-    launch_info.GetEnvironmentEntries().AppendArgument(
-        llvm::StringRef::withNullAsEmpty(option_arg));
+    launch_info.GetEnvironmentEntries().AppendArgument(option_arg);
     break;
 
   default:
diff --git a/lldb/source/Target/ProcessLaunchInfo.cpp b/lldb/source/Target/ProcessLaunchInfo.cpp
index 164bab2..aba9605 100644
--- a/lldb/source/Target/ProcessLaunchInfo.cpp
+++ b/lldb/source/Target/ProcessLaunchInfo.cpp
@@ -142,11 +142,8 @@
   return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str());
 }
 
-void ProcessLaunchInfo::SetProcessPluginName(const char *plugin) {
-  if (plugin && plugin[0])
-    m_plugin_name.assign(plugin);
-  else
-    m_plugin_name.clear();
+void ProcessLaunchInfo::SetProcessPluginName(llvm::StringRef plugin) {
+  m_plugin_name = plugin;
 }
 
 const FileSpec &ProcessLaunchInfo::GetShell() const { return m_shell; }