llvm.org GIT mirror llvm / c83e68f
[C++11] Add 'override' keyword to virtual methods that override their base class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203345 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 5 years ago
22 changed file(s) with 215 addition(s) and 212 deletion(s). Raw diff Collapse all Expand all
204204 struct PassModel
205205 true> : PassConcept {
206206 PassModel(PassT Pass) : Pass(std::move(Pass)) {}
207 virtual PassModel *clone() { return new PassModel(Pass); }
208 virtual PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) {
207 PassModel *clone() override { return new PassModel(Pass); }
208 PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) override {
209209 return Pass.run(IR, AM);
210210 }
211 virtual StringRef name() { return PassT::name(); }
211 StringRef name() override { return PassT::name(); }
212212 PassT Pass;
213213 };
214214
218218 struct PassModel
219219 false> : PassConcept {
220220 PassModel(PassT Pass) : Pass(std::move(Pass)) {}
221 virtual PassModel *clone() { return new PassModel(Pass); }
222 virtual PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) {
221 PassModel *clone() override { return new PassModel(Pass); }
222 PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) override {
223223 return Pass.run(IR);
224224 }
225 virtual StringRef name() { return PassT::name(); }
225 StringRef name() override { return PassT::name(); }
226226 PassT Pass;
227227 };
228228
302302 struct AnalysisResultModel
303303 true> : AnalysisResultConcept {
304304 AnalysisResultModel(ResultT Result) : Result(std::move(Result)) {}
305 virtual AnalysisResultModel *clone() {
305 AnalysisResultModel *clone() override {
306306 return new AnalysisResultModel(Result);
307307 }
308308
309309 /// \brief The model delegates to the \c ResultT method.
310 virtual bool invalidate(IRUnitT IR, const PreservedAnalyses &PA) {
310 bool invalidate(IRUnitT IR, const PreservedAnalyses &PA) override {
311311 return Result.invalidate(IR, PA);
312312 }
313313
370370 false> : AnalysisPassConcept
371371 AnalysisManagerT> {
372372 AnalysisPassModel(PassT Pass) : Pass(std::move(Pass)) {}
373 virtual AnalysisPassModel *clone() { return new AnalysisPassModel(Pass); }
373 AnalysisPassModel *clone() override { return new AnalysisPassModel(Pass); }
374374
375375 // FIXME: Replace PassT::Result with type traits when we use C++11.
376376 typedef AnalysisResultModel
379379 /// \brief The model delegates to the \c PassT::run method.
380380 ///
381381 /// The return is wrapped in an \c AnalysisResultModel.
382 virtual ResultModelT *run(IRUnitT IR, AnalysisManagerT *) {
382 ResultModelT *run(IRUnitT IR, AnalysisManagerT *) override {
383383 return new ResultModelT(Pass.run(IR));
384384 }
385385
5151 // running the "Kept" passes fail when run on the output of the "removed"
5252 // passes. If we return true, we update the current module of bugpoint.
5353 //
54 virtual TestResult doTest(std::vector &Removed,
55 std::vector &Kept,
56 std::string &Error);
54 TestResult doTest(std::vector &Removed,
55 std::vector &Kept,
56 std::string &Error) override;
5757 };
5858 }
5959
109109 bool (*testFn)(const BugDriver &, Module *))
110110 : BD(bd), TestFn(testFn) {}
111111
112 virtual TestResult doTest(std::vector &Prefix,
113 std::vector &Kept,
114 std::string &Error) {
112 TestResult doTest(std::vector &Prefix,
113 std::vector &Kept,
114 std::string &Error) override {
115115 if (!Kept.empty() && TestGlobalVariables(Kept))
116116 return KeepSuffix;
117117 if (!Prefix.empty() && TestGlobalVariables(Prefix))
179179 bool (*testFn)(const BugDriver &, Module *))
180180 : BD(bd), TestFn(testFn) {}
181181
182 virtual TestResult doTest(std::vector &Prefix,
183 std::vector &Kept,
184 std::string &Error) {
182 TestResult doTest(std::vector &Prefix,
183 std::vector &Kept,
184 std::string &Error) override {
185185 if (!Kept.empty() && TestFuncs(Kept))
186186 return KeepSuffix;
187187 if (!Prefix.empty() && TestFuncs(Prefix))
252252 bool (*testFn)(const BugDriver &, Module *))
253253 : BD(bd), TestFn(testFn) {}
254254
255 virtual TestResult doTest(std::vector &Prefix,
256 std::vector &Kept,
257 std::string &Error) {
255 TestResult doTest(std::vector &Prefix,
256 std::vector &Kept,
257 std::string &Error) override {
258258 if (!Kept.empty() && TestBlocks(Kept))
259259 return KeepSuffix;
260260 if (!Prefix.empty() && TestBlocks(Prefix))
361361 bool (*testFn)(const BugDriver &, Module *))
362362 : BD(bd), TestFn(testFn) {}
363363
364 virtual TestResult doTest(std::vector &Prefix,
365 std::vector &Kept,
366 std::string &Error) {
364 TestResult doTest(std::vector &Prefix,
365 std::vector &Kept,
366 std::string &Error) override {
367367 if (!Kept.empty() && TestInsts(Kept))
368368 return KeepSuffix;
369369 if (!Prefix.empty() && TestInsts(Prefix))
4747 public:
4848 ReduceMiscompilingPasses(BugDriver &bd) : BD(bd) {}
4949
50 virtual TestResult doTest(std::vector &Prefix,
51 std::vector &Suffix,
52 std::string &Error);
50 TestResult doTest(std::vector &Prefix,
51 std::vector &Suffix,
52 std::string &Error) override;
5353 };
5454 }
5555
182182 std::string &))
183183 : BD(bd), TestFn(F) {}
184184
185 virtual TestResult doTest(std::vector &Prefix,
186 std::vector &Suffix,
187 std::string &Error) {
185 TestResult doTest(std::vector &Prefix,
186 std::vector &Suffix,
187 std::string &Error) override {
188188 if (!Suffix.empty()) {
189189 bool Ret = TestFuncs(Suffix, Error);
190190 if (!Error.empty())
467467 const std::vector &Fns)
468468 : BD(bd), TestFn(F), FunctionsBeingTested(Fns) {}
469469
470 virtual TestResult doTest(std::vector &Prefix,
471 std::vector &Suffix,
472 std::string &Error) {
470 TestResult doTest(std::vector &Prefix,
471 std::vector &Suffix,
472 std::string &Error) override {
473473 if (!Suffix.empty()) {
474474 bool Ret = TestFuncs(Suffix, Error);
475475 if (!Error.empty())
177177 if (Args) { ToolArgs = *Args; }
178178 }
179179
180 virtual int ExecuteProgram(const std::string &Bitcode,
181 const std::vector &Args,
182 const std::string &InputFile,
183 const std::string &OutputFile,
184 std::string *Error,
185 const std::vector &GCCArgs,
186 const std::vector &SharedLibs =
187 std::vector(),
188 unsigned Timeout = 0,
189 unsigned MemoryLimit = 0);
180 int ExecuteProgram(const std::string &Bitcode,
181 const std::vector &Args,
182 const std::string &InputFile,
183 const std::string &OutputFile,
184 std::string *Error,
185 const std::vector &GCCArgs,
186 const std::vector &SharedLibs =
187 std::vector(),
188 unsigned Timeout = 0,
189 unsigned MemoryLimit = 0) override;
190190 };
191191 }
192192
293293 const std::string &CompilerCmd, std::vector CompArgs) :
294294 CompilerCommand(CompilerCmd), CompilerArgs(CompArgs) {}
295295
296 virtual void compileProgram(const std::string &Bitcode,
297 std::string *Error,
298 unsigned Timeout = 0,
299 unsigned MemoryLimit = 0);
300
301 virtual int ExecuteProgram(const std::string &Bitcode,
302 const std::vector &Args,
303 const std::string &InputFile,
304 const std::string &OutputFile,
305 std::string *Error,
306 const std::vector &GCCArgs =
307 std::vector(),
308 const std::vector &SharedLibs =
309 std::vector(),
310 unsigned Timeout = 0,
311 unsigned MemoryLimit = 0) {
296 void compileProgram(const std::string &Bitcode,
297 std::string *Error,
298 unsigned Timeout = 0,
299 unsigned MemoryLimit = 0) override;
300
301 int ExecuteProgram(const std::string &Bitcode,
302 const std::vector &Args,
303 const std::string &InputFile,
304 const std::string &OutputFile,
305 std::string *Error,
306 const std::vector &GCCArgs =
307 std::vector(),
308 const std::vector &SharedLibs =
309 std::vector(),
310 unsigned Timeout = 0,
311 unsigned MemoryLimit = 0) override {
312312 *Error = "Execution not supported with -compile-custom";
313313 return -1;
314314 }
354354 const std::string &ExecutionCmd, std::vector ExecArgs) :
355355 ExecutionCommand(ExecutionCmd), ExecutorArgs(ExecArgs) {}
356356
357 virtual int ExecuteProgram(const std::string &Bitcode,
358 const std::vector &Args,
359 const std::string &InputFile,
360 const std::string &OutputFile,
361 std::string *Error,
362 const std::vector &GCCArgs,
363 const std::vector &SharedLibs =
364 std::vector(),
365 unsigned Timeout = 0,
366 unsigned MemoryLimit = 0);
357 int ExecuteProgram(const std::string &Bitcode,
358 const std::vector &Args,
359 const std::string &InputFile,
360 const std::string &OutputFile,
361 std::string *Error,
362 const std::vector &GCCArgs,
363 const std::vector &SharedLibs =
364 std::vector(),
365 unsigned Timeout = 0,
366 unsigned MemoryLimit = 0) override;
367367 };
368368 }
369369
583583 if (Args) { ToolArgs = *Args; }
584584 }
585585
586 virtual int ExecuteProgram(const std::string &Bitcode,
587 const std::vector &Args,
588 const std::string &InputFile,
589 const std::string &OutputFile,
590 std::string *Error,
591 const std::vector &GCCArgs =
592 std::vector(),
593 const std::vector &SharedLibs =
594 std::vector(),
595 unsigned Timeout = 0,
596 unsigned MemoryLimit = 0);
586 int ExecuteProgram(const std::string &Bitcode,
587 const std::vector &Args,
588 const std::string &InputFile,
589 const std::string &OutputFile,
590 std::string *Error,
591 const std::vector &GCCArgs =
592 std::vector(),
593 const std::vector &SharedLibs =
594 std::vector(),
595 unsigned Timeout = 0,
596 unsigned MemoryLimit = 0) override;
597597 };
598598 }
599599
167167 /// compileProgram - Compile the specified program from bitcode to executable
168168 /// code. This does not produce any output, it is only used when debugging
169169 /// the code generator. Returns false if the code generator fails.
170 virtual void compileProgram(const std::string &Bitcode, std::string *Error,
171 unsigned Timeout = 0, unsigned MemoryLimit = 0);
170 void compileProgram(const std::string &Bitcode, std::string *Error,
171 unsigned Timeout = 0, unsigned MemoryLimit = 0) override;
172172
173 virtual int ExecuteProgram(const std::string &Bitcode,
174 const std::vector &Args,
175 const std::string &InputFile,
176 const std::string &OutputFile,
177 std::string *Error,
178 const std::vector &GCCArgs =
179 std::vector(),
180 const std::vector &SharedLibs =
181 std::vector(),
182 unsigned Timeout = 0,
183 unsigned MemoryLimit = 0);
173 int ExecuteProgram(const std::string &Bitcode,
174 const std::vector &Args,
175 const std::string &InputFile,
176 const std::string &OutputFile,
177 std::string *Error,
178 const std::vector &GCCArgs =
179 std::vector(),
180 const std::vector &SharedLibs =
181 std::vector(),
182 unsigned Timeout = 0,
183 unsigned MemoryLimit = 0) override;
184184
185185 /// OutputCode - Compile the specified program from bitcode to code
186186 /// understood by the GCC driver (either C or asm). If the code generator
187187 /// fails, it sets Error, otherwise, this function returns the type of code
188188 /// emitted.
189 virtual GCC::FileType OutputCode(const std::string &Bitcode,
190 std::string &OutFile, std::string &Error,
191 unsigned Timeout = 0,
192 unsigned MemoryLimit = 0);
189 GCC::FileType OutputCode(const std::string &Bitcode,
190 std::string &OutFile, std::string &Error,
191 unsigned Timeout = 0,
192 unsigned MemoryLimit = 0) override;
193193 };
194194
195195 } // End llvm namespace
100100 public:
101101 AddToDriver(BugDriver &_D) : FunctionPassManager(0), D(_D) {}
102102
103 virtual void add(Pass *P) {
103 void add(Pass *P) override {
104104 const void *ID = P->getPassID();
105105 const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(ID);
106106 D.addPass(PI->getPassArgument());
2828 static char ID; // Pass ID, replacement for typeid
2929 CrashOnCalls() : BasicBlockPass(ID) {}
3030 private:
31 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
31 void getAnalysisUsage(AnalysisUsage &AU) const override {
3232 AU.setPreservesAll();
3333 }
3434
35 bool runOnBasicBlock(BasicBlock &BB) {
35 bool runOnBasicBlock(BasicBlock &BB) override {
3636 for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I)
3737 if (isa(*I))
3838 abort();
5555 static char ID; // Pass ID, replacement for typeid
5656 DeleteCalls() : BasicBlockPass(ID) {}
5757 private:
58 bool runOnBasicBlock(BasicBlock &BB) {
58 bool runOnBasicBlock(BasicBlock &BB) override {
5959 for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I)
6060 if (CallInst *CI = dyn_cast(I)) {
6161 if (!CI->use_empty())
6666 virtual ~RemoteMemoryManager();
6767
6868 uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
69 unsigned SectionID, StringRef SectionName);
69 unsigned SectionID,
70 StringRef SectionName) override;
7071
7172 uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
7273 unsigned SectionID, StringRef SectionName,
73 bool IsReadOnly);
74 bool IsReadOnly) override;
7475
7576 // For now, remote symbol resolution is not support in lli. The MCJIT
7677 // interface does support this, but clients must provide their own
7778 // mechanism for finding remote symbol addresses. MCJIT will resolve
7879 // symbols from Modules it contains.
79 uint64_t getSymbolAddress(const std::string &Name) { return 0; }
80 uint64_t getSymbolAddress(const std::string &Name) override { return 0; }
8081
81 void notifyObjectLoaded(ExecutionEngine *EE, const ObjectImage *Obj);
82 void notifyObjectLoaded(ExecutionEngine *EE, const ObjectImage *Obj) override;
8283
83 bool finalizeMemory(std::string *ErrMsg);
84 bool finalizeMemory(std::string *ErrMsg) override;
8485
8586 // For now, remote EH frame registration isn't supported. Remote symbol
8687 // resolution is a prerequisite to supporting remote EH frame registration.
87 void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {}
88 void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {}
88 void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr,
89 size_t Size) override {}
90 void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr,
91 size_t Size) override {}
8992
9093 // This is a non-interface function used by lli
9194 void setRemoteTarget(RemoteTarget *T) { Target = T; }
9295
9396 // The following obsolete JITMemoryManager calls are stubbed out for
9497 // this model.
95 void setMemoryWritable();
96 void setMemoryExecutable();
97 void setPoisonMemory(bool poison);
98 void AllocateGOT();
99 uint8_t *getGOTBase() const;
100 uint8_t *startFunctionBody(const Function *F, uintptr_t &ActualSize);
98 void setMemoryWritable() override;
99 void setMemoryExecutable() override;
100 void setPoisonMemory(bool poison) override;
101 void AllocateGOT() override;
102 uint8_t *getGOTBase() const override;
103 uint8_t *startFunctionBody(const Function *F, uintptr_t &ActualSize) override;
101104 uint8_t *allocateStub(const GlobalValue* F, unsigned StubSize,
102 unsigned Alignment);
105 unsigned Alignment) override;
103106 void endFunctionBody(const Function *F, uint8_t *FunctionStart,
104 uint8_t *FunctionEnd);
105 uint8_t *allocateSpace(intptr_t Size, unsigned Alignment);
106 uint8_t *allocateGlobal(uintptr_t Size, unsigned Alignment);
107 void deallocateFunctionBody(void *Body);
107 uint8_t *FunctionEnd) override;
108 uint8_t *allocateSpace(intptr_t Size, unsigned Alignment) override;
109 uint8_t *allocateGlobal(uintptr_t Size, unsigned Alignment) override;
110 void deallocateFunctionBody(void *Body) override;
108111 };
109112
110113 } // end namespace llvm
4545 ///
4646 /// @returns True on success. On failure, ErrorMsg is updated with
4747 /// descriptive text of the encountered error.
48 virtual bool allocateSpace(size_t Size,
49 unsigned Alignment,
50 uint64_t &Address);
48 bool allocateSpace(size_t Size, unsigned Alignment,
49 uint64_t &Address) override;
5150
5251 /// Load data into the target address space.
5352 ///
5756 ///
5857 /// @returns True on success. On failure, ErrorMsg is updated with
5958 /// descriptive text of the encountered error.
60 virtual bool loadData(uint64_t Address, const void *Data, size_t Size);
59 bool loadData(uint64_t Address, const void *Data, size_t Size) override;
6160
6261 /// Load code into the target address space and prepare it for execution.
6362 ///
6766 ///
6867 /// @returns True on success. On failure, ErrorMsg is updated with
6968 /// descriptive text of the encountered error.
70 virtual bool loadCode(uint64_t Address, const void *Data, size_t Size);
69 bool loadCode(uint64_t Address, const void *Data, size_t Size) override;
7170
7271 /// Execute code in the target process. The called function is required
7372 /// to be of signature int "(*)(void)".
7877 ///
7978 /// @returns True on success. On failure, ErrorMsg is updated with
8079 /// descriptive text of the encountered error.
81 virtual bool executeCode(uint64_t Address, int &RetVal);
80 bool executeCode(uint64_t Address, int &RetVal) override;
8281
8382 /// Minimum alignment for memory permissions. Used to separate code and
8483 /// data regions to make sure data doesn't get marked as code or vice
8584 /// versa.
8685 ///
8786 /// @returns Page alignment return value. Default of 4k.
88 virtual unsigned getPageAlignment() { return 4096; }
87 unsigned getPageAlignment() override { return 4096; }
8988
90 virtual bool create() {
89 bool create() override {
9190 RPC.ChildName = ChildName;
9291 if (!RPC.createServer())
9392 return true;
103102 }
104103
105104 /// Terminate the remote process.
106 virtual void stop();
105 void stop() override;
107106
108107 RemoteTargetExternal(std::string &Name) : RemoteTarget(), ChildName(Name) {}
109108 virtual ~RemoteTargetExternal() {}
261261 }
262262 virtual ~LLIObjectCache() {}
263263
264 virtual void notifyObjectCompiled(const Module *M, const MemoryBuffer *Obj) {
264 void notifyObjectCompiled(const Module *M, const MemoryBuffer *Obj) override {
265265 const std::string ModuleID = M->getModuleIdentifier();
266266 std::string CacheName;
267267 if (!getCacheFilename(ModuleID, CacheName))
277277 outfile.close();
278278 }
279279
280 virtual MemoryBuffer* getObject(const Module* M) {
280 MemoryBuffer* getObject(const Module* M) override {
281281 const std::string ModuleID = M->getModuleIdentifier();
282282 std::string CacheName;
283283 if (!getCacheFilename(ModuleID, CacheName))
7878 : out(errs()), Differences(false), Indent(0) {}
7979
8080 bool hadDifferences() const;
81 void enterContext(Value *L, Value *R);
82 void exitContext();
83 void log(StringRef text);
84 void logf(const LogBuilder &Log);
85 void logd(const DiffLogBuilder &Log);
81 void enterContext(Value *L, Value *R) override;
82 void exitContext() override;
83 void log(StringRef text) override;
84 void logf(const LogBuilder &Log) override;
85 void logd(const DiffLogBuilder &Log) override;
8686 };
8787 }
8888
6565 class CommentWriter : public AssemblyAnnotationWriter {
6666 public:
6767 void emitFunctionAnnot(const Function *F,
68 formatted_raw_ostream &OS) {
68 formatted_raw_ostream &OS) override {
6969 OS << "; [#uses=" << F->getNumUses() << ']'; // Output # uses
7070 OS << '\n';
7171 }
72 void printInfoComment(const Value &V, formatted_raw_ostream &OS) {
72 void printInfoComment(const Value &V, formatted_raw_ostream &OS) override {
7373 bool Padded = false;
7474 if (!V.getType()->isVoidTy()) {
7575 OS.PadToColumn(50);
3434 public:
3535 VectorMemoryObject(const ByteArrayTy &bytes) : Bytes(bytes) {}
3636
37 uint64_t getBase() const { return 0; }
38 uint64_t getExtent() const { return Bytes.size(); }
39
40 int readByte(uint64_t Addr, uint8_t *Byte) const {
37 uint64_t getBase() const override { return 0; }
38 uint64_t getExtent() const override { return Bytes.size(); }
39
40 int readByte(uint64_t Addr, uint8_t *Byte) const override {
4141 if (Addr >= getExtent())
4242 return -1;
4343 *Byte = Bytes[Addr].first;
4141 ELFDumper(const ELFFile *Obj, StreamWriter &Writer)
4242 : ObjDumper(Writer), Obj(Obj) {}
4343
44 virtual void printFileHeaders() override;
45 virtual void printSections() override;
46 virtual void printRelocations() override;
47 virtual void printSymbols() override;
48 virtual void printDynamicSymbols() override;
49 virtual void printUnwindInfo() override;
50
51 virtual void printDynamicTable() override;
52 virtual void printNeededLibraries() override;
53 virtual void printProgramHeaders() override;
54
55 virtual void printAttributes() override;
44 void printFileHeaders() override;
45 void printSections() override;
46 void printRelocations() override;
47 void printSymbols() override;
48 void printDynamicSymbols() override;
49 void printUnwindInfo() override;
50
51 void printDynamicTable() override;
52 void printNeededLibraries() override;
53 void printProgramHeaders() override;
54
55 void printAttributes() override;
5656
5757 private:
5858 typedef ELFFile ELFO;
1818 namespace {
1919 class _readobj_error_category : public _do_message {
2020 public:
21 virtual const char* name() const;
22 virtual std::string message(int ev) const;
23 virtual error_condition default_error_condition(int ev) const;
21 const char* name() const override;
22 std::string message(int ev) const override;
23 error_condition default_error_condition(int ev) const override;
2424 };
2525 } // namespace
2626
6060 SmallVector DataMemory;
6161
6262 uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
63 unsigned SectionID, StringRef SectionName);
63 unsigned SectionID,
64 StringRef SectionName) override;
6465 uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
6566 unsigned SectionID, StringRef SectionName,
66 bool IsReadOnly);
67
68 virtual void *getPointerToNamedFunction(const std::string &Name,
69 bool AbortOnFailure = true) {
67 bool IsReadOnly) override;
68
69 void *getPointerToNamedFunction(const std::string &Name,
70 bool AbortOnFailure = true) override {
7071 return 0;
7172 }
7273
73 bool finalizeMemory(std::string *ErrMsg) { return false; }
74 bool finalizeMemory(std::string *ErrMsg) override { return false; }
7475
7576 // Invalidate instruction cache for sections with execute permissions.
7677 // Some platforms with separate data cache and instruction cache require
287287
288288 struct LoadModifier: public Modifier {
289289 LoadModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {}
290 virtual void Act() {
290 void Act() override {
291291 // Try to use predefined pointers. If non-exist, use undef pointer value;
292292 Value *Ptr = getRandomPointerValue();
293293 Value *V = new LoadInst(Ptr, "L", BB->getTerminator());
297297
298298 struct StoreModifier: public Modifier {
299299 StoreModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {}
300 virtual void Act() {
300 void Act() override {
301301 // Try to use predefined pointers. If non-exist, use undef pointer value;
302302 Value *Ptr = getRandomPointerValue();
303303 Type *Tp = Ptr->getType();
316316 struct BinModifier: public Modifier {
317317 BinModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {}
318318
319 virtual void Act() {
319 void Act() override {
320320 Value *Val0 = getRandomVal();
321321 Value *Val1 = getRandomValue(Val0->getType());
322322
359359 /// Generate constant values.
360360 struct ConstModifier: public Modifier {
361361 ConstModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {}
362 virtual void Act() {
362 void Act() override {
363363 Type *Ty = pickType();
364364
365365 if (Ty->isVectorTy()) {
406406 struct AllocaModifier: public Modifier {
407407 AllocaModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R){}
408408
409 virtual void Act() {
409 void Act() override {
410410 Type *Tp = pickType();
411411 PT->push_back(new AllocaInst(Tp, "A", BB->getFirstNonPHI()));
412412 }
416416 ExtractElementModifier(BasicBlock *BB, PieceTable *PT, Random *R):
417417 Modifier(BB, PT, R) {}
418418
419 virtual void Act() {
419 void Act() override {
420420 Value *Val0 = getRandomVectorValue();
421421 Value *V = ExtractElementInst::Create(Val0,
422422 ConstantInt::get(Type::getInt32Ty(BB->getContext()),
428428
429429 struct ShuffModifier: public Modifier {
430430 ShuffModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {}
431 virtual void Act() {
431 void Act() override {
432432
433433 Value *Val0 = getRandomVectorValue();
434434 Value *Val1 = getRandomValue(Val0->getType());
457457 InsertElementModifier(BasicBlock *BB, PieceTable *PT, Random *R):
458458 Modifier(BB, PT, R) {}
459459
460 virtual void Act() {
460 void Act() override {
461461 Value *Val0 = getRandomVectorValue();
462462 Value *Val1 = getRandomValue(Val0->getType()->getScalarType());
463463
472472
473473 struct CastModifier: public Modifier {
474474 CastModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {}
475 virtual void Act() {
475 void Act() override {
476476
477477 Value *V = getRandomVal();
478478 Type *VTy = V->getType();
559559 SelectModifier(BasicBlock *BB, PieceTable *PT, Random *R):
560560 Modifier(BB, PT, R) {}
561561
562 virtual void Act() {
562 void Act() override {
563563 // Try a bunch of different select configuration until a valid one is found.
564564 Value *Val0 = getRandomVal();
565565 Value *Val1 = getRandomValue(Val0->getType());
582582
583583 struct CmpModifier: public Modifier {
584584 CmpModifier(BasicBlock *BB, PieceTable *PT, Random *R):Modifier(BB, PT, R) {}
585 virtual void Act() {
585 void Act() override {
586586
587587 Value *Val0 = getRandomVal();
588588 Value *Val1 = getRandomValue(Val0->getType());
3131 struct ExternalFunctionsPassedConstants : public ModulePass {
3232 static char ID; // Pass ID, replacement for typeid
3333 ExternalFunctionsPassedConstants() : ModulePass(ID) {}
34 virtual bool runOnModule(Module &M) {
34 bool runOnModule(Module &M) override {
3535 for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
3636 if (!I->isDeclaration()) continue;
3737
6161 return false;
6262 }
6363
64 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
64 void getAnalysisUsage(AnalysisUsage &AU) const override {
6565 AU.setPreservesAll();
6666 }
6767 };
7777 static char ID; // Pass ID, replacement for typeid
7878 CallGraphPrinter() : ModulePass(ID) {}
7979
80 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
80 void getAnalysisUsage(AnalysisUsage &AU) const override {
8181 AU.setPreservesAll();
8282 AU.addRequiredTransitive();
8383 }
84 virtual bool runOnModule(Module &M) {
84 bool runOnModule(Module &M) override {
8585 getAnalysis().print(errs(), &M);
8686 return false;
8787 }
4444 }
4545 }
4646
47 virtual bool runOnModule(Module &M) {
47 bool runOnModule(Module &M) override {
4848 TypeIdentifierMap.clear();
4949 NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu");
5050 if (CU_Nodes)
6868 return false;
6969 }
7070
71 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
71 void getAnalysisUsage(AnalysisUsage &AU) const override {
7272 AU.setPreservesAll();
7373 }
7474 };
2828 static char ID; // Pass identification, replacement for typeid
2929 DomInfoPrinter() : FunctionPass(ID) {}
3030
31 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
31 void getAnalysisUsage(AnalysisUsage &AU) const override {
3232 AU.setPreservesAll();
3333 AU.addRequired();
3434 }
3535
36 virtual bool runOnFunction(Function &F) {
36 bool runOnFunction(Function &F) override {
3737 getAnalysis().dump();
3838 return false;
3939 }
3535 PassName = "FunctionPass Printer: " + PassToPrintName;
3636 }
3737
38 virtual bool runOnFunction(Function &F) {
38 bool runOnFunction(Function &F) override {
3939 if (!QuietPass)
4040 Out << "Printing analysis '" << PassToPrint->getPassName()
4141 << "' for function '" << F.getName() << "':\n";
4545 return false;
4646 }
4747
48 virtual const char *getPassName() const { return PassName.c_str(); }
49
50 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
48 const char *getPassName() const override { return PassName.c_str(); }
49
50 void getAnalysisUsage(AnalysisUsage &AU) const override {
5151 AU.addRequiredID(PassToPrint->getTypeInfo());
5252 AU.setPreservesAll();
5353 }
6868 PassName = "CallGraphSCCPass Printer: " + PassToPrintName;
6969 }
7070
71 virtual bool runOnSCC(CallGraphSCC &SCC) {
71 bool runOnSCC(CallGraphSCC &SCC) override {
7272 if (!QuietPass)
7373 Out << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
7474
8282 return false;
8383 }
8484
85 virtual const char *getPassName() const { return PassName.c_str(); }
86
87 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
85 const char *getPassName() const override { return PassName.c_str(); }
86
87 void getAnalysisUsage(AnalysisUsage &AU) const override {
8888 AU.addRequiredID(PassToPrint->getTypeInfo());
8989 AU.setPreservesAll();
9090 }
105105 PassName = "ModulePass Printer: " + PassToPrintName;
106106 }
107107
108 virtual bool runOnModule(Module &M) {
108 bool runOnModule(Module &M) override {
109109 if (!QuietPass)
110110 Out << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
111111
114114 return false;
115115 }
116116
117 virtual const char *getPassName() const { return PassName.c_str(); }
118
119 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
117 const char *getPassName() const override { return PassName.c_str(); }
118
119 void getAnalysisUsage(AnalysisUsage &AU) const override {
120120 AU.addRequiredID(PassToPrint->getTypeInfo());
121121 AU.setPreservesAll();
122122 }
137137 PassName = "LoopPass Printer: " + PassToPrintName;
138138 }
139139
140 virtual bool runOnLoop(Loop *L, LPPassManager &LPM) {
140 bool runOnLoop(Loop *L, LPPassManager &LPM) override {
141141 if (!QuietPass)
142142 Out << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
143143
147147 return false;
148148 }
149149
150 virtual const char *getPassName() const { return PassName.c_str(); }
151
152 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
150 const char *getPassName() const override { return PassName.c_str(); }
151
152 void getAnalysisUsage(AnalysisUsage &AU) const override {
153153 AU.addRequiredID(PassToPrint->getTypeInfo());
154154 AU.setPreservesAll();
155155 }
170170 PassName = "RegionPass Printer: " + PassToPrintName;
171171 }
172172
173 virtual bool runOnRegion(Region *R, RGPassManager &RGM) {
173 bool runOnRegion(Region *R, RGPassManager &RGM) override {
174174 if (!QuietPass) {
175175 Out << "Printing analysis '" << PassToPrint->getPassName() << "' for "
176176 << "region: '" << R->getNameStr() << "' in function '"
182182 return false;
183183 }
184184
185 virtual const char *getPassName() const { return PassName.c_str(); }
186
187 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
185 const char *getPassName() const override { return PassName.c_str(); }
186
187 void getAnalysisUsage(AnalysisUsage &AU) const override {
188188 AU.addRequiredID(PassToPrint->getTypeInfo());
189189 AU.setPreservesAll();
190190 }
205205 PassName = "BasicBlockPass Printer: " + PassToPrintName;
206206 }
207207
208 virtual bool runOnBasicBlock(BasicBlock &BB) {
208 bool runOnBasicBlock(BasicBlock &BB) override {
209209 if (!QuietPass)
210210 Out << "Printing Analysis info for BasicBlock '" << BB.getName()
211211 << "': Pass " << PassToPrint->getPassName() << ":\n";
216216 return false;
217217 }
218218
219 virtual const char *getPassName() const { return PassName.c_str(); }
220
221 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
219 const char *getPassName() const override { return PassName.c_str(); }
220
221 void getAnalysisUsage(AnalysisUsage &AU) const override {
222222 AU.addRequiredID(PassToPrint->getTypeInfo());
223223 AU.setPreservesAll();
224224 }
3636 struct CFGSCC : public FunctionPass {
3737 static char ID; // Pass identification, replacement for typeid
3838 CFGSCC() : FunctionPass(ID) {}
39 bool runOnFunction(Function& func);
39 bool runOnFunction(Function& func) override;
4040
41 void print(raw_ostream &O, const Module* = 0) const { }
41 void print(raw_ostream &O, const Module* = 0) const override { }
4242
43 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
43 void getAnalysisUsage(AnalysisUsage &AU) const override {
4444 AU.setPreservesAll();
4545 }
4646 };
5050 CallGraphSCC() : ModulePass(ID) {}
5151
5252 // run - Print out SCCs in the call graph for the specified module.
53 bool runOnModule(Module &M);
53 bool runOnModule(Module &M) override;
5454
55 void print(raw_ostream &O, const Module* = 0) const { }
55 void print(raw_ostream &O, const Module* = 0) const override { }
5656
5757 // getAnalysisUsage - This pass requires the CallGraph.
58 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
58 void getAnalysisUsage(AnalysisUsage &AU) const override {
5959 AU.setPreservesAll();
6060 AU.addRequired();
6161 }