diff options
author | Chris Lattner <sabre@nondot.org> | 2002-07-23 17:15:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-07-23 17:15:12 +0000 |
commit | 494c0b07de8a273d5b72bb41128b58a5a00e1342 (patch) | |
tree | dc182b239e43cfa5245a620965d633b5ca288fe9 /llvm/lib/Support/CommandLine.cpp | |
parent | ee49ae06266ca5d98c347bfc3d9a7073d74a2efb (diff) | |
download | bcm5719-llvm-494c0b07de8a273d5b72bb41128b58a5a00e1342.tar.gz bcm5719-llvm-494c0b07de8a273d5b72bb41128b58a5a00e1342.zip |
*** empty log message ***
llvm-svn: 2999
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 001fdac476d..cafc14d3206 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -435,6 +435,22 @@ void Option::addArgument(const char *ArgStr) { } } +void Option::removeArgument(const char *ArgStr) { + if (ArgStr[0]) { + assert(getOpts()[ArgStr] == this && "Arg not in map!"); + getOpts().erase(ArgStr); + } else if (getFormattingFlag() == Positional) { + vector<Option*>::iterator I = + std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); + assert(I != getPositionalOpts().end() && "Arg not registered!"); + getPositionalOpts().erase(I); + } else if (getNumOccurancesFlag() == ConsumeAfter) { + assert(!getPositionalOpts().empty() && getPositionalOpts()[0] == this && + "Arg not registered correctly!"); + getPositionalOpts().erase(getPositionalOpts().begin()); + } +} + // getValueStr - Get the value description string, using "DefaultMsg" if nothing // has been specified yet. @@ -571,6 +587,22 @@ void parser<string>::printOptionInfo(const Option &O, // generic_parser_base implementation // +// findOption - Return the option number corresponding to the specified +// argument string. If the option is not found, getNumOptions() is returned. +// +unsigned generic_parser_base::findOption(const char *Name) { + unsigned i = 0, e = getNumOptions(); + string N(Name); + + while (i != e) + if (getOption(i) == N) + return i; + else + ++i; + return e; +} + + // Return the width of the option tag for printing... unsigned generic_parser_base::getOptionWidth(const Option &O) const { if (O.hasArgStr()) { |