1 //===- llvm/Assembly/PrintModulePass.h - Printing Pass -----------*- C++ -*--=//
3 // This file defines two passes to print out a module. The PrintModulePass
4 // pass simply prints out the entire module when it is executed. The
5 // PrintMethodPass class is designed to be pipelined with other MethodPass's,
6 // and prints out the methods of the class as they are processed.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_ASSEMBLY_PRINTMODULEPASS_H
11 #define LLVM_ASSEMBLY_PRINTMODULEPASS_H
13 #include "llvm/Pass.h"
16 class PrintModulePass : public Pass {
17 std::ostream *Out; // ostream to print on
18 bool DeleteStream; // Delete the ostream in our dtor?
20 inline PrintModulePass(std::ostream *o = &std::cout, bool DS = false)
21 : Out(o), DeleteStream(DS) {
24 inline ~PrintModulePass() {
25 if (DeleteStream) delete Out;
34 class PrintFunctionPass : public MethodPass {
35 std::string Banner; // String to print before each method
36 std::ostream *Out; // ostream to print on
37 bool DeleteStream; // Delete the ostream in our dtor?
39 inline PrintFunctionPass(const std::string &B, std::ostream *o = &std::cout,
41 : Banner(B), Out(o), DeleteStream(DS) {
44 inline ~PrintFunctionPass() {
45 if (DeleteStream) delete Out;
48 // runOnMethod - This pass just prints a banner followed by the method as
51 bool runOnMethod(Function *F) {
52 (*Out) << Banner << F;