summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2013-08-02 21:20:27 +0000
committerHans Wennborg <hans@hanshq.net>2013-08-02 21:20:27 +0000
commitb8f3420d1eb77075f66c83bced17bb2067f1c01f (patch)
tree072a91e03f6f583096d14523ef9c5f74dc40f38d /llvm/lib
parente9efbf140bac0ce5116d39f892818bd7a042d87e (diff)
downloadbcm5719-llvm-b8f3420d1eb77075f66c83bced17bb2067f1c01f.tar.gz
bcm5719-llvm-b8f3420d1eb77075f66c83bced17bb2067f1c01f.zip
Option parsing: recognize the special -- token
Everything that comes after -- should be treated as a filename. This enables passing in filenames that would otherwise be conflated with command-line options. This is especially important for clang-cl which supports options starting with /, which are easily conflatable with Unix-style path names. Differential Revision: http://llvm-reviews.chandlerc.com/D1274 llvm-svn: 187675
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Option/OptTable.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp
index 11439d3e56f..98e63bc2de9 100644
--- a/llvm/lib/Option/OptTable.cpp
+++ b/llvm/lib/Option/OptTable.cpp
@@ -253,11 +253,26 @@ InputArgList *OptTable::ParseArgs(const char *const *ArgBegin,
unsigned Index = 0, End = ArgEnd - ArgBegin;
while (Index < End) {
// Ignore empty arguments (other things may still take them as arguments).
- if (Args->getArgString(Index)[0] == '\0') {
+ StringRef Str = Args->getArgString(Index);
+ if (Str == "") {
++Index;
continue;
}
+ if (Str == "--") {
+ // Everything after -- is a filename.
+ ++Index;
+
+ assert(TheInputOptionID != 0 && "Invalid input option ID.");
+ while (Index < End) {
+ Args->append(new Arg(getOption(TheInputOptionID),
+ Args->getArgString(Index), Index,
+ Args->getArgString(Index)));
+ ++Index;
+ }
+ break;
+ }
+
unsigned Prev = Index;
Arg *A = ParseOneArg(*Args, Index, FlagsToInclude, FlagsToExclude);
assert(Index > Prev && "Parser failed to consume argument.");
OpenPOWER on IntegriCloud