Changes to build successfully with GCC 3.02
[oota-llvm.git] / include / llvm / Analysis / ModuleAnalyzer.h
1 //===-- llvm/Analysis/ModuleAnalyzer.h - Module analysis driver --*- C++ -*-==//
2 //
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.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_ANALYSIS_MODULEANALYZER_H
10 #define LLVM_ANALYSIS_MODULEANALYZER_H
11
12 #include <set>
13
14 class Type;
15 class Module;
16 class Method;
17 class BasicBlock;
18 class Instruction;
19 class MethodType;
20 class MethodArgument;
21
22 class ModuleAnalyzer {
23   ModuleAnalyzer(const ModuleAnalyzer &);                   // do not impl
24   const ModuleAnalyzer &operator=(const ModuleAnalyzer &);  // do not impl
25 public:
26   ModuleAnalyzer() {}
27   virtual ~ModuleAnalyzer() {}
28   
29 protected:
30   // processModule - Driver function to call all of my subclasses virtual 
31   // methods.  Commonly called by derived type's constructor.
32   //
33   bool processModule(const Module *M);
34
35   // processType - This callback occurs when an derived type is discovered
36   // at the class level. This activity occurs when processing a constant pool.
37   //
38   virtual bool processType(const Type *Ty) { return false; }
39
40   // processMethods - The default implementation of this method loops through 
41   // all of the methods in the module and processModule's them.
42   //
43   virtual bool processMethods(const Module *M);
44
45   // visitMethod - This member is called after the constant pool has been 
46   // processed.  The default implementation of this is a noop.
47   //
48   virtual bool visitMethod(const Method *M) { return false; }
49
50   //===--------------------------------------------------------------------===//
51   //  Stages of processing Method level information
52   //
53
54   // processMethod - Process all aspects of a method.
55   //
56   virtual bool processMethod(const Method *M);
57
58   // processMethodArgument - This member is called for every argument that 
59   // is passed into the method.
60   //
61   virtual bool processMethodArgument(const MethodArgument *MA) { return false; }
62
63   // processBasicBlock - This member is called for each basic block in a methd.
64   //
65   virtual bool processBasicBlock(const BasicBlock *BB);
66
67   //===--------------------------------------------------------------------===//
68   //  Stages of processing BasicBlock level information
69   //
70
71   // preProcessInstruction - This member is called for each Instruction in a 
72   // method before processInstruction.
73   //
74   virtual bool preProcessInstruction(const Instruction *I);
75
76   // processInstruction - This member is called for each Instruction in a method
77   //
78   virtual bool processInstruction(const Instruction *I) { return false; }
79
80 private:
81   bool handleType(std::set<const Type *> &TypeSet, const Type *T);
82 };
83
84 #endif