From 633ad4ee178dad542cbd0a718aa0d8e1d57ad820 Mon Sep 17 00:00:00 2001
From: Chris Lattner
#include "llvm/Pass.h" #include "llvm/Function.h" +#include "llvm/Support/raw_ostream.h"
Which are needed because we are writing a Pass, and +href="http://llvm.org/doxygen/classllvm_1_1Pass.html">Pass, we are operating on Function's.
+href="http://llvm.org/doxygen/classllvm_1_1Function.html">Function's, +and we will be doing some printing.Next we have:
@@ -273,7 +275,7 @@ avoid using expensive C++ runtime information.virtual bool runOnFunction(Function &F) { - llvm::cerr << "Hello: " << F.getName() << "\n"; + errs() << "Hello: " << F.getName() << "\n"; return false; } }; // end of struct Hello @@ -312,6 +314,7 @@ is supplied as fourth argument.#include "llvm/Pass.h" #include "llvm/Function.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -322,7 +325,7 @@ is supplied as fourth argument. Hello() : FunctionPass(&ID) {} virtual bool runOnFunction(Function &F) { - llvm::cerr << "Hello: " << F.getName() << "\n"; + errs() << "Hello: " << F.getName() << "\n"; return false; } };