aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Transforms/PrintModulePass.h
blob: 0e2cee1599754537feba8931ce747cd77d3fa5f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//===- llvm/Transforms/PrintModulePass.h - Printing Pass ---------*- C++ -*--=//
//
// This file defines a simple pass to print out methods of a module as they are
// processed.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TRANSFORMS_PRINTMODULE_H
#define LLVM_TRANSFORMS_PRINTMODULE_H

#include "llvm/Transforms/Pass.h"
#include "llvm/Assembly/Writer.h"

class PrintModulePass : public ConcretePass {
  string Banner;          // String to print before each method
  ostream *Out;           // ostream to print on
  bool DeleteStream;      // Delete the ostream in our dtor?
public:
  inline PrintModulePass(const string &B, ostream *o = &cout, bool DS = false) 
    : Banner(B), Out(o), DeleteStream(DS) {}

  ~PrintModulePass() {
    if (DeleteStream) delete Out;
  }

  // doPerMethodWork - This pass just prints a banner followed by the method as
  // it's processed.
  //
  bool doPerMethodWorkVirt(Method *M) {
    (*Out) << Banner << M;
    return false;
  }
};

#endif