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"
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?
21 inline PrintModulePass(const std::string &B, std::ostream *o = &std::cout,
23 bool printPerMethod = true)
24 : Banner(B), Out(o), DeleteStream(DS), PrintPerMethod(printPerMethod) {
27 inline ~PrintModulePass() {
28 if (DeleteStream) delete Out;
31 // doPerMethodWork - This pass just prints a banner followed by the method as
34 bool doPerMethodWork(Method *M) {
36 (*Out) << Banner << M;
40 // doPassFinalization - Virtual method overriden by subclasses to do any post
41 // processing needed after all passes have run.
43 bool doPassFinalization(Module *M) {
45 (*Out) << Banner << M;