Rewrite all Property related functions in terms of StringRef.

This was a bit tricky, especially for things like
OptionValueArray and OptionValueDictionary since they do some
funky string parsing.  Rather than try to re-write line-by-line
I tried to make the StringRef usage idiomatic, even though
it meant often re-writing from scratch large blocks of code
in a different way while keeping true to the original intent.

The finished code is a big improvement though, and often much
shorter than the original code.  All tests and unit tests
pass on Windows and Linux.

llvm-svn: 287242
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 24715ec..e66fb23 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -276,11 +276,9 @@
 
 Error Debugger::SetPropertyValue(const ExecutionContext *exe_ctx,
                                  VarSetOperationType op,
-                                 const char *property_path, const char *value) {
-  bool is_load_script =
-      strcmp(property_path, "target.load-script-from-symbol-file") == 0;
-  bool is_escape_non_printables =
-      strcmp(property_path, "escape-non-printables") == 0;
+  llvm::StringRef property_path, llvm::StringRef value) {
+  bool is_load_script = (property_path == "target.load-script-from-symbol-file");
+  bool is_escape_non_printables = (property_path == "escape-non-printables");
   TargetSP target_sp;
   LoadScriptFromSymFile load_script_old_value;
   if (is_load_script && exe_ctx->GetTargetSP()) {
@@ -291,7 +289,7 @@
   Error error(Properties::SetPropertyValue(exe_ctx, op, property_path, value));
   if (error.Success()) {
     // FIXME it would be nice to have "on-change" callbacks for properties
-    if (strcmp(property_path, g_properties[ePropertyPrompt].name) == 0) {
+    if (property_path == g_properties[ePropertyPrompt].name) {
       llvm::StringRef new_prompt = GetPrompt();
       std::string str = lldb_utility::ansi::FormatAnsiTerminalCodes(
           new_prompt, GetUseColor());
@@ -302,8 +300,7 @@
           new Event(CommandInterpreter::eBroadcastBitResetPrompt,
                     new EventDataBytes(new_prompt)));
       GetCommandInterpreter().BroadcastEvent(prompt_change_event_sp);
-    } else if (strcmp(property_path, g_properties[ePropertyUseColor].name) ==
-               0) {
+    } else if (property_path == g_properties[ePropertyUseColor].name) {
       // use-color changed. Ping the prompt so it can reset the ansi terminal
       // codes.
       SetPrompt(GetPrompt());
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp
index c55ad1c..7cac294 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -1321,9 +1321,8 @@
   }
 }
 
-void PseudoInstruction::SetDescription(const char *description) {
-  if (description && strlen(description) > 0)
-    m_description = description;
+void PseudoInstruction::SetDescription(llvm::StringRef description) {
+  m_description = description;
 }
 
 Instruction::Operand Instruction::Operand::BuildRegister(ConstString &r) {
diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp
index 00fbc4b..92c3c84 100644
--- a/lldb/source/Core/UserSettingsController.cpp
+++ b/lldb/source/Core/UserSettingsController.cpp
@@ -24,7 +24,7 @@
 using namespace lldb_private;
 
 lldb::OptionValueSP
-Properties::GetPropertyValue(const ExecutionContext *exe_ctx, const char *path,
+Properties::GetPropertyValue(const ExecutionContext *exe_ctx, llvm::StringRef path,
                              bool will_modify, Error &error) const {
   OptionValuePropertiesSP properties_sp(GetValueProperties());
   if (properties_sp)
@@ -33,8 +33,8 @@
 }
 
 Error Properties::SetPropertyValue(const ExecutionContext *exe_ctx,
-                                   VarSetOperationType op, const char *path,
-                                   const char *value) {
+                                   VarSetOperationType op, llvm::StringRef path,
+  llvm::StringRef value) {
   OptionValuePropertiesSP properties_sp(GetValueProperties());
   if (properties_sp)
     return properties_sp->SetSubValue(exe_ctx, op, path, value);
@@ -60,7 +60,7 @@
 }
 
 Error Properties::DumpPropertyValue(const ExecutionContext *exe_ctx,
-                                    Stream &strm, const char *property_path,
+                                    Stream &strm, llvm::StringRef property_path,
                                     uint32_t dump_mask) {
   OptionValuePropertiesSP properties_sp(GetValueProperties());
   if (properties_sp) {
@@ -93,16 +93,11 @@
 
 const char *Properties::GetExperimentalSettingsName() { return "experimental"; }
 
-bool Properties::IsSettingExperimental(const char *setting) {
-  if (setting == nullptr)
+bool Properties::IsSettingExperimental(llvm::StringRef setting) {
+  if (setting.empty())
     return false;
 
-  const char *experimental = GetExperimentalSettingsName();
-  const char *dot_pos = strchr(setting, '.');
-  if (dot_pos == nullptr)
-    return strcmp(experimental, setting) == 0;
-  else {
-    size_t first_elem_len = dot_pos - setting;
-    return strncmp(experimental, setting, first_elem_len) == 0;
-  }
+  llvm::StringRef experimental = GetExperimentalSettingsName();
+  size_t dot_pos = setting.find_first_of('.');
+  return setting.take_front(dot_pos) == experimental;
 }