summaryrefslogtreecommitdiffstats
path: root/lib/Option
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2013-08-13 21:09:50 +0000
committerHans Wennborg <hans@hanshq.net>2013-08-13 21:09:50 +0000
commitaf9e3557552c341615052a05d4eeb36d7fd5c33f (patch)
tree4849f2d2fea5491ad0421600d01edbd9cd2e05c5 /lib/Option
parent3f70e908c3d9de7acea462719ebf36dca1560f9c (diff)
downloadexternal_llvm-af9e3557552c341615052a05d4eeb36d7fd5c33f.zip
external_llvm-af9e3557552c341615052a05d4eeb36d7fd5c33f.tar.gz
external_llvm-af9e3557552c341615052a05d4eeb36d7fd5c33f.tar.bz2
Options: Add new option kind that consumes remaining arguments
This adds KIND_REMAINING_ARGS, a class of options that consume all remaining arguments on the command line. This will be used to support /link in clang-cl, which is used to forward all remaining arguments to the linker. It also allows us to remove the hard-coded handling of "--", allowing clients (clang and lld) to implement that functionality themselves with this new option class. Differential Revision: http://llvm-reviews.chandlerc.com/D1387 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188314 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Option')
-rw-r--r--lib/Option/OptTable.cpp3
-rw-r--r--lib/Option/Option.cpp11
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/Option/OptTable.cpp b/lib/Option/OptTable.cpp
index 98e63bc..650aec8 100644
--- a/lib/Option/OptTable.cpp
+++ b/lib/Option/OptTable.cpp
@@ -259,6 +259,8 @@ InputArgList *OptTable::ParseArgs(const char *const *ArgBegin,
continue;
}
+ // FIXME: Remove once clients are updated to use a KIND_REMAINING_ARGS
+ // option to handle this explicitly instead.
if (Str == "--") {
// Everything after -- is a filename.
++Index;
@@ -308,6 +310,7 @@ static std::string getOptionHelpName(const OptTable &Opts, OptSpecifier Id) {
break;
case Option::SeparateClass: case Option::JoinedOrSeparateClass:
+ case Option::RemainingArgsClass:
Name += ' ';
// FALLTHROUGH
case Option::JoinedClass: case Option::CommaJoinedClass:
diff --git a/lib/Option/Option.cpp b/lib/Option/Option.cpp
index 1d6a3d3..7b5ff2b 100644
--- a/lib/Option/Option.cpp
+++ b/lib/Option/Option.cpp
@@ -52,6 +52,7 @@ void Option::dump() const {
P(MultiArgClass);
P(JoinedOrSeparateClass);
P(JoinedAndSeparateClass);
+ P(RemainingArgsClass);
#undef P
}
@@ -214,6 +215,16 @@ Arg *Option::accept(const ArgList &Args,
return new Arg(UnaliasedOption, Spelling, Index - 2,
Args.getArgString(Index - 2) + ArgSize,
Args.getArgString(Index - 1));
+ case RemainingArgsClass: {
+ // Matches iff this is an exact match.
+ // FIXME: Avoid strlen.
+ if (ArgSize != strlen(Args.getArgString(Index)))
+ return 0;
+ Arg *A = new Arg(UnaliasedOption, Spelling, Index++);
+ while (Index < Args.getNumInputArgStrings())
+ A->getValues().push_back(Args.getArgString(Index++));
+ return A;
+ }
default:
llvm_unreachable("Invalid option kind!");
}