add some missing quotes in debug output
[llvm/avr.git] / lib / Transforms / Hello / Hello.cpp
blob8000d0d2ff4ae3d9c6bf71a6d231f73bc17539ed
1 //===- Hello.cpp - Example code from "Writing an LLVM Pass" ---------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements two versions of the LLVM "Hello World" pass described
11 // in docs/WritingAnLLVMPass.html
13 //===----------------------------------------------------------------------===//
15 #define DEBUG_TYPE "hello"
16 #include "llvm/Pass.h"
17 #include "llvm/Function.h"
18 #include "llvm/ADT/StringExtras.h"
19 #include "llvm/Support/raw_ostream.h"
20 #include "llvm/ADT/Statistic.h"
21 using namespace llvm;
23 STATISTIC(HelloCounter, "Counts number of functions greeted");
25 namespace {
26 // Hello - The first implementation, without getAnalysisUsage.
27 struct Hello : public FunctionPass {
28 static char ID; // Pass identification, replacement for typeid
29 Hello() : FunctionPass(&ID) {}
31 virtual bool runOnFunction(Function &F) {
32 HelloCounter++;
33 std::string fname = F.getName();
34 EscapeString(fname);
35 errs() << "Hello: " << fname << "\n";
36 return false;
41 char Hello::ID = 0;
42 static RegisterPass<Hello> X("hello", "Hello World Pass");
44 namespace {
45 // Hello2 - The second implementation with getAnalysisUsage implemented.
46 struct Hello2 : public FunctionPass {
47 static char ID; // Pass identification, replacement for typeid
48 Hello2() : FunctionPass(&ID) {}
50 virtual bool runOnFunction(Function &F) {
51 HelloCounter++;
52 std::string fname = F.getName();
53 EscapeString(fname);
54 errs() << "Hello: " << fname << "\n";
55 return false;
58 // We don't modify the program, so we preserve all analyses
59 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
60 AU.setPreservesAll();
65 char Hello2::ID = 0;
66 static RegisterPass<Hello2>
67 Y("hello2", "Hello World Pass (with getAnalysisUsage implemented)");