remove renamed method.
[oota-llvm.git] / include / llvm / Support / CommandLine.h
index 9b218dab031cf39c4ab5ea6694957573169c70a3..3ae50136e4a9d38ae2d0b87c3a4351d98463ffde 100644 (file)
@@ -25,6 +25,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/ADT/SmallVector.h"
 #include <cassert>
+#include <climits>
 #include <cstdarg>
 #include <string>
 #include <utility>
@@ -302,12 +303,6 @@ 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
@@ -542,10 +537,17 @@ struct basic_parser : public basic_parser_impl {
 //
 template<>
 class parser<bool> : public basic_parser<bool> {
+  const char *ArgStr;
 public:
+
   // parse - Return true on error.
   bool parse(Option &O, const char *ArgName, const std::string &Arg, bool &Val);
 
+  template <class Opt>
+  void initialize(Opt &O) {
+    ArgStr = O.ArgStr;
+  }
+
   enum ValueExpected getValueExpectedFlagDefault() const {
     return ValueOptional;
   }
@@ -582,30 +584,6 @@ 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>
 //
@@ -701,6 +679,28 @@ public:
 
 EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<std::string>);
 
+//--------------------------------------------------
+// parser<char>
+//
+template<>
+class parser<char> : public basic_parser<char> {
+public:
+  // parse - Return true on error.
+  bool parse(Option &, const char *, const std::string &Arg,
+             char &Value) {
+    Value = Arg[0];
+    return false;
+  }
+
+  // getValueName - Overload in subclass to provide a better default value.
+  virtual const char *getValueName() const { return "char"; }
+
+  // An out-of-line virtual method to provide a 'home' for this class.
+  virtual void anchor();
+};
+
+EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<char>);
+
 //===----------------------------------------------------------------------===//
 // applicator class - This class is used because we must use partial
 // specialization to handle literal string arguments specially (const char* does
@@ -760,7 +760,7 @@ template<class DataType, bool ExternalStorage, bool isClass>
 class opt_storage {
   DataType *Location;   // Where to store the object...
 
-  void check() {
+  void check() const {
     assert(Location != 0 && "cl::location(...) not specified for a command "
            "line option with external storage, "
            "or cl::init specified before cl::location()!!");
@@ -839,8 +839,8 @@ class opt : public Option,
        typename ParserClass::parser_data_type();
     if (Parser.parse(*this, ArgName, Arg, Val))
       return true;                            // Parse error!
-    setValue(Val);
-    setPosition(pos);
+    this->setValue(Val);
+    this->setPosition(pos);
     return false;
   }
 
@@ -945,11 +945,9 @@ public:
 EXTERN_TEMPLATE_INSTANTIATION(class opt<unsigned>);
 EXTERN_TEMPLATE_INSTANTIATION(class opt<int>);
 EXTERN_TEMPLATE_INSTANTIATION(class opt<std::string>);
+EXTERN_TEMPLATE_INSTANTIATION(class opt<char>);
 EXTERN_TEMPLATE_INSTANTIATION(class opt<bool>);
 
-class boolInverse;
-typedef opt<bool, true, parser<boolInverse> > inverse_opt;
-
 //===----------------------------------------------------------------------===//
 // list_storage class
 
@@ -1107,7 +1105,7 @@ public:
   }
 };
 
-// multi_arg - Modifier to set the number of additional values.
+// multi_val - Modifier to set the number of additional values.
 struct multi_val {
   unsigned AdditionalVals;
   explicit multi_val(unsigned N) : AdditionalVals(N) {}
@@ -1131,7 +1129,7 @@ class bits_storage {
   template<class T>
   static unsigned Bit(const T &V) {
     unsigned BitPos = reinterpret_cast<unsigned>(V);
-    assert(BitPos < sizeof(unsigned) * 8 &&
+    assert(BitPos < sizeof(unsigned) * CHAR_BIT &&
           "enum exceeds width of bit vector!");
     return 1 << BitPos;
   }
@@ -1172,7 +1170,7 @@ class bits_storage<DataType, bool> {
   template<class T>
   static unsigned Bit(const T &V) {
     unsigned BitPos = reinterpret_cast<unsigned>(V);
-    assert(BitPos < sizeof(unsigned) * 8 &&
+    assert(BitPos < sizeof(unsigned) * CHAR_BIT &&
           "enum exceeds width of bit vector!");
     return 1 << BitPos;
   }