Update OptionGroup::SetValue to take StringRef.

Then deal with all the fallout.

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

llvm-svn: 282265
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp
index 4a041df..11a4721 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -70,11 +70,10 @@
 };
 
 Error CommandObjectExpression::CommandOptions::SetOptionValue(
-    uint32_t option_idx, const char *option_arg,
+    uint32_t option_idx, llvm::StringRef option_arg,
     ExecutionContext *execution_context) {
   Error error;
 
-  auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
   const int short_option = GetDefinitions()[option_idx].short_option;
 
   switch (short_option) {
@@ -82,66 +81,68 @@
     language = Language::GetLanguageTypeFromString(option_arg);
     if (language == eLanguageTypeUnknown)
       error.SetErrorStringWithFormat(
-          "unknown language type: '%s' for expression", option_arg);
+          "unknown language type: '%s' for expression",
+          option_arg.str().c_str());
     break;
 
   case 'a': {
     bool success;
     bool result;
-    result = Args::StringToBoolean(option_strref, true, &success);
+    result = Args::StringToBoolean(option_arg, true, &success);
     if (!success)
       error.SetErrorStringWithFormat(
-          "invalid all-threads value setting: \"%s\"", option_arg);
+          "invalid all-threads value setting: \"%s\"",
+          option_arg.str().c_str());
     else
       try_all_threads = result;
   } break;
 
   case 'i': {
     bool success;
-    bool tmp_value = Args::StringToBoolean(option_strref, true, &success);
+    bool tmp_value = Args::StringToBoolean(option_arg, true, &success);
     if (success)
       ignore_breakpoints = tmp_value;
     else
       error.SetErrorStringWithFormat(
-          "could not convert \"%s\" to a boolean value.", option_arg);
+          "could not convert \"%s\" to a boolean value.",
+          option_arg.str().c_str());
     break;
   }
 
   case 'j': {
     bool success;
-    bool tmp_value = Args::StringToBoolean(option_strref, true, &success);
+    bool tmp_value = Args::StringToBoolean(option_arg, true, &success);
     if (success)
       allow_jit = tmp_value;
     else
       error.SetErrorStringWithFormat(
-          "could not convert \"%s\" to a boolean value.", option_arg);
+          "could not convert \"%s\" to a boolean value.",
+          option_arg.str().c_str());
     break;
   }
 
-  case 't': {
-    bool success;
-    uint32_t result;
-    result = StringConvert::ToUInt32(option_arg, 0, 0, &success);
-    if (success)
-      timeout = result;
-    else
+  case 't':
+    if (option_arg.getAsInteger(0, timeout)) {
+      timeout = 0;
       error.SetErrorStringWithFormat("invalid timeout setting \"%s\"",
-                                     option_arg);
-  } break;
+                                     option_arg.str().c_str());
+    }
+    break;
 
   case 'u': {
     bool success;
-    bool tmp_value = Args::StringToBoolean(option_strref, true, &success);
+    bool tmp_value = Args::StringToBoolean(option_arg, true, &success);
     if (success)
       unwind_on_error = tmp_value;
     else
       error.SetErrorStringWithFormat(
-          "could not convert \"%s\" to a boolean value.", option_arg);
+          "could not convert \"%s\" to a boolean value.",
+          option_arg.str().c_str());
     break;
   }
 
   case 'v':
-    if (!option_arg) {
+    if (!option_arg.empty()) {
       m_verbosity = eLanguageRuntimeDescriptionDisplayVerbosityFull;
       break;
     }
@@ -150,7 +151,8 @@
             option_arg, GetDefinitions()[option_idx].enum_values, 0, error);
     if (!error.Success())
       error.SetErrorStringWithFormat(
-          "unrecognized value for description-verbosity '%s'", option_arg);
+          "unrecognized value for description-verbosity '%s'",
+          option_arg.str().c_str());
     break;
 
   case 'g':
@@ -165,12 +167,13 @@
 
   case 'X': {
     bool success;
-    bool tmp_value = Args::StringToBoolean(option_strref, true, &success);
+    bool tmp_value = Args::StringToBoolean(option_arg, true, &success);
     if (success)
       auto_apply_fixits = tmp_value ? eLazyBoolYes : eLazyBoolNo;
     else
       error.SetErrorStringWithFormat(
-          "could not convert \"%s\" to a boolean value.", option_arg);
+          "could not convert \"%s\" to a boolean value.",
+          option_arg.str().c_str());
     break;
   }