Make llvm::StringRef to std::string conversions explicit.

This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.

This doesn't actually modify StringRef yet, I'll do that in a follow-up.
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 939cc2b..12b05e7 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -573,7 +573,8 @@
       if (response.IsUnsupportedResponse()) {
         m_supports_jThreadsInfo = false;
       } else if (!response.Empty()) {
-        object_sp = StructuredData::ParseJSON(response.GetStringRef());
+        object_sp =
+            StructuredData::ParseJSON(std::string(response.GetStringRef()));
       }
     }
   }
@@ -685,7 +686,7 @@
     if (result != PacketResult::Success)
       return result;
 
-    const std::string &this_string = this_response.GetStringRef();
+    const std::string &this_string = std::string(this_response.GetStringRef());
 
     // Check for m or l as first character; l seems to mean this is the last
     // chunk
@@ -757,7 +758,7 @@
       return true;
     if (response.GetChar() == 'E') {
       // A string the describes what failed when launching...
-      error_str = response.GetStringRef().substr(1);
+      error_str = std::string(response.GetStringRef().substr(1));
     } else {
       error_str.assign("unknown error occurred launching process");
     }
@@ -1000,7 +1001,7 @@
         while (response.GetNameColonValue(name, value)) {
           if (name.equals("name")) {
             success = true;
-            m_gdb_server_name = value;
+            m_gdb_server_name = std::string(value);
           } else if (name.equals("version")) {
             llvm::StringRef major, minor;
             std::tie(major, minor) = value.split('.');
@@ -1158,7 +1159,7 @@
             if (!value.getAsInteger(0, sub))
               ++num_keys_decoded;
           } else if (name.equals("arch")) {
-            arch_name = value;
+            arch_name = std::string(value);
             ++num_keys_decoded;
           } else if (name.equals("triple")) {
             StringExtractor extractor(value);
@@ -1185,10 +1186,10 @@
               os_name = "ios";
               environment = "macabi";
             } else
-              os_name = value;
+              os_name = std::string(value);
             ++num_keys_decoded;
           } else if (name.equals("vendor")) {
-            vendor_name = value;
+            vendor_name = std::string(value);
             ++num_keys_decoded;
           } else if (name.equals("endian")) {
             byte_order = llvm::StringSwitch<lldb::ByteOrder>(value)
@@ -1956,9 +1957,9 @@
       } else if (name.equals("cpusubtype")) {
         value.getAsInteger(0, sub);
       } else if (name.equals("vendor")) {
-        vendor = value;
+        vendor = std::string(value);
       } else if (name.equals("ostype")) {
-        os_type = value;
+        os_type = std::string(value);
       }
     }
 
@@ -2049,10 +2050,10 @@
             os_name = "ios";
             environment = "macabi";
           } else
-            os_name = value;
+            os_name = std::string(value);
           ++num_keys_decoded;
         } else if (name.equals("vendor")) {
-          vendor_name = value;
+          vendor_name = std::string(value);
           ++num_keys_decoded;
         } else if (name.equals("endian")) {
           byte_order = llvm::StringSwitch<lldb::ByteOrder>(value)
@@ -2069,7 +2070,7 @@
           if (!value.getAsInteger(16, pid))
             ++num_keys_decoded;
         } else if (name.equals("elf_abi")) {
-          elf_abi = value;
+          elf_abi = std::string(value);
           ++num_keys_decoded;
         }
       }
@@ -2536,7 +2537,7 @@
     return 0;
 
   StructuredData::ObjectSP data =
-      StructuredData::ParseJSON(response.GetStringRef());
+      StructuredData::ParseJSON(std::string(response.GetStringRef()));
   if (!data)
     return 0;
 
@@ -2557,7 +2558,7 @@
     std::string socket_name;
     if (StructuredData::ObjectSP socket_name_osp =
             element->GetValueForKey(llvm::StringRef("socket_name")))
-      socket_name = socket_name_osp->GetStringValue();
+      socket_name = std::string(socket_name_osp->GetStringValue());
 
     if (port != 0 || !socket_name.empty())
       connection_urls.emplace_back(port, socket_name);
@@ -3667,7 +3668,7 @@
   }
 
   StructuredData::ObjectSP response_object_sp =
-      StructuredData::ParseJSON(response.GetStringRef());
+      StructuredData::ParseJSON(std::string(response.GetStringRef()));
   if (!response_object_sp)
     return llvm::None;
 
@@ -3722,7 +3723,7 @@
       return false;
     }
 
-    const std::string &str = chunk.GetStringRef();
+    const std::string &str = std::string(chunk.GetStringRef());
     if (str.length() == 0) {
       // should have some data in chunk
       err.SetErrorString("Empty response from $qXfer packet");
@@ -3936,7 +3937,7 @@
     if (SendPacketAndWaitForResponse("qStructuredDataPlugins", response,
                                      send_async) == PacketResult::Success) {
       m_supported_async_json_packets_sp =
-          StructuredData::ParseJSON(response.GetStringRef());
+          StructuredData::ParseJSON(std::string(response.GetStringRef()));
       if (m_supported_async_json_packets_sp &&
           !m_supported_async_json_packets_sp->GetAsArray()) {
         // We were returned something other than a JSON array.  This is