aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-01-30 08:19:46 +0000
committerMike Stump <mrs@apple.com>2009-01-30 08:19:46 +0000
commitd6f175b3ec8d40e33ab8110020ca8feb98295834 (patch)
tree3091e0cccbf5a365cc770b720e74744a610d3c7f /lib/Support
parente0ffc92508a50ede2dd6f15140e7185cb6e0bcb5 (diff)
downloadexternal_llvm-d6f175b3ec8d40e33ab8110020ca8feb98295834.zip
external_llvm-d6f175b3ec8d40e33ab8110020ca8feb98295834.tar.gz
external_llvm-d6f175b3ec8d40e33ab8110020ca8feb98295834.tar.bz2
Add opposite_of and inverse_opt to support -fno- style options. This
is necessary for eventual gcc commmand line compatibility. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63384 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/CommandLine.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index 2414734..e06f324 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -40,6 +40,7 @@ using namespace cl;
//
TEMPLATE_INSTANTIATION(class basic_parser<bool>);
TEMPLATE_INSTANTIATION(class basic_parser<boolOrDefault>);
+TEMPLATE_INSTANTIATION(class basic_parser<boolInverse>);
TEMPLATE_INSTANTIATION(class basic_parser<int>);
TEMPLATE_INSTANTIATION(class basic_parser<unsigned>);
TEMPLATE_INSTANTIATION(class basic_parser<double>);
@@ -55,6 +56,7 @@ void Option::anchor() {}
void basic_parser_impl::anchor() {}
void parser<bool>::anchor() {}
void parser<boolOrDefault>::anchor() {}
+void parser<boolInverse>::anchor() {}
void parser<int>::anchor() {}
void parser<unsigned>::anchor() {}
void parser<double>::anchor() {}
@@ -882,7 +884,8 @@ bool parser<boolOrDefault>::parse(Option &O, const char *ArgName,
if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" ||
Arg == "1") {
Value = BOU_TRUE;
- } else if (Arg == "false" || Arg == "FALSE" || Arg == "False" || Arg == "0") {
+ } else if (Arg == "false" || Arg == "FALSE"
+ || Arg == "False" || Arg == "0") {
Value = BOU_FALSE;
} else {
return O.error(": '" + Arg +
@@ -891,6 +894,23 @@ bool parser<boolOrDefault>::parse(Option &O, const char *ArgName,
return false;
}
+// parser<boolInverse> implementation
+//
+bool parser<boolInverse>::parse(Option &O, const char *ArgName,
+ const std::string &Arg, bool &Value) {
+ if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" ||
+ Arg == "1") {
+ Value = false;
+ } else if (Arg == "false" || Arg == "FALSE"
+ || Arg == "False" || Arg == "0") {
+ Value = true;
+ } else {
+ return O.error(": '" + Arg +
+ "' is invalid value for boolean argument! Try 0 or 1");
+ }
+ return false;
+}
+
// parser<int> implementation
//
bool parser<int>::parse(Option &O, const char *ArgName,