1 //===-- llvm/Analysis/ModuleAnalyzer.h - Module analysis driver --*- C++ -*-==//
3 // This class provides a nice interface to traverse a module in a predictable
4 // way. This is used by the AssemblyWriter, BytecodeWriter, and SlotCalculator
5 // to do analysis of a module.
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_ANALYSIS_MODULEANALYZER_H
10 #define LLVM_ANALYSIS_MODULEANALYZER_H
22 class ModuleAnalyzer {
23 ModuleAnalyzer(const ModuleAnalyzer &); // do not impl
24 const ModuleAnalyzer &operator=(const ModuleAnalyzer &); // do not impl
27 virtual ~ModuleAnalyzer() {}
30 // processModule - Driver function to call all of my subclasses virtual
31 // methods. Commonly called by derived type's constructor.
33 bool processModule(const Module *M);
35 // processType - This callback occurs when an derived type is discovered
36 // at the class level. This activity occurs when processing a constant pool.
38 virtual bool processType(const Type *Ty) { return false; }
40 // processMethods - The default implementation of this method loops through
41 // all of the methods in the module and processModule's them.
43 virtual bool processMethods(const Module *M);
45 // visitMethod - This member is called after the constant pool has been
46 // processed. The default implementation of this is a noop.
48 virtual bool visitMethod(const Method *M) { return false; }
50 //===--------------------------------------------------------------------===//
51 // Stages of processing Method level information
54 // processMethod - Process all aspects of a method.
56 virtual bool processMethod(const Method *M);
58 // processMethodArgument - This member is called for every argument that
59 // is passed into the method.
61 virtual bool processMethodArgument(const MethodArgument *MA) { return false; }
63 // processBasicBlock - This member is called for each basic block in a methd.
65 virtual bool processBasicBlock(const BasicBlock *BB);
67 //===--------------------------------------------------------------------===//
68 // Stages of processing BasicBlock level information
71 // preProcessInstruction - This member is called for each Instruction in a
72 // method before processInstruction.
74 virtual bool preProcessInstruction(const Instruction *I);
76 // processInstruction - This member is called for each Instruction in a method
78 virtual bool processInstruction(const Instruction *I) { return false; }
81 bool handleType(std::set<const Type *> &TypeSet, const Type *T);