Skip to content

Commit

Permalink
[C++11] Add 'override' keyword to virtual methods that override their…
Browse files Browse the repository at this point in the history
… base class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203345 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
topperc committed Mar 8, 2014
1 parent 838cb74 commit c83e68f
Show file tree
Hide file tree
Showing 22 changed files with 207 additions and 204 deletions.
20 changes: 10 additions & 10 deletions include/llvm/IR/PassManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ template <typename IRUnitT, typename AnalysisManagerT, typename PassT>
struct PassModel<IRUnitT, AnalysisManagerT, PassT,
true> : PassConcept<IRUnitT, AnalysisManagerT> {
PassModel(PassT Pass) : Pass(std::move(Pass)) {}
virtual PassModel *clone() { return new PassModel(Pass); }
virtual PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) {
PassModel *clone() override { return new PassModel(Pass); }
PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) override {
return Pass.run(IR, AM);
}
virtual StringRef name() { return PassT::name(); }
StringRef name() override { return PassT::name(); }
PassT Pass;
};

Expand All @@ -219,11 +219,11 @@ template <typename IRUnitT, typename AnalysisManagerT, typename PassT>
struct PassModel<IRUnitT, AnalysisManagerT, PassT,
false> : PassConcept<IRUnitT, AnalysisManagerT> {
PassModel(PassT Pass) : Pass(std::move(Pass)) {}
virtual PassModel *clone() { return new PassModel(Pass); }
virtual PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) {
PassModel *clone() override { return new PassModel(Pass); }
PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) override {
return Pass.run(IR);
}
virtual StringRef name() { return PassT::name(); }
StringRef name() override { return PassT::name(); }
PassT Pass;
};

Expand Down Expand Up @@ -303,12 +303,12 @@ template <typename IRUnitT, typename PassT, typename ResultT>
struct AnalysisResultModel<IRUnitT, PassT, ResultT,
true> : AnalysisResultConcept<IRUnitT> {
AnalysisResultModel(ResultT Result) : Result(std::move(Result)) {}
virtual AnalysisResultModel *clone() {
AnalysisResultModel *clone() override {
return new AnalysisResultModel(Result);
}

/// \brief The model delegates to the \c ResultT method.
virtual bool invalidate(IRUnitT IR, const PreservedAnalyses &PA) {
bool invalidate(IRUnitT IR, const PreservedAnalyses &PA) override {
return Result.invalidate(IR, PA);
}

Expand Down Expand Up @@ -371,7 +371,7 @@ struct AnalysisPassModel<IRUnitT, AnalysisManagerT, PassT,
false> : AnalysisPassConcept<IRUnitT,
AnalysisManagerT> {
AnalysisPassModel(PassT Pass) : Pass(std::move(Pass)) {}
virtual AnalysisPassModel *clone() { return new AnalysisPassModel(Pass); }
AnalysisPassModel *clone() override { return new AnalysisPassModel(Pass); }

// FIXME: Replace PassT::Result with type traits when we use C++11.
typedef AnalysisResultModel<IRUnitT, PassT, typename PassT::Result>
Expand All @@ -380,7 +380,7 @@ struct AnalysisPassModel<IRUnitT, AnalysisManagerT, PassT,
/// \brief The model delegates to the \c PassT::run method.
///
/// The return is wrapped in an \c AnalysisResultModel.
virtual ResultModelT *run(IRUnitT IR, AnalysisManagerT *) {
ResultModelT *run(IRUnitT IR, AnalysisManagerT *) override {
return new ResultModelT(Pass.run(IR));
}

Expand Down
6 changes: 3 additions & 3 deletions tools/bugpoint-passes/TestPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ namespace {
static char ID; // Pass ID, replacement for typeid
CrashOnCalls() : BasicBlockPass(ID) {}
private:
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
}

bool runOnBasicBlock(BasicBlock &BB) {
bool runOnBasicBlock(BasicBlock &BB) override {
for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I)
if (isa<CallInst>(*I))
abort();
Expand All @@ -56,7 +56,7 @@ namespace {
static char ID; // Pass ID, replacement for typeid
DeleteCalls() : BasicBlockPass(ID) {}
private:
bool runOnBasicBlock(BasicBlock &BB) {
bool runOnBasicBlock(BasicBlock &BB) override {
for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I)
if (CallInst *CI = dyn_cast<CallInst>(I)) {
if (!CI->use_empty())
Expand Down
30 changes: 15 additions & 15 deletions tools/bugpoint/CrashDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ namespace llvm {
// running the "Kept" passes fail when run on the output of the "removed"
// passes. If we return true, we update the current module of bugpoint.
//
virtual TestResult doTest(std::vector<std::string> &Removed,
std::vector<std::string> &Kept,
std::string &Error);
TestResult doTest(std::vector<std::string> &Removed,
std::vector<std::string> &Kept,
std::string &Error) override;
};
}

Expand Down Expand Up @@ -110,9 +110,9 @@ namespace {
bool (*testFn)(const BugDriver &, Module *))
: BD(bd), TestFn(testFn) {}

virtual TestResult doTest(std::vector<GlobalVariable*> &Prefix,
std::vector<GlobalVariable*> &Kept,
std::string &Error) {
TestResult doTest(std::vector<GlobalVariable*> &Prefix,
std::vector<GlobalVariable*> &Kept,
std::string &Error) override {
if (!Kept.empty() && TestGlobalVariables(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestGlobalVariables(Prefix))
Expand Down Expand Up @@ -180,9 +180,9 @@ namespace {
bool (*testFn)(const BugDriver &, Module *))
: BD(bd), TestFn(testFn) {}

virtual TestResult doTest(std::vector<Function*> &Prefix,
std::vector<Function*> &Kept,
std::string &Error) {
TestResult doTest(std::vector<Function*> &Prefix,
std::vector<Function*> &Kept,
std::string &Error) override {
if (!Kept.empty() && TestFuncs(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestFuncs(Prefix))
Expand Down Expand Up @@ -253,9 +253,9 @@ namespace {
bool (*testFn)(const BugDriver &, Module *))
: BD(bd), TestFn(testFn) {}

virtual TestResult doTest(std::vector<const BasicBlock*> &Prefix,
std::vector<const BasicBlock*> &Kept,
std::string &Error) {
TestResult doTest(std::vector<const BasicBlock*> &Prefix,
std::vector<const BasicBlock*> &Kept,
std::string &Error) override {
if (!Kept.empty() && TestBlocks(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestBlocks(Prefix))
Expand Down Expand Up @@ -362,9 +362,9 @@ namespace {
bool (*testFn)(const BugDriver &, Module *))
: BD(bd), TestFn(testFn) {}

virtual TestResult doTest(std::vector<const Instruction*> &Prefix,
std::vector<const Instruction*> &Kept,
std::string &Error) {
TestResult doTest(std::vector<const Instruction*> &Prefix,
std::vector<const Instruction*> &Kept,
std::string &Error) override {
if (!Kept.empty() && TestInsts(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestInsts(Prefix))
Expand Down
18 changes: 9 additions & 9 deletions tools/bugpoint/Miscompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ namespace {
public:
ReduceMiscompilingPasses(BugDriver &bd) : BD(bd) {}

virtual TestResult doTest(std::vector<std::string> &Prefix,
std::vector<std::string> &Suffix,
std::string &Error);
TestResult doTest(std::vector<std::string> &Prefix,
std::vector<std::string> &Suffix,
std::string &Error) override;
};
}

Expand Down Expand Up @@ -183,9 +183,9 @@ namespace {
std::string &))
: BD(bd), TestFn(F) {}

virtual TestResult doTest(std::vector<Function*> &Prefix,
std::vector<Function*> &Suffix,
std::string &Error) {
TestResult doTest(std::vector<Function*> &Prefix,
std::vector<Function*> &Suffix,
std::string &Error) override {
if (!Suffix.empty()) {
bool Ret = TestFuncs(Suffix, Error);
if (!Error.empty())
Expand Down Expand Up @@ -468,9 +468,9 @@ namespace {
const std::vector<Function*> &Fns)
: BD(bd), TestFn(F), FunctionsBeingTested(Fns) {}

virtual TestResult doTest(std::vector<BasicBlock*> &Prefix,
std::vector<BasicBlock*> &Suffix,
std::string &Error) {
TestResult doTest(std::vector<BasicBlock*> &Prefix,
std::vector<BasicBlock*> &Suffix,
std::string &Error) override {
if (!Suffix.empty()) {
bool Ret = TestFuncs(Suffix, Error);
if (!Error.empty())
Expand Down
94 changes: 47 additions & 47 deletions tools/bugpoint/ToolRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,16 @@ namespace {
if (Args) { ToolArgs = *Args; }
}

virtual int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
std::string *Error,
const std::vector<std::string> &GCCArgs,
const std::vector<std::string> &SharedLibs =
std::vector<std::string>(),
unsigned Timeout = 0,
unsigned MemoryLimit = 0);
int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
std::string *Error,
const std::vector<std::string> &GCCArgs,
const std::vector<std::string> &SharedLibs =
std::vector<std::string>(),
unsigned Timeout = 0,
unsigned MemoryLimit = 0) override;
};
}

Expand Down Expand Up @@ -294,22 +294,22 @@ namespace {
const std::string &CompilerCmd, std::vector<std::string> CompArgs) :
CompilerCommand(CompilerCmd), CompilerArgs(CompArgs) {}

virtual void compileProgram(const std::string &Bitcode,
std::string *Error,
unsigned Timeout = 0,
unsigned MemoryLimit = 0);

virtual int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
std::string *Error,
const std::vector<std::string> &GCCArgs =
std::vector<std::string>(),
const std::vector<std::string> &SharedLibs =
std::vector<std::string>(),
unsigned Timeout = 0,
unsigned MemoryLimit = 0) {
void compileProgram(const std::string &Bitcode,
std::string *Error,
unsigned Timeout = 0,
unsigned MemoryLimit = 0) override;

int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
std::string *Error,
const std::vector<std::string> &GCCArgs =
std::vector<std::string>(),
const std::vector<std::string> &SharedLibs =
std::vector<std::string>(),
unsigned Timeout = 0,
unsigned MemoryLimit = 0) override {
*Error = "Execution not supported with -compile-custom";
return -1;
}
Expand Down Expand Up @@ -355,16 +355,16 @@ namespace {
const std::string &ExecutionCmd, std::vector<std::string> ExecArgs) :
ExecutionCommand(ExecutionCmd), ExecutorArgs(ExecArgs) {}

virtual int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
std::string *Error,
const std::vector<std::string> &GCCArgs,
const std::vector<std::string> &SharedLibs =
std::vector<std::string>(),
unsigned Timeout = 0,
unsigned MemoryLimit = 0);
int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
std::string *Error,
const std::vector<std::string> &GCCArgs,
const std::vector<std::string> &SharedLibs =
std::vector<std::string>(),
unsigned Timeout = 0,
unsigned MemoryLimit = 0) override;
};
}

Expand Down Expand Up @@ -584,17 +584,17 @@ namespace {
if (Args) { ToolArgs = *Args; }
}

virtual int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
std::string *Error,
const std::vector<std::string> &GCCArgs =
std::vector<std::string>(),
const std::vector<std::string> &SharedLibs =
std::vector<std::string>(),
unsigned Timeout = 0,
unsigned MemoryLimit = 0);
int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
std::string *Error,
const std::vector<std::string> &GCCArgs =
std::vector<std::string>(),
const std::vector<std::string> &SharedLibs =
std::vector<std::string>(),
unsigned Timeout = 0,
unsigned MemoryLimit = 0) override;
};
}

Expand Down
34 changes: 17 additions & 17 deletions tools/bugpoint/ToolRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,29 +168,29 @@ class LLC : public AbstractInterpreter {
/// compileProgram - Compile the specified program from bitcode to executable
/// code. This does not produce any output, it is only used when debugging
/// the code generator. Returns false if the code generator fails.
virtual void compileProgram(const std::string &Bitcode, std::string *Error,
unsigned Timeout = 0, unsigned MemoryLimit = 0);
void compileProgram(const std::string &Bitcode, std::string *Error,
unsigned Timeout = 0, unsigned MemoryLimit = 0) override;

virtual int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
std::string *Error,
const std::vector<std::string> &GCCArgs =
std::vector<std::string>(),
const std::vector<std::string> &SharedLibs =
std::vector<std::string>(),
unsigned Timeout = 0,
unsigned MemoryLimit = 0);
int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
std::string *Error,
const std::vector<std::string> &GCCArgs =
std::vector<std::string>(),
const std::vector<std::string> &SharedLibs =
std::vector<std::string>(),
unsigned Timeout = 0,
unsigned MemoryLimit = 0) override;

/// OutputCode - Compile the specified program from bitcode to code
/// understood by the GCC driver (either C or asm). If the code generator
/// fails, it sets Error, otherwise, this function returns the type of code
/// emitted.
virtual GCC::FileType OutputCode(const std::string &Bitcode,
std::string &OutFile, std::string &Error,
unsigned Timeout = 0,
unsigned MemoryLimit = 0);
GCC::FileType OutputCode(const std::string &Bitcode,
std::string &OutFile, std::string &Error,
unsigned Timeout = 0,
unsigned MemoryLimit = 0) override;
};

} // End llvm namespace
Expand Down
2 changes: 1 addition & 1 deletion tools/bugpoint/bugpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace {
public:
AddToDriver(BugDriver &_D) : FunctionPassManager(0), D(_D) {}

virtual void add(Pass *P) {
void add(Pass *P) override {
const void *ID = P->getPassID();
const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(ID);
D.addPass(PI->getPassArgument());
Expand Down
Loading

0 comments on commit c83e68f

Please sign in to comment.