1 //===- llvm/Assembly/PrintModulePass.h - Printing Pass -----------*- C++ -*--=//
3 // This file defines a simple pass to print out methods of a module as they are
6 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_ASSEMBLY_PRINTMODULEPASS_H
9 #define LLVM_ASSEMBLY_PRINTMODULEPASS_H
11 #include "llvm/Pass.h"
12 #include "llvm/Assembly/Writer.h"
14 class PrintModulePass : public Pass {
15 string Banner; // String to print before each method
16 ostream *Out; // ostream to print on
17 bool DeleteStream; // Delete the ostream in our dtor?
18 bool PrintPerMethod; // Print one method at a time rather than the whole?
20 inline PrintModulePass(const string &B, ostream *o = &cout,
22 bool printPerMethod = true)
23 : Banner(B), Out(o), DeleteStream(DS), PrintPerMethod(printPerMethod) {
26 inline ~PrintModulePass() {
27 if (DeleteStream) delete Out;
30 // doPerMethodWork - This pass just prints a banner followed by the method as
33 bool doPerMethodWork(Method *M) {
35 (*Out) << Banner << M;
39 // doPassFinalization - Virtual method overriden by subclasses to do any post
40 // processing needed after all passes have run.
42 bool doPassFinalization(Module *M) {
44 (*Out) << Banner << M;