Add a version of sys::ExecuteAndWait that takes StringRefs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183934 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/Support/Program.h b/include/llvm/Support/Program.h
index 38fc8c2..c8729c7 100644
--- a/include/llvm/Support/Program.h
+++ b/include/llvm/Support/Program.h
@@ -80,6 +80,11 @@
       ///< program.
       bool *ExecutionFailed = 0);
 
+  int ExecuteAndWait(StringRef path, const char **args, const char **env = 0,
+                     const StringRef **redirects = 0,
+                     unsigned secondsToWait = 0, unsigned memoryLimit = 0,
+                     std::string *ErrMsg = 0, bool *ExecutionFailed = 0);
+
   /// Similar to ExecuteAndWait, but return immediately.
   void ExecuteNoWait(const Path &path, const char **args, const char **env = 0,
                      const sys::Path **redirects = 0, unsigned memoryLimit = 0,
diff --git a/lib/Support/Program.cpp b/lib/Support/Program.cpp
index b1a9b98..1659726 100644
--- a/lib/Support/Program.cpp
+++ b/lib/Support/Program.cpp
@@ -29,6 +29,29 @@
 static int Wait(void *&Data, const Path &path, unsigned secondsToWait,
                 std::string *ErrMsg);
 
+int sys::ExecuteAndWait(StringRef path, const char **args, const char **env,
+                        const StringRef **redirects, unsigned secondsToWait,
+                        unsigned memoryLimit, std::string *ErrMsg,
+                        bool *ExecutionFailed) {
+  Path P(path);
+  if (!redirects)
+    return ExecuteAndWait(P, args, env, 0, secondsToWait, memoryLimit, ErrMsg,
+                          ExecutionFailed);
+  Path IO[3];
+  const Path *IOP[3];
+  for (int I = 0; I < 3; ++I) {
+    if (redirects[I]) {
+      IO[I] = *redirects[I];
+      IOP[I] = &IO[I];
+    } else {
+      IOP[I] = 0;
+   }
+  }
+
+  return ExecuteAndWait(P, args, env, IOP, secondsToWait, memoryLimit, ErrMsg,
+                        ExecutionFailed);
+}
+
 int sys::ExecuteAndWait(const Path &path, const char **args, const char **envp,
                         const Path **redirects, unsigned secondsToWait,
                         unsigned memoryLimit, std::string *ErrMsg,