From 48c3341cfe47b5c4d0dca8fac80bfcf1ecaefb88 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Sat, 9 Jun 2018 22:44:44 +0000 Subject: [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. llvm-svn: 334353 --- llvm/lib/Support/Program.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'llvm/lib/Support/Program.cpp') diff --git a/llvm/lib/Support/Program.cpp b/llvm/lib/Support/Program.cpp index 8484b46e522..8c56fb6db2d 100644 --- a/llvm/lib/Support/Program.cpp +++ b/llvm/lib/Support/Program.cpp @@ -63,6 +63,15 @@ ProcessInfo sys::ExecuteNoWait(StringRef Program, const char **Args, return PI; } +bool sys::commandLineFitsWithinSystemLimits(StringRef Program, + ArrayRef Args) { + SmallVector 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" -- cgit v1.2.3