diff options
author | Zachary Turner <zturner@google.com> | 2018-06-10 02:46:11 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2018-06-10 02:46:11 +0000 |
commit | 5e119768a1ecf9d6f8ad5b38de7497cc334b69d9 (patch) | |
tree | 31ae8137e7b92faa9ff20039c9eaebc9ace074c2 /llvm/lib/Support/Unix/Program.inc | |
parent | 1fbca91c07975454d668926f535f36829616e2e2 (diff) | |
download | llvm-5e119768a1ecf9d6f8ad5b38de7497cc334b69d9.zip llvm-5e119768a1ecf9d6f8ad5b38de7497cc334b69d9.tar.gz llvm-5e119768a1ecf9d6f8ad5b38de7497cc334b69d9.tar.bz2 |
Resubmit "[Support] Expose flattenWindowsCommandLine."
There were a few linux compilation failures, but other than that
I think this was just a flake that caused the tests to fail. I'm
going to resubmit and see if the failures go away, if not I'll
revert again.
llvm-svn: 334355
Diffstat (limited to 'llvm/lib/Support/Unix/Program.inc')
-rw-r--r-- | llvm/lib/Support/Unix/Program.inc | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc index 04840bf..be97155 100644 --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc @@ -434,7 +434,7 @@ llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents, } bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program, - ArrayRef<const char *> Args) { + ArrayRef<StringRef> Args) { static long ArgMax = sysconf(_SC_ARG_MAX); // POSIX requires that _POSIX_ARG_MAX is 4096, which is the lowest possible // value for ARG_MAX on a POSIX compliant system. @@ -456,18 +456,16 @@ bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program, long HalfArgMax = EffectiveArgMax / 2; size_t ArgLength = Program.size() + 1; - for (const char* Arg : Args) { - size_t length = strlen(Arg); - + for (StringRef Arg : Args) { // Ensure that we do not exceed the MAX_ARG_STRLEN constant on Linux, which // does not have a constant unlike what the man pages would have you // believe. Since this limit is pretty high, perform the check // unconditionally rather than trying to be aggressive and limiting it to // Linux only. - if (length >= (32 * 4096)) + if (Arg.size() >= (32 * 4096)) return false; - ArgLength += length + 1; + ArgLength += Arg.size() + 1; if (ArgLength > size_t(HalfArgMax)) { return false; } |