aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Transforms/PrintModulePass.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-10-15 17:31:51 +0000
committerChris Lattner <sabre@nondot.org>2001-10-15 17:31:51 +0000
commit1bffea0341968b3b2b0106c745d4602b6804e62f (patch)
treec76072d785eecda413d6e12bcf7ce41f965f5e9d /include/llvm/Transforms/PrintModulePass.h
parent3524fc2197c17edcea786a9bb0e00246438dba90 (diff)
Add new Pass infrastructure and some examples
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@836 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Transforms/PrintModulePass.h')
-rw-r--r--include/llvm/Transforms/PrintModulePass.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/llvm/Transforms/PrintModulePass.h b/include/llvm/Transforms/PrintModulePass.h
new file mode 100644
index 0000000000..90cd369f7b
--- /dev/null
+++ b/include/llvm/Transforms/PrintModulePass.h
@@ -0,0 +1,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<PrintModulePass> {
+ 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