Make lldb::Regex use StringRef.
This updates getters and setters to use StringRef instead of
const char *.  I tested the build on Linux, Windows, and OSX
and saw no build or test failures.  I cannot test any BSD
or Android variants, however I expect the required changes
to be minimal or non-existant.
llvm-svn: 282079
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index 82faf7f..66dee4b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -999,16 +999,18 @@
     const char *producer_cstr = die->GetAttributeValueAsString(
         m_dwarf2Data, this, DW_AT_producer, NULL);
     if (producer_cstr) {
-      RegularExpression llvm_gcc_regex("^4\\.[012]\\.[01] \\(Based on Apple "
-                                       "Inc\\. build [0-9]+\\) \\(LLVM build "
-                                       "[\\.0-9]+\\)$");
-      if (llvm_gcc_regex.Execute(producer_cstr)) {
+      RegularExpression llvm_gcc_regex(
+          llvm::StringRef("^4\\.[012]\\.[01] \\(Based on Apple "
+                          "Inc\\. build [0-9]+\\) \\(LLVM build "
+                          "[\\.0-9]+\\)$"));
+      if (llvm_gcc_regex.Execute(llvm::StringRef(producer_cstr))) {
         m_producer = eProducerLLVMGCC;
       } else if (strstr(producer_cstr, "clang")) {
         static RegularExpression g_clang_version_regex(
-            "clang-([0-9]+)\\.([0-9]+)\\.([0-9]+)");
+            llvm::StringRef("clang-([0-9]+)\\.([0-9]+)\\.([0-9]+)"));
         RegularExpression::Match regex_match(3);
-        if (g_clang_version_regex.Execute(producer_cstr, ®ex_match)) {
+        if (g_clang_version_regex.Execute(llvm::StringRef(producer_cstr),
+                                          ®ex_match)) {
           std::string str;
           if (regex_match.GetMatchAtIndex(producer_cstr, 1, str))
             m_producer_version_major =
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index e06c1b8..9dc656d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -535,18 +535,20 @@
                    const uint32_t curr_depth, void *userData) {
   FindCallbackStringInfo *info = (FindCallbackStringInfo *)userData;
 
-  if (die) {
-    const char *die_name = die->GetName(dwarf2Data, cu);
-    if (die_name) {
-      if (info->regex) {
-        if (info->regex->Execute(die_name))
-          info->die_offsets.push_back(die->GetOffset());
-      } else {
-        if ((info->ignore_case ? strcasecmp(die_name, info->name)
-                               : strcmp(die_name, info->name)) == 0)
-          info->die_offsets.push_back(die->GetOffset());
-      }
-    }
+  if (!die)
+    return next_offset;
+
+  const char *die_name = die->GetName(dwarf2Data, cu);
+  if (!die_name)
+    return next_offset;
+
+  if (info->regex) {
+    if (info->regex->Execute(llvm::StringRef(die_name)))
+      info->die_offsets.push_back(die->GetOffset());
+  } else {
+    if ((info->ignore_case ? strcasecmp(die_name, info->name)
+                           : strcmp(die_name, info->name)) == 0)
+      info->die_offsets.push_back(die->GetOffset());
   }
 
   // Just return the current offset to parse the next CU or DIE entry
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
index 16c0b90..afdb1d6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "HashedNameToDIE.h"
+#include "llvm/ADT/StringRef.h"
 
 void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
                                       DIEArray &die_offsets) {
@@ -469,7 +470,7 @@
   if (count > 0 &&
       m_data.ValidOffsetForDataOfSize(*hash_data_offset_ptr,
                                       min_total_hash_data_size)) {
-    const bool match = regex.Execute(strp_cstr);
+    const bool match = regex.Execute(llvm::StringRef(strp_cstr));
 
     if (!match && m_header.header_data.HashDataHasFixedByteSize()) {
       // If the regex doesn't match and we have fixed size data,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 5c8083c..92e513d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2198,7 +2198,7 @@
     GetObjectFile()->GetModule()->LogMessage(
         log, "SymbolFileDWARF::FindGlobalVariables (regex=\"%s\", append=%u, "
              "max_matches=%u, variables)",
-        regex.GetText(), append, max_matches);
+        regex.GetText().str().c_str(), append, max_matches);
   }
 
   DWARFDebugInfo *info = DebugInfo();
@@ -2252,7 +2252,7 @@
           GetObjectFile()->GetModule()->ReportErrorIfModifyDetected(
               "the DWARF debug information has been modified (.apple_names "
               "accelerator table had bad die 0x%8.8x for regex '%s')\n",
-              die_ref.die_offset, regex.GetText());
+              die_ref.die_offset, regex.GetText().str().c_str());
         }
       }
     }
@@ -2673,7 +2673,7 @@
                                         SymbolContextList &sc_list) {
   Timer scoped_timer(LLVM_PRETTY_FUNCTION,
                      "SymbolFileDWARF::FindFunctions (regex = '%s')",
-                     regex.GetText());
+                     regex.GetText().str().c_str());
 
   Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
 
@@ -2681,7 +2681,7 @@
     GetObjectFile()->GetModule()->LogMessage(
         log,
         "SymbolFileDWARF::FindFunctions (regex=\"%s\", append=%u, sc_list)",
-        regex.GetText(), append);
+        regex.GetText().str().c_str(), append);
   }
 
   // If we aren't appending the results to this list, then clear the list
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 3933a2b..6a1b6b4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1020,7 +1020,7 @@
                                                 SymbolContextList &sc_list) {
   Timer scoped_timer(LLVM_PRETTY_FUNCTION,
                      "SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')",
-                     regex.GetText());
+                     regex.GetText().str().c_str());
 
   uint32_t initial_size = 0;
   if (append)