aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Windows
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-04-11 14:06:34 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-04-11 14:06:34 +0000
commitcd848c0866cffc70f97b65689b269a1441ee48d0 (patch)
tree8b3ac5ae15ba65d78b72e370190b8c177d5a9ddb /llvm/lib/Support/Windows
parent9643a313ac976716f0893159f7d9d8c0bde7da63 (diff)
downloadllvm-cd848c0866cffc70f97b65689b269a1441ee48d0.zip
llvm-cd848c0866cffc70f97b65689b269a1441ee48d0.tar.gz
llvm-cd848c0866cffc70f97b65689b269a1441ee48d0.tar.bz2
Add a function to check if an argument list is too long.
This will be used in clang to decide if it should create an @file or not. It will be tested on the clang side. Patch by Nathan Froyd. llvm-svn: 179285
Diffstat (limited to 'llvm/lib/Support/Windows')
-rw-r--r--llvm/lib/Support/Windows/Program.inc16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Support/Windows/Program.inc b/llvm/lib/Support/Windows/Program.inc
index 691d6d4..994a097 100644
--- a/llvm/lib/Support/Windows/Program.inc
+++ b/llvm/lib/Support/Windows/Program.inc
@@ -396,4 +396,20 @@ error_code Program::ChangeStderrToBinary(){
return make_error_code(errc::success);
}
+bool llvm::sys::argumentsFitWithinSystemLimits(ArrayRef<const char*> Args) {
+ // The documented max length of the command line passed to CreateProcess.
+ static const size_t MaxCommandStringLength = 32768;
+ size_t ArgLength = 0;
+ for (ArrayRef<const char*>::iterator I = Args.begin(), E = Args.end();
+ I != E; ++I) {
+ // Account for the trailing space for every arg but the last one and the
+ // trailing NULL of the last argument.
+ ArgLength += ArgLenWithQuotes(*I) + 1;
+ if (ArgLength > MaxCommandStringLength) {
+ return false;
+ }
+ }
+ return true;
+}
+
}