* s/Method/Function
* Add/allow callbacks for module,function, & basic block visiting llvm-svn: 2250
This commit is contained in:
		
							parent
							
								
									91eda67aaf
								
							
						
					
					
						commit
						ffe541feb2
					
				| 
						 | 
					@ -29,7 +29,7 @@
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//  And this class would be used like this:
 | 
					//  And this class would be used like this:
 | 
				
			||||||
//    CountMallocVistor CMV;
 | 
					//    CountMallocVistor CMV;
 | 
				
			||||||
//    CMV.visit(method);
 | 
					//    CMV.visit(function);
 | 
				
			||||||
//    NumMallocs = CMV.Count;
 | 
					//    NumMallocs = CMV.Count;
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//===----------------------------------------------------------------------===//
 | 
					//===----------------------------------------------------------------------===//
 | 
				
			||||||
| 
						 | 
					@ -65,11 +65,20 @@ struct InstVisitor {
 | 
				
			||||||
      visit(*Start++);
 | 
					      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(Module *M) {
 | 
				
			||||||
  void visit(Function *F) { visit(F->begin(), F->end()); }
 | 
					    ((SubClass*)this)->visitModule(M);
 | 
				
			||||||
  void visit(BasicBlock *BB) { visit(BB->begin(), BB->end()); }
 | 
					    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...
 | 
					  // visit - Finally, code to visit an instruction...
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
| 
						 | 
					@ -92,6 +101,13 @@ struct InstVisitor {
 | 
				
			||||||
  // because there are no virtual functions to get in the way.
 | 
					  // 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
 | 
					  // Specific Instruction type classes... note that all of the casts are
 | 
				
			||||||
  // neccesary because we use the instruction classes as opaque types...
 | 
					  // neccesary because we use the instruction classes as opaque types...
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue