Switch all uses of LLVM_OVERRIDE to just use 'override' directly.
[oota-llvm.git] / include / llvm / Support / CommandLine.h
index c0bfbae0370e7d31f393c0abd069739f7c02caea..0267db817a46cc51f4c5595b50218e25d8d55b6a 100644 (file)
@@ -21,8 +21,8 @@
 #define LLVM_SUPPORT_COMMANDLINE_H
 
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/Twine.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/type_traits.h"
 #include <cassert>
@@ -149,8 +149,8 @@ private:
 public:
   OptionCategory(const char *const Name, const char *const Description = 0)
       : Name(Name), Description(Description) { registerCategory(); }
-  const char *getName() { return Name; }
-  const char *getDescription() { return Description; }
+  const char *getName() const { return Name; }
+  const char *getDescription() const { return Description; }
 };
 
 // The general Option Category (used as default category).
@@ -249,6 +249,12 @@ public:
   //
   void addArgument();
 
+  /// Unregisters this option from the CommandLine system.
+  ///
+  /// This option must have been the last option registered.
+  /// For testing purposes only.
+  void removeArgument();
+
   Option *getNextRegisteredOption() const { return NextRegistered; }
 
   // Return the width of the option tag for printing...
@@ -350,6 +356,9 @@ struct cat {
 struct GenericOptionValue {
   virtual ~GenericOptionValue() {}
   virtual bool compare(const GenericOptionValue &V) const = 0;
+
+private:
+  virtual void anchor();
 };
 
 template<class DataType> struct OptionValue;
@@ -1017,8 +1026,8 @@ template<> struct applicator<const char*> {
 };
 
 template<> struct applicator<NumOccurrencesFlag> {
-  static void opt(NumOccurrencesFlag NO, Option &O) {
-    O.setNumOccurrencesFlag(NO);
+  static void opt(NumOccurrencesFlag N, Option &O) {
+    O.setNumOccurrencesFlag(N);
   }
 };
 template<> struct applicator<ValueExpected> {
@@ -1052,7 +1061,7 @@ class opt_storage {
   DataType *Location;   // Where to store the object...
   OptionValue<DataType> Default;
 
-  void check() const {
+  void check_location() const {
     assert(Location != 0 && "cl::location(...) not specified for a command "
            "line option with external storage, "
            "or cl::init specified before cl::location()!!");
@@ -1070,14 +1079,14 @@ public:
 
   template<class T>
   void setValue(const T &V, bool initial = false) {
-    check();
+    check_location();
     *Location = V;
     if (initial)
       Default = V;
   }
 
-  DataType &getValue() { check(); return *Location; }
-  const DataType &getValue() const { check(); return *Location; }
+  DataType &getValue() { check_location(); return *Location; }
+  const DataType &getValue() const { check_location(); return *Location; }
 
   operator DataType() const { return this->getValue(); }
 
@@ -1632,16 +1641,20 @@ public:
 class alias : public Option {
   Option *AliasFor;
   virtual bool handleOccurrence(unsigned pos, StringRef /*ArgName*/,
-                                StringRef Arg) LLVM_OVERRIDE {
+                                StringRef Arg) override {
     return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg);
   }
   // Handle printing stuff...
-  virtual size_t getOptionWidth() const LLVM_OVERRIDE;
-  virtual void printOptionInfo(size_t GlobalWidth) const LLVM_OVERRIDE;
+  virtual size_t getOptionWidth() const override;
+  virtual void printOptionInfo(size_t GlobalWidth) const override;
 
   // Aliases do not need to print their values.
   virtual void printOptionValue(size_t /*GlobalWidth*/,
-                                bool /*Force*/) const LLVM_OVERRIDE {}
+                                bool /*Force*/) const override {}
+
+  virtual ValueExpected getValueExpectedFlagDefault() const override {
+    return AliasFor->getValueExpectedFlag();
+  }
 
   void done() {
     if (!hasArgStr())
@@ -1752,6 +1765,7 @@ void getRegisteredOptions(StringMap<Option*> &Map);
 /// \brief Saves strings in the inheritor's stable storage and returns a stable
 /// raw character pointer.
 class StringSaver {
+  virtual void anchor();
 public:
   virtual const char *SaveString(const char *Str) = 0;
   virtual ~StringSaver() {};  // Pacify -Wnon-virtual-dtor.