aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/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 /include/llvm/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 'include/llvm/Support')
-rw-r--r--include/llvm/Support/CommandLine.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h
index e7f5a02..9b218da 100644
--- a/include/llvm/Support/CommandLine.h
+++ b/include/llvm/Support/CommandLine.h
@@ -302,6 +302,12 @@ struct LocationClass {
template<class Ty>
LocationClass<Ty> location(Ty &L) { return LocationClass<Ty>(L); }
+// opposite_of - Allow the user to specify which other option this
+// option is the opposite of.
+//
+template<class Ty>
+LocationClass<bool> opposite_of(Ty &O) { return location(O.getValue()); }
+
//===----------------------------------------------------------------------===//
// Enum valued command line option
@@ -577,6 +583,30 @@ public:
EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<boolOrDefault>);
//--------------------------------------------------
+// parser<boolInverse>
+class boolInverse { };
+template<>
+class parser<boolInverse> : public basic_parser<bool> {
+public:
+ typedef bool parser_data_type;
+ // parse - Return true on error.
+ bool parse(Option &O, const char *ArgName, const std::string &Arg,
+ bool &Val);
+
+ enum ValueExpected getValueExpectedFlagDefault() const {
+ return ValueOptional;
+ }
+
+ // getValueName - Do not print =<value> at all.
+ virtual const char *getValueName() const { return 0; }
+
+ // An out-of-line virtual method to provide a 'home' for this class.
+ virtual void anchor();
+};
+
+EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<bool>);
+
+//--------------------------------------------------
// parser<int>
//
template<>
@@ -917,6 +947,9 @@ EXTERN_TEMPLATE_INSTANTIATION(class opt<int>);
EXTERN_TEMPLATE_INSTANTIATION(class opt<std::string>);
EXTERN_TEMPLATE_INSTANTIATION(class opt<bool>);
+class boolInverse;
+typedef opt<bool, true, parser<boolInverse> > inverse_opt;
+
//===----------------------------------------------------------------------===//
// list_storage class