[Support] Expose flattenWindowsCommandLine.

This function was internal to Program.inc, but I've needed this
on several occasions when I've had to use CreateProcess without
llvm's sys::Execute functions.  In doing so, I noticed that the
function was written using unsafe C-string access and was pretty
hard to understand / make sense of, so I've also re-written the
functions to use more modern LLVM constructs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334353 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zachary Turner
2018-06-09 22:44:44 +00:00
parent 0c500a83b4
commit 861985beca
3 changed files with 90 additions and 114 deletions
+9
View File
@@ -63,6 +63,15 @@ ProcessInfo sys::ExecuteNoWait(StringRef Program, const char **Args,
return PI;
}
bool sys::commandLineFitsWithinSystemLimits(StringRef Program,
ArrayRef<const char *> Args) {
SmallVector<StringRef, 8> StringRefArgs;
StringRefArgs.reserve(Args.size());
for (const char *A : Args)
StringRefArgs.emplace_back(A);
return commandLineFitsWithinSystemLimits(Program, StringRefArgs);
}
// Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX
#include "Unix/Program.inc"