Skip to content

Commit

Permalink
[C+11] Add 'override' keyword to methods in the support library.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202791 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
topperc committed Mar 4, 2014
1 parent cfb73ab commit 4a655e7
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 137 deletions.
21 changes: 10 additions & 11 deletions include/llvm/ADT/FoldingSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,20 +396,20 @@ template<class T> class FoldingSet : public FoldingSetImpl {
private:
/// GetNodeProfile - Each instantiatation of the FoldingSet needs to provide a
/// way to convert nodes into a unique specifier.
virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const {
void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const override {
T *TN = static_cast<T *>(N);
FoldingSetTrait<T>::Profile(*TN, ID);
}
/// NodeEquals - Instantiations may optionally provide a way to compare a
/// node with a specified ID.
virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash,
FoldingSetNodeID &TempID) const {
bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash,
FoldingSetNodeID &TempID) const override {
T *TN = static_cast<T *>(N);
return FoldingSetTrait<T>::Equals(*TN, ID, IDHash, TempID);
}
/// ComputeNodeHash - Instantiations may optionally provide a way to compute a
/// hash value directly from a node.
virtual unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const {
unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const override {
T *TN = static_cast<T *>(N);
return FoldingSetTrait<T>::ComputeHash(*TN, TempID);
}
Expand Down Expand Up @@ -473,20 +473,19 @@ class ContextualFoldingSet : public FoldingSetImpl {

/// GetNodeProfile - Each instantiatation of the FoldingSet needs to provide a
/// way to convert nodes into a unique specifier.
virtual void GetNodeProfile(FoldingSetImpl::Node *N,
FoldingSetNodeID &ID) const {
void GetNodeProfile(FoldingSetImpl::Node *N,
FoldingSetNodeID &ID) const override {
T *TN = static_cast<T *>(N);
ContextualFoldingSetTrait<T, Ctx>::Profile(*TN, ID, Context);
}
virtual bool NodeEquals(FoldingSetImpl::Node *N,
const FoldingSetNodeID &ID, unsigned IDHash,
FoldingSetNodeID &TempID) const {
bool NodeEquals(FoldingSetImpl::Node *N, const FoldingSetNodeID &ID,
unsigned IDHash, FoldingSetNodeID &TempID) const override {
T *TN = static_cast<T *>(N);
return ContextualFoldingSetTrait<T, Ctx>::Equals(*TN, ID, IDHash, TempID,
Context);
}
virtual unsigned ComputeNodeHash(FoldingSetImpl::Node *N,
FoldingSetNodeID &TempID) const {
unsigned ComputeNodeHash(FoldingSetImpl::Node *N,
FoldingSetNodeID &TempID) const override {
T *TN = static_cast<T *>(N);
return ContextualFoldingSetTrait<T, Ctx>::ComputeHash(*TN, TempID, Context);
}
Expand Down
2 changes: 1 addition & 1 deletion include/llvm/IR/InstrTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TerminatorInst : public Instruction {
virtual BasicBlock *getSuccessorV(unsigned idx) const = 0;
virtual unsigned getNumSuccessorsV() const = 0;
virtual void setSuccessorV(unsigned idx, BasicBlock *B) = 0;
virtual TerminatorInst *clone_impl() const = 0;
TerminatorInst *clone_impl() const override = 0;
public:

/// getNumSuccessors - Return the number of successors that this terminator
Expand Down
108 changes: 57 additions & 51 deletions include/llvm/Support/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ struct OptionValueBase : public GenericOptionValue {

bool compare(const DataType &/*V*/) const { return false; }

virtual bool compare(const GenericOptionValue& /*V*/) const { return false; }
bool compare(const GenericOptionValue& /*V*/) const override {
return false;
}
};

// Simple copy of the option value.
Expand All @@ -404,7 +406,7 @@ class OptionValueCopy : public GenericOptionValue {
return Valid && (Value != V);
}

virtual bool compare(const GenericOptionValue &V) const {
bool compare(const GenericOptionValue &V) const override {
const OptionValueCopy<DataType> &VC =
static_cast< const OptionValueCopy<DataType>& >(V);
if (!VC.hasValue()) return false;
Expand Down Expand Up @@ -450,7 +452,7 @@ struct OptionValue<cl::boolOrDefault> : OptionValueCopy<cl::boolOrDefault> {
return *this;
}
private:
virtual void anchor();
void anchor() override;
};

template<>
Expand All @@ -467,7 +469,7 @@ struct OptionValue<std::string> : OptionValueCopy<std::string> {
return *this;
}
private:
virtual void anchor();
void anchor() override;
};

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -646,14 +648,14 @@ class parser : public generic_parser_base {
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].Name; }
const char *getDescription(unsigned N) const {
unsigned getNumOptions() const override { return unsigned(Values.size()); }
const char *getOption(unsigned N) const override { return Values[N].Name; }
const char *getDescription(unsigned N) const override {
return Values[N].HelpStr;
}

// getOptionValue - Return the value of option name N.
virtual const GenericOptionValue &getOptionValue(unsigned N) const {
const GenericOptionValue &getOptionValue(unsigned N) const override {
return Values[N].V;
}

Expand Down Expand Up @@ -762,13 +764,13 @@ class parser<bool> : public basic_parser<bool> {
}

// getValueName - Do not print =<value> at all.
virtual const char *getValueName() const { return 0; }
const char *getValueName() const override { return 0; }

void printOptionDiff(const Option &O, bool V, OptVal Default,
size_t GlobalWidth) const;

// An out-of-line virtual method to provide a 'home' for this class.
virtual void anchor();
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<bool>);
Expand All @@ -786,13 +788,13 @@ class parser<boolOrDefault> : public basic_parser<boolOrDefault> {
}

// getValueName - Do not print =<value> at all.
virtual const char *getValueName() const { return 0; }
const char *getValueName() const override { return 0; }

void printOptionDiff(const Option &O, boolOrDefault V, OptVal Default,
size_t GlobalWidth) const;

// An out-of-line virtual method to provide a 'home' for this class.
virtual void anchor();
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<boolOrDefault>);
Expand All @@ -807,13 +809,13 @@ class parser<int> : public basic_parser<int> {
bool parse(Option &O, StringRef ArgName, StringRef Arg, int &Val);

// getValueName - Overload in subclass to provide a better default value.
virtual const char *getValueName() const { return "int"; }
const char *getValueName() const override { return "int"; }

void printOptionDiff(const Option &O, int V, OptVal Default,
size_t GlobalWidth) const;

// An out-of-line virtual method to provide a 'home' for this class.
virtual void anchor();
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<int>);
Expand All @@ -829,13 +831,13 @@ class parser<unsigned> : public basic_parser<unsigned> {
bool parse(Option &O, StringRef ArgName, StringRef Arg, unsigned &Val);

// getValueName - Overload in subclass to provide a better default value.
virtual const char *getValueName() const { return "uint"; }
const char *getValueName() const override { return "uint"; }

void printOptionDiff(const Option &O, unsigned V, OptVal Default,
size_t GlobalWidth) const;

// An out-of-line virtual method to provide a 'home' for this class.
virtual void anchor();
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<unsigned>);
Expand All @@ -851,13 +853,13 @@ class parser<unsigned long long> : public basic_parser<unsigned long long> {
unsigned long long &Val);

// getValueName - Overload in subclass to provide a better default value.
virtual const char *getValueName() const { return "uint"; }
const char *getValueName() const override { return "uint"; }

void printOptionDiff(const Option &O, unsigned long long V, OptVal Default,
size_t GlobalWidth) const;

// An out-of-line virtual method to provide a 'home' for this class.
virtual void anchor();
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<unsigned long long>);
Expand All @@ -872,13 +874,13 @@ class parser<double> : public basic_parser<double> {
bool parse(Option &O, StringRef ArgName, StringRef Arg, double &Val);

// getValueName - Overload in subclass to provide a better default value.
virtual const char *getValueName() const { return "number"; }
const char *getValueName() const override { return "number"; }

void printOptionDiff(const Option &O, double V, OptVal Default,
size_t GlobalWidth) const;

// An out-of-line virtual method to provide a 'home' for this class.
virtual void anchor();
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<double>);
Expand All @@ -893,13 +895,13 @@ class parser<float> : public basic_parser<float> {
bool parse(Option &O, StringRef ArgName, StringRef Arg, float &Val);

// getValueName - Overload in subclass to provide a better default value.
virtual const char *getValueName() const { return "number"; }
const char *getValueName() const override { return "number"; }

void printOptionDiff(const Option &O, float V, OptVal Default,
size_t GlobalWidth) const;

// An out-of-line virtual method to provide a 'home' for this class.
virtual void anchor();
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<float>);
Expand All @@ -917,13 +919,13 @@ class parser<std::string> : public basic_parser<std::string> {
}

// getValueName - Overload in subclass to provide a better default value.
virtual const char *getValueName() const { return "string"; }
const char *getValueName() const override { return "string"; }

void printOptionDiff(const Option &O, StringRef V, OptVal Default,
size_t GlobalWidth) const;

// An out-of-line virtual method to provide a 'home' for this class.
virtual void anchor();
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<std::string>);
Expand All @@ -941,13 +943,13 @@ class parser<char> : public basic_parser<char> {
}

// getValueName - Overload in subclass to provide a better default value.
virtual const char *getValueName() const { return "char"; }
const char *getValueName() const override { return "char"; }

void printOptionDiff(const Option &O, char V, OptVal Default,
size_t GlobalWidth) const;

// An out-of-line virtual method to provide a 'home' for this class.
virtual void anchor();
void anchor() override;
};

EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<char>);
Expand Down Expand Up @@ -1157,8 +1159,8 @@ class opt : public Option,
is_class<DataType>::value> {
ParserClass Parser;

virtual bool handleOccurrence(unsigned pos, StringRef ArgName,
StringRef Arg) {
bool handleOccurrence(unsigned pos, StringRef ArgName,
StringRef Arg) override {
typename ParserClass::parser_data_type Val =
typename ParserClass::parser_data_type();
if (Parser.parse(*this, ArgName, Arg, Val))
Expand All @@ -1168,20 +1170,20 @@ class opt : public Option,
return false;
}

virtual enum ValueExpected getValueExpectedFlagDefault() const {
enum ValueExpected getValueExpectedFlagDefault() const override {
return Parser.getValueExpectedFlagDefault();
}
virtual void getExtraOptionNames(SmallVectorImpl<const char*> &OptionNames) {
void getExtraOptionNames(SmallVectorImpl<const char*> &OptionNames) override {
return Parser.getExtraOptionNames(OptionNames);
}

// Forward printing stuff to the parser...
virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);}
virtual void printOptionInfo(size_t GlobalWidth) const {
size_t getOptionWidth() const override {return Parser.getOptionWidth(*this);}
void printOptionInfo(size_t GlobalWidth) const override {
Parser.printOptionInfo(*this, GlobalWidth);
}

virtual void printOptionValue(size_t GlobalWidth, bool Force) const {
void printOptionValue(size_t GlobalWidth, bool Force) const override {
if (Force || this->getDefault().compare(this->getValue())) {
cl::printOptionDiff<ParserClass>(
*this, Parser, this->getValue(), this->getDefault(), GlobalWidth);
Expand Down Expand Up @@ -1328,14 +1330,15 @@ class list : public Option, public list_storage<DataType, Storage> {
std::vector<unsigned> Positions;
ParserClass Parser;

virtual enum ValueExpected getValueExpectedFlagDefault() const {
enum ValueExpected getValueExpectedFlagDefault() const override {
return Parser.getValueExpectedFlagDefault();
}
virtual void getExtraOptionNames(SmallVectorImpl<const char*> &OptionNames) {
void getExtraOptionNames(SmallVectorImpl<const char*> &OptionNames) override {
return Parser.getExtraOptionNames(OptionNames);
}

virtual bool handleOccurrence(unsigned pos, StringRef ArgName, StringRef Arg){
bool handleOccurrence(unsigned pos, StringRef ArgName,
StringRef Arg) override {
typename ParserClass::parser_data_type Val =
typename ParserClass::parser_data_type();
if (Parser.parse(*this, ArgName, Arg, Val))
Expand All @@ -1347,13 +1350,14 @@ class list : public Option, public list_storage<DataType, Storage> {
}

// Forward printing stuff to the parser...
virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);}
virtual void printOptionInfo(size_t GlobalWidth) const {
size_t getOptionWidth() const override {return Parser.getOptionWidth(*this);}
void printOptionInfo(size_t GlobalWidth) const override {
Parser.printOptionInfo(*this, GlobalWidth);
}

// Unimplemented: list options don't currently store their default value.
virtual void printOptionValue(size_t /*GlobalWidth*/, bool /*Force*/) const {}
void printOptionValue(size_t /*GlobalWidth*/,
bool /*Force*/) const override {}

void done() {
addArgument();
Expand Down Expand Up @@ -1530,14 +1534,15 @@ class bits : public Option, public bits_storage<DataType, Storage> {
std::vector<unsigned> Positions;
ParserClass Parser;

virtual enum ValueExpected getValueExpectedFlagDefault() const {
enum ValueExpected getValueExpectedFlagDefault() const override {
return Parser.getValueExpectedFlagDefault();
}
virtual void getExtraOptionNames(SmallVectorImpl<const char*> &OptionNames) {
void getExtraOptionNames(SmallVectorImpl<const char*> &OptionNames) override {
return Parser.getExtraOptionNames(OptionNames);
}

virtual bool handleOccurrence(unsigned pos, StringRef ArgName, StringRef Arg){
bool handleOccurrence(unsigned pos, StringRef ArgName,
StringRef Arg) override {
typename ParserClass::parser_data_type Val =
typename ParserClass::parser_data_type();
if (Parser.parse(*this, ArgName, Arg, Val))
Expand All @@ -1549,13 +1554,14 @@ class bits : public Option, public bits_storage<DataType, Storage> {
}

// Forward printing stuff to the parser...
virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);}
virtual void printOptionInfo(size_t GlobalWidth) const {
size_t getOptionWidth() const override {return Parser.getOptionWidth(*this);}
void printOptionInfo(size_t GlobalWidth) const override {
Parser.printOptionInfo(*this, GlobalWidth);
}

// Unimplemented: bits options don't currently store their default values.
virtual void printOptionValue(size_t /*GlobalWidth*/, bool /*Force*/) const {}
void printOptionValue(size_t /*GlobalWidth*/,
bool /*Force*/) const override {}

void done() {
addArgument();
Expand Down Expand Up @@ -1640,19 +1646,19 @@ class bits : public Option, public bits_storage<DataType, Storage> {

class alias : public Option {
Option *AliasFor;
virtual bool handleOccurrence(unsigned pos, StringRef /*ArgName*/,
bool handleOccurrence(unsigned pos, StringRef /*ArgName*/,
StringRef Arg) override {
return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg);
}
// Handle printing stuff...
virtual size_t getOptionWidth() const override;
virtual void printOptionInfo(size_t GlobalWidth) const override;
size_t getOptionWidth() const override;
void printOptionInfo(size_t GlobalWidth) const override;

// Aliases do not need to print their values.
virtual void printOptionValue(size_t /*GlobalWidth*/,
bool /*Force*/) const override {}
void printOptionValue(size_t /*GlobalWidth*/,
bool /*Force*/) const override {}

virtual ValueExpected getValueExpectedFlagDefault() const override {
ValueExpected getValueExpectedFlagDefault() const override {
return AliasFor->getValueExpectedFlag();
}

Expand Down
Loading

0 comments on commit 4a655e7

Please sign in to comment.