aboutsummaryrefslogtreecommitdiff
path: root/docs/ProgrammersManual.html
diff options
context:
space:
mode:
authorJoel Stanley <jstanley@cs.uiuc.edu>2002-09-09 16:29:58 +0000
committerJoel Stanley <jstanley@cs.uiuc.edu>2002-09-09 16:29:58 +0000
commitd8aabb20e81dd934425903466ba2544659dc6fb0 (patch)
tree56cfaed372c3e71596318c8598fd22c321b1de9c /docs/ProgrammersManual.html
parente7be6500e709adb12e5512d83d87170dab06b6cb (diff)
*** empty log message ***
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3635 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/ProgrammersManual.html')
-rw-r--r--docs/ProgrammersManual.html26
1 files changed, 13 insertions, 13 deletions
diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html
index d51d958df0..36e5920068 100644
--- a/docs/ProgrammersManual.html
+++ b/docs/ProgrammersManual.html
@@ -383,11 +383,11 @@ more complex example </h4><ul>
Say that you're writing a FunctionPass and would like to count all the
locations in the entire module (that is, across every
-<tt>Function</tt>) where a certain function (i.e. <tt>Function</tt>*)
-passed into the FunctionPass constructor. As you'll learn later, you
-may want to use an <tt>InstVisitor</tt> to accomplish this in a much
-more straightforward manner, but this example will allow us to explore
-how you'd do it if you didn't have <tt>InstVisitor</tt> around. In
+<tt>Function</tt>) where a certain function (i.e. some
+<tt>Function</tt>*) already in scope. As you'll learn later, you may
+want to use an <tt>InstVisitor</tt> to accomplish this in a much more
+straightforward manner, but this example will allow us to explore how
+you'd do it if you didn't have <tt>InstVisitor</tt> around. In
pseudocode, this is what we want to do:
<pre>
@@ -400,15 +400,16 @@ for each Function f in the Module
</pre>
And the actual code is (remember, since we're writing a
-<tt>FunctionPass</tt> our <tt>FunctionPass</tt>-derived class simply
+<tt>FunctionPass</tt>, our <tt>FunctionPass</tt>-derived class simply
has to override the <tt>runOnFunction</tt> method...):
<pre>
+
+Function* targetFunc = ...;
+
class OurFunctionPass : public FunctionPass {
public:
- OurFunctionPass(Function* func): m_func(func) { }
-
- virtual doInitialization(Module&amp M) { callCounter = 0; };
+ OurFunctionPass(): callCounter(0) { }
virtual runOnFunction(Function&amp F) {
for(Function::iterator b = F.begin(), be = F.end(); b != be; ++b) {
@@ -418,15 +419,14 @@ class OurFunctionPass : public FunctionPass {
// need to determine if it's a call to the
// function pointed to by m_func or not.
- if(callInst-&gt;getCalledFunction() == m_func)
+ if(callInst-&gt;getCalledFunction() == targetFunc)
++callCounter;
}
}
}
private:
- Function* m_func; // we're counting calls to this function.
- static unsigned callCounter;
+ unsigned callCounter;
};
</pre>
@@ -1280,6 +1280,6 @@ pointer to the parent Function.
<a href="mailto:sabre@nondot.org">Chris Lattner</a></address>
<!-- Created: Tue Aug 6 15:00:33 CDT 2002 -->
<!-- hhmts start -->
-Last modified: Mon Sep 9 10:47:48 CDT 2002
+Last modified: Mon Sep 9 11:29:35 CDT 2002
<!-- hhmts end -->
</font></body></html>