diff options
author | Hans Wennborg <hans@hanshq.net> | 2016-04-15 00:23:30 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2016-04-15 00:23:30 +0000 |
commit | 40cfde3cb8f9fd5afe50396487b45b9b5f40a567 (patch) | |
tree | 0ab892cc2a798d05411e9318c94556af033b6c2f /llvm/lib/Option | |
parent | c940f097f414204c49afc901d39b463e23e29d09 (diff) | |
download | bcm5719-llvm-40cfde3cb8f9fd5afe50396487b45b9b5f40a567.tar.gz bcm5719-llvm-40cfde3cb8f9fd5afe50396487b45b9b5f40a567.zip |
Option parser: class for consuming a joined arg in addition to all remaining args
llvm-svn: 266394
Diffstat (limited to 'llvm/lib/Option')
-rw-r--r-- | llvm/lib/Option/OptTable.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Option/Option.cpp | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp index 09d4cebb83d..13aa9667b5c 100644 --- a/llvm/lib/Option/OptTable.cpp +++ b/llvm/lib/Option/OptTable.cpp @@ -315,7 +315,7 @@ static std::string getOptionHelpName(const OptTable &Opts, OptSpecifier Id) { break; case Option::SeparateClass: case Option::JoinedOrSeparateClass: - case Option::RemainingArgsClass: + case Option::RemainingArgsClass: case Option::RemainingArgsJoinedClass: Name += ' '; // FALLTHROUGH case Option::JoinedClass: case Option::CommaJoinedClass: diff --git a/llvm/lib/Option/Option.cpp b/llvm/lib/Option/Option.cpp index d191e0e9274..5eb179fbd25 100644 --- a/llvm/lib/Option/Option.cpp +++ b/llvm/lib/Option/Option.cpp @@ -51,6 +51,7 @@ void Option::print(raw_ostream &O) const { P(JoinedOrSeparateClass); P(JoinedAndSeparateClass); P(RemainingArgsClass); + P(RemainingArgsJoinedClass); #undef P } @@ -234,6 +235,19 @@ Arg *Option::accept(const ArgList &Args, A->getValues().push_back(Args.getArgString(Index++)); return A; } + case RemainingArgsJoinedClass: { + Arg *A = new Arg(UnaliasedOption, Spelling, Index); + if (ArgSize != strlen(Args.getArgString(Index))) { + // An inexact match means there is a joined arg. + A->getValues().push_back(Args.getArgString(Index) + ArgSize); + } + Index++; + while (Index < Args.getNumInputArgStrings() && + Args.getArgString(Index) != nullptr) + A->getValues().push_back(Args.getArgString(Index++)); + return A; + } + default: llvm_unreachable("Invalid option kind!"); } |