Changes to build successfully with GCC 3.02
[oota-llvm.git] / include / llvm / Assembly / PrintModulePass.h
1 //===- llvm/Assembly/PrintModulePass.h - Printing Pass -----------*- C++ -*--=//
2 //
3 // This file defines a simple pass to print out methods of a module as they are
4 // processed.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #ifndef LLVM_ASSEMBLY_PRINTMODULEPASS_H
9 #define LLVM_ASSEMBLY_PRINTMODULEPASS_H
10
11 #include "llvm/Pass.h"
12 #include "llvm/Assembly/Writer.h"
13 #include <iostream>
14
15 class PrintModulePass : public Pass {
16   std::string Banner;     // String to print before each method
17   std::ostream *Out;      // ostream to print on
18   bool DeleteStream;      // Delete the ostream in our dtor?
19   bool PrintPerMethod;    // Print one method at a time rather than the whole?
20 public:
21   inline PrintModulePass(const std::string &B, std::ostream *o = &std::cout,
22                          bool DS = false,
23                          bool printPerMethod = true)
24     : Banner(B), Out(o), DeleteStream(DS), PrintPerMethod(printPerMethod) {
25   }
26   
27   inline ~PrintModulePass() {
28     if (DeleteStream) delete Out;
29   }
30   
31   // doPerMethodWork - This pass just prints a banner followed by the method as
32   // it's processed.
33   //
34   bool doPerMethodWork(Method *M) {
35     if (PrintPerMethod)
36       (*Out) << Banner << M;
37     return false;
38   }
39
40   // doPassFinalization - Virtual method overriden by subclasses to do any post
41   // processing needed after all passes have run.
42   //
43   bool doPassFinalization(Module *M) {
44     if (! PrintPerMethod)
45       (*Out) << Banner << M;
46     return false;
47   }
48 };
49
50 #endif