Convert some functions to use StringRef instead of c_str, len

This started as an effort to change StringExtractor to store a
StringRef internally instead of a std::string.  I got that working
locally with just 1 test failure which I was unable to figure out the
cause of.  But it was also a massive changelist due to a trickle
down effect of changes.

So I'm starting over, using what I learned from the first time to
tackle smaller, more isolated changes hopefully leading up to
a full conversion by the end.

At first the changes (such as in this CL) will seem mostly
a matter of preference and pointless otherwise.  However, there
are some places in my larger CL where using StringRef turned 20+
lines of code into 2, drastically simplifying logic.  Hopefully
once these go in they will illustrate some of the benefits of
thinking in terms of StringRef.

llvm-svn: 279917
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 7095815..1472b65 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -264,7 +264,7 @@
     if (g_default_packet_timeout_sec > 0)
         response.Printf ("default_packet_timeout:%u;", g_default_packet_timeout_sec);
 
-    return SendPacketNoLock (response.GetData(), response.GetSize());
+    return SendPacketNoLock (response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -280,7 +280,7 @@
         {
             StreamString response;
             CreateProcessInfoResponse (proc_info, response);
-            return SendPacketNoLock (response.GetData(), response.GetSize());
+            return SendPacketNoLock (response.GetString());
         }
     }
     return SendErrorResponse (1);
@@ -395,7 +395,7 @@
         StreamString response;
         CreateProcessInfoResponse (m_proc_infos.GetProcessInfoAtIndex(m_proc_infos_index), response);
         ++m_proc_infos_index;
-        return SendPacketNoLock (response.GetData(), response.GetSize());
+        return SendPacketNoLock (response.GetString());
     }
     return SendErrorResponse (4);
 }
@@ -480,7 +480,7 @@
                     bytes_left = 0;
                 }
             }
-            return SendPacketNoLock (response.GetData(), response.GetSize());
+            return SendPacketNoLock (response.GetString());
         }
     }
     return SendErrorResponse (7);
@@ -510,7 +510,7 @@
                 response.Printf("%i", fd);
                 if (save_errno)
                     response.Printf(",%i", save_errno);
-                return SendPacketNoLock(response.GetData(), response.GetSize());
+                return SendPacketNoLock(response.GetString());
             }
         }
     }
@@ -539,7 +539,7 @@
     response.Printf("%i", err);
     if (save_errno)
         response.Printf(",%i", save_errno);
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -638,7 +638,7 @@
             response.PutChar(',');
             response.PutHex64(retcode); // TODO: replace with Host::GetSyswideErrorCode()
         }
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     return SendErrorResponse(22);
 }
@@ -657,7 +657,7 @@
         response.Printf("F%u", mode);
         if (mode == 0 || error.Fail())
             response.Printf(",%i", (int)error.GetError());
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     return SendErrorResponse(23);
 }
@@ -678,7 +678,7 @@
             response.PutChar('1');
         else
             response.PutChar('0');
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     return SendErrorResponse(24);
 }
@@ -694,7 +694,7 @@
     Error error = FileSystem::Symlink(FileSpec{src, true}, FileSpec{dst, false});
     StreamString response;
     response.Printf("F%u,%u", error.GetError(), error.GetError());
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -706,7 +706,7 @@
     Error error = FileSystem::Unlink(FileSpec{path, true});
     StreamString response;
     response.Printf("F%u,%u", error.GetError(), error.GetError());
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -745,7 +745,7 @@
                 response.PutChar(',');
                 response.PutEscapedBytes(output.c_str(), output.size());
             }
-            return SendPacketNoLock(response.GetData(), response.GetSize());
+            return SendPacketNoLock(response.GetString());
         }
     }
     return SendErrorResponse(24);
@@ -779,7 +779,7 @@
             response.PutHex64(a);
             response.PutHex64(b);
         }
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     return SendErrorResponse(25);
 }
@@ -798,7 +798,7 @@
         StreamGDBRemote response;
         response.Printf("F%u", error.GetError());
 
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     return SendErrorResponse(20);
 }
@@ -818,7 +818,7 @@
         StreamGDBRemote response;
         response.Printf("F%u", error.GetError());
 
-        return SendPacketNoLock(response.GetData(), response.GetSize());
+        return SendPacketNoLock(response.GetString());
     }
     return SendErrorResponse(19);
 }
@@ -840,7 +840,7 @@
     response.PutCString (";qXfer:auxv:read+");
 #endif
 
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -936,7 +936,7 @@
     StreamString response;
     response.PutChar('E');
     response.PutCString(m_process_launch_error.AsCString("<unknown error>"));
-    return SendPacketNoLock (response.GetData(), response.GetSize());
+    return SendPacketNoLock (response.GetString());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -1077,7 +1077,7 @@
 GDBRemoteCommunicationServerCommon::Handle_qEcho (StringExtractorGDBRemote &packet)
 {
     // Just echo back the exact same packet for qEcho...
-    return SendPacketNoLock(packet.GetStringRef().c_str(), packet.GetStringRef().size());
+    return SendPacketNoLock(packet.GetStringRef());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -1144,7 +1144,7 @@
     response.PutHex64(file_size);
     response.PutChar(';');
 
-    return SendPacketNoLock(response.GetData(), response.GetSize());
+    return SendPacketNoLock(response.GetString());
 }
 
 void