Fix more functions in Args to use StringRef.

This patch also marks the const char* versions as =delete to prevent
their use.  This has the potential to cause build breakages on some
platforms which I can't compile.  I have tested on Windows, Linux,
and OSX.  Best practices for fixing broken callsites are outlined in
Args.h in a comment above the deleted function declarations.

Eventually we can remove these =delete declarations, but for now they
are important to make sure that all implicit conversions from
const char * are manually audited to make sure that they do not invoke a
conversion from nullptr.

llvm-svn: 281919
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index ef3e75b..14c64f2 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1067,31 +1067,31 @@
     char arg_cstr[PATH_MAX];
 
     // Start args with "debugserver /file/path -r --"
-    debugserver_args.AppendArgument(debugserver_path);
+    debugserver_args.AppendArgument(llvm::StringRef(debugserver_path));
 
 #if !defined(__APPLE__)
     // First argument to lldb-server must be mode in which to run.
-    debugserver_args.AppendArgument("gdbserver");
+    debugserver_args.AppendArgument(llvm::StringRef("gdbserver"));
 #endif
 
     // If a url is supplied then use it
     if (url)
-      debugserver_args.AppendArgument(url);
+      debugserver_args.AppendArgument(llvm::StringRef(url));
 
     if (pass_comm_fd >= 0) {
       StreamString fd_arg;
       fd_arg.Printf("--fd=%i", pass_comm_fd);
-      debugserver_args.AppendArgument(fd_arg.GetData());
+      debugserver_args.AppendArgument(fd_arg.GetString());
       // Send "pass_comm_fd" down to the inferior so it can use it to
       // communicate back with this process
       launch_info.AppendDuplicateFileAction(pass_comm_fd, pass_comm_fd);
     }
 
     // use native registers, not the GDB registers
-    debugserver_args.AppendArgument("--native-regs");
+    debugserver_args.AppendArgument(llvm::StringRef("--native-regs"));
 
     if (launch_info.GetLaunchInSeparateProcessGroup()) {
-      debugserver_args.AppendArgument("--setsid");
+      debugserver_args.AppendArgument(llvm::StringRef("--setsid"));
     }
 
     llvm::SmallString<PATH_MAX> named_pipe_path;
@@ -1137,8 +1137,8 @@
           return error;
         }
         int write_fd = socket_pipe.GetWriteFileDescriptor();
-        debugserver_args.AppendArgument("--pipe");
-        debugserver_args.AppendArgument(llvm::to_string(write_fd).c_str());
+        debugserver_args.AppendArgument(llvm::StringRef("--pipe"));
+        debugserver_args.AppendArgument(llvm::to_string(write_fd));
         launch_info.AppendCloseFileAction(socket_pipe.GetReadFileDescriptor());
 #endif
       } else {
@@ -1164,8 +1164,8 @@
           // Send the host and port down that debugserver and specify an option
           // so that it connects back to the port we are listening to in this
           // process
-          debugserver_args.AppendArgument("--reverse-connect");
-          debugserver_args.AppendArgument(port_cstr);
+          debugserver_args.AppendArgument(llvm::StringRef("--reverse-connect"));
+          debugserver_args.AppendArgument(llvm::StringRef(port_cstr));
           if (port)
             *port = port_;
         } else {
@@ -1182,7 +1182,7 @@
     if (env_debugserver_log_file) {
       ::snprintf(arg_cstr, sizeof(arg_cstr), "--log-file=%s",
                  env_debugserver_log_file);
-      debugserver_args.AppendArgument(arg_cstr);
+      debugserver_args.AppendArgument(llvm::StringRef(arg_cstr));
     }
 
 #if defined(__APPLE__)
@@ -1199,7 +1199,7 @@
     if (env_debugserver_log_channels) {
       ::snprintf(arg_cstr, sizeof(arg_cstr), "--log-channels=%s",
                  env_debugserver_log_channels);
-      debugserver_args.AppendArgument(arg_cstr);
+      debugserver_args.AppendArgument(llvm::StringRef(arg_cstr));
     }
 #endif
 
@@ -1215,7 +1215,7 @@
       has_env_var = extra_arg != nullptr;
 
       if (has_env_var) {
-        debugserver_args.AppendArgument(extra_arg);
+        debugserver_args.AppendArgument(llvm::StringRef(extra_arg));
         if (log)
           log->Printf("GDBRemoteCommunication::%s adding env var %s contents "
                       "to stub command line (%s)",
@@ -1224,7 +1224,7 @@
     } while (has_env_var);
 
     if (inferior_args && inferior_args->GetArgumentCount() > 0) {
-      debugserver_args.AppendArgument("--");
+      debugserver_args.AppendArgument(llvm::StringRef("--"));
       debugserver_args.AppendArguments(*inferior_args);
     }
 
@@ -1232,7 +1232,7 @@
     StringList env;
     if (Host::GetEnvironment(env)) {
       for (size_t i = 0; i < env.GetSize(); ++i)
-        launch_info.GetEnvironmentEntries().AppendArgument(env[i].c_str());
+        launch_info.GetEnvironmentEntries().AppendArgument(env[i]);
     }
 
     // Close STDIN, STDOUT and STDERR.
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 0d7ca3c..9dfb47d 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -946,7 +946,8 @@
   packet.SetFilePos(::strlen("QEnvironment:"));
   const uint32_t bytes_left = packet.GetBytesLeft();
   if (bytes_left > 0) {
-    m_process_launch_info.GetEnvironmentEntries().AppendArgument(packet.Peek());
+    m_process_launch_info.GetEnvironmentEntries().AppendArgument(
+        llvm::StringRef::withNullAsEmpty(packet.Peek()));
     return SendOKResponse();
   }
   return SendErrorResponse(12);
@@ -960,7 +961,7 @@
   if (bytes_left > 0) {
     std::string str;
     packet.GetHexByteString(str);
-    m_process_launch_info.GetEnvironmentEntries().AppendArgument(str.c_str());
+    m_process_launch_info.GetEnvironmentEntries().AppendArgument(str);
     return SendOKResponse();
   }
   return SendErrorResponse(12);
@@ -1032,8 +1033,7 @@
                 if (arg_idx == 0)
                   m_process_launch_info.GetExecutableFile().SetFile(arg.c_str(),
                                                                     false);
-                m_process_launch_info.GetArguments().AppendArgument(
-                    arg.c_str());
+                m_process_launch_info.GetArguments().AppendArgument(arg);
                 if (log)
                   log->Printf("LLGSPacketHandler::%s added arg %d: \"%s\"",
                               __FUNCTION__, actual_arg_index, arg.c_str());
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 504aa4f..4230601 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4158,8 +4158,7 @@
             alt_name.SetString(value);
           } else if (name == "encoding") {
             encoding_set = true;
-            reg_info.encoding =
-                Args::StringToEncoding(value.data(), eEncodingUint);
+            reg_info.encoding = Args::StringToEncoding(value, eEncodingUint);
           } else if (name == "format") {
             format_set = true;
             Format format = eFormatInvalid;
@@ -4198,7 +4197,7 @@
                 StringConvert::ToUInt32(value.data(), LLDB_INVALID_REGNUM, 0);
           } else if (name == "generic") {
             reg_info.kinds[eRegisterKindGeneric] =
-                Args::StringToGenericRegister(value.data());
+                Args::StringToGenericRegister(value);
           } else if (name == "value_regnums") {
             SplitCommaSeparatedRegisterNumberString(value, value_regs, 0);
           } else if (name == "invalidate_regnums") {