Delete SlowOperationInformer, which is no longer used.
[oota-llvm.git] / include / llvm / Support / CommandLine.h
index 2e65fdd79a143dfa6c29b44b69527f33f3a7bbec..9ae3d6af32ee8cd68868e7fb0461d12e2ff2f7a5 100644 (file)
@@ -31,7 +31,7 @@
 #include <vector>
 
 namespace llvm {
-  
+
 /// cl Namespace - This namespace contains all of the command line option
 /// processing machinery.  It is intentionally a short name to make qualified
 /// usage concise.
@@ -93,9 +93,9 @@ enum ValueExpected {           // Is a value required for the option?
 };
 
 enum OptionHidden {            // Control whether -help shows this option
-  NotHidden       = 0x20,      // Option included in --help & --help-hidden
-  Hidden          = 0x40,      // -help doesn't, but --help-hidden does
-  ReallyHidden    = 0x60,      // Neither --help nor --help-hidden show this arg
+  NotHidden       = 0x20,      // Option included in -help & -help-hidden
+  Hidden          = 0x40,      // -help doesn't, but -help-hidden does
+  ReallyHidden    = 0x60,      // Neither -help nor -help-hidden show this arg
   HiddenMask      = 0x60
 };
 
@@ -159,7 +159,7 @@ class Option {
   Option *NextRegistered; // Singly linked list of registered options.
 public:
   const char *ArgStr;     // The argument string itself (ex: "help", "o")
-  const char *HelpStr;    // The descriptive text message for --help
+  const char *HelpStr;    // The descriptive text message for -help
   const char *ValueStr;   // String describing what the value of this option is
 
   inline enum NumOccurrencesFlag getNumOccurrencesFlag() const {
@@ -251,14 +251,14 @@ public:
 // command line option parsers...
 //
 
-// desc - Modifier to set the description shown in the --help output...
+// desc - Modifier to set the description shown in the -help output...
 struct desc {
   const char *Desc;
   desc(const char *Str) : Desc(Str) {}
   void apply(Option &O) const { O.setDescription(Desc); }
 };
 
-// value_desc - Modifier to set the value description shown in the --help
+// value_desc - Modifier to set the value description shown in the -help
 // output...
 struct value_desc {
   const char *Desc;
@@ -437,22 +437,29 @@ protected:
 // Default parser implementation - This implementation depends on having a
 // mapping of recognized options to values of some sort.  In addition to this,
 // each entry in the mapping also tracks a help message that is printed with the
-// command line option for --help.  Because this is a simple mapping parser, the
+// command line option for -help.  Because this is a simple mapping parser, the
 // data type can be any unsupported type.
 //
 template <class DataType>
 class parser : public generic_parser_base {
 protected:
-  SmallVector<std::pair<const char *,
-                        std::pair<DataType, const char *> >, 8> Values;
+  class OptionInfo {
+  public:
+    OptionInfo(const char *name, DataType v, const char *helpStr) :
+      Name(name), V(v), HelpStr(helpStr) {}
+    const char *Name;
+    DataType V;
+    const char *HelpStr;
+  };
+  SmallVector<OptionInfo, 8> Values;
 public:
   typedef DataType parser_data_type;
 
   // Implement virtual functions needed by generic_parser_base
   unsigned getNumOptions() const { return unsigned(Values.size()); }
-  const char *getOption(unsigned N) const { return Values[N].first; }
+  const char *getOption(unsigned N) const { return Values[N].Name; }
   const char *getDescription(unsigned N) const {
-    return Values[N].second.second;
+    return Values[N].HelpStr;
   }
 
   // parse - Return true on error.
@@ -465,8 +472,8 @@ public:
 
     for (unsigned i = 0, e = static_cast<unsigned>(Values.size());
          i != e; ++i)
-      if (Values[i].first == ArgVal) {
-        V = Values[i].second.first;
+      if (Values[i].Name == ArgVal) {
+        V = Values[i].V;
         return false;
       }
 
@@ -478,8 +485,8 @@ public:
   template <class DT>
   void addLiteralOption(const char *Name, const DT &V, const char *HelpStr) {
     assert(findOption(Name) == Values.size() && "Option already exists!");
-    Values.push_back(std::make_pair(Name,
-                             std::make_pair(static_cast<DataType>(V),HelpStr)));
+    OptionInfo X(Name, static_cast<DataType>(V), HelpStr);
+    Values.push_back(X);
     MarkOptionsChanged();
   }
 
@@ -781,7 +788,7 @@ public:
 
   DataType &getValue() { check(); return *Location; }
   const DataType &getValue() const { check(); return *Location; }
-  
+
   operator DataType() const { return this->getValue(); }
 };
 
@@ -986,7 +993,7 @@ template<class DataType>
 class list_storage<DataType, bool> : public std::vector<DataType> {
 public:
   template<class T>
-  void addValue(const T &V) { push_back(V); }
+  void addValue(const T &V) { std::vector<DataType>::push_back(V); }
 };
 
 
@@ -1011,7 +1018,7 @@ class list : public Option, public list_storage<DataType, Storage> {
       typename ParserClass::parser_data_type();
     if (Parser.parse(*this, ArgName, Arg, Val))
       return true;  // Parse Error!
-    addValue(Val);
+    list_storage<DataType, Storage>::addValue(Val);
     setPosition(pos);
     Positions.push_back(pos);
     return false;
@@ -1168,7 +1175,7 @@ class bits_storage<DataType, bool> {
 
   template<class T>
   static unsigned Bit(const T &V) {
-    unsigned BitPos = reinterpret_cast<unsigned>(V);
+    unsigned BitPos = (unsigned)V;
     assert(BitPos < sizeof(unsigned) * CHAR_BIT &&
           "enum exceeds width of bit vector!");
     return 1 << BitPos;
@@ -1373,7 +1380,7 @@ struct extrahelp {
 
 void PrintVersionMessage();
 // This function just prints the help message, exactly the same way as if the
-// --help option had been given on the command line.
+// -help option had been given on the command line.
 // NOTE: THIS FUNCTION TERMINATES THE PROGRAM!
 void PrintHelpMessage();