diff options
author | Chris Lattner <sabre@nondot.org> | 2002-04-15 19:32:36 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-04-15 19:32:36 +0000 |
commit | 7296e93f08f7495dbe3f25e35bff0b616b438e19 (patch) | |
tree | 9fa95c738db8834f3501ec0972249ac38debe3ff | |
parent | b42b7f921af95025a665129adbbb51fbf25d982c (diff) |
* s/Method/Function
* Add/allow callbacks for module,function, & basic block visiting
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2250 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Support/InstVisitor.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/include/llvm/Support/InstVisitor.h b/include/llvm/Support/InstVisitor.h index c379cc1743..ba193336cf 100644 --- a/include/llvm/Support/InstVisitor.h +++ b/include/llvm/Support/InstVisitor.h @@ -29,7 +29,7 @@ // // And this class would be used like this: // CountMallocVistor CMV; -// CMV.visit(method); +// CMV.visit(function); // NumMallocs = CMV.Count; // //===----------------------------------------------------------------------===// @@ -65,11 +65,20 @@ struct InstVisitor { visit(*Start++); } - // Define visitors for modules, methods and basic blocks... + // Define visitors for modules, functions and basic blocks... // - void visit(Module *M) { visit(M->begin(), M->end()); } - void visit(Function *F) { visit(F->begin(), F->end()); } - void visit(BasicBlock *BB) { visit(BB->begin(), BB->end()); } + void visit(Module *M) { + ((SubClass*)this)->visitModule(M); + visit(M->begin(), M->end()); + } + void visit(Function *F) { + ((SubClass*)this)->visitFunction(F); + visit(F->begin(), F->end()); + } + void visit(BasicBlock *BB) { + ((SubClass*)this)->visitBasicBlock(BB); + visit(BB->begin(), BB->end()); + } // visit - Finally, code to visit an instruction... // @@ -91,6 +100,13 @@ struct InstVisitor { // and try visiting the subtype. All of this should be inlined perfectly, // because there are no virtual functions to get in the way. // + + // When visiting a module, function or basic block directly, these methods get + // called to indicate when transitioning into a new unit. + // + void visitModule (Module *M) {} + void visitFunction (Function *F) {} + void visitBasicBlock(BasicBlock *BB) {} // Specific Instruction type classes... note that all of the casts are // neccesary because we use the instruction classes as opaque types... |