summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-07-23 17:15:12 +0000
committerChris Lattner <sabre@nondot.org>2002-07-23 17:15:12 +0000
commitaa852bbb503571d1198856fa4c6e099d7625e3b3 (patch)
tree367ae1202fb1d7ab7178811249c3f1895f4c759b
parentaf7e82184d7d77e426056c7c233e860baeebe80f (diff)
downloadllvm-aa852bbb503571d1198856fa4c6e099d7625e3b3.tar.gz
llvm-aa852bbb503571d1198856fa4c6e099d7625e3b3.tar.bz2
llvm-aa852bbb503571d1198856fa4c6e099d7625e3b3.tar.xz
*** empty log message ***
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2999 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Support/CommandLine.cpp32
-rw-r--r--support/lib/Support/CommandLine.cpp32
2 files changed, 64 insertions, 0 deletions
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index 001fdac476..cafc14d320 100644
--- a/lib/Support/CommandLine.cpp
+++ b/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()) {
diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp
index 001fdac476..cafc14d320 100644
--- a/support/lib/Support/CommandLine.cpp
+++ b/support/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()) {