+ return !L->contains(cast<<a href="#Instruction">Instruction</a>>(V)->getParent());
+ </pre>
+
+ <p>Note that you should <b>not</b> use an <tt>isa<></tt> test followed
+ by a <tt>cast<></tt>, for that use the <tt>dyn_cast<></tt>
+ operator.</p>
+
+ </dd>
+
+ <dt><tt>dyn_cast<></tt>:</dt>
+
+ <dd>The <tt>dyn_cast<></tt> operator is a "checking cast" operation. It
+ checks to see if the operand is of the specified type, and if so, returns a
+ pointer to it (this operator does not work with references). If the operand is
+ not of the correct type, a null pointer is returned. Thus, this works very
+ much like the <tt>dynamic_cast</tt> operator in C++, and should be used in the
+ same circumstances. Typically, the <tt>dyn_cast<></tt> operator is used
+ in an <tt>if</tt> statement or some other flow control statement like this:
+
+ <pre>
+ if (<a href="#AllocationInst">AllocationInst</a> *AI = dyn_cast<<a href="#AllocationInst">AllocationInst</a>>(Val)) {
+ ...
+ }
+ </pre>
+
+ <p> This form of the <tt>if</tt> statement effectively combines together a
+ call to <tt>isa<></tt> and a call to <tt>cast<></tt> into one
+ statement, which is very convenient.</p>
+
+ <p> Another common example is:</p>
+
+ <pre>
+ <i>// Loop over all of the phi nodes in a basic block</i>
+ BasicBlock::iterator BBI = BB->begin();
+ for (; <a href="#PhiNode">PHINode</a> *PN = dyn_cast<<a href="#PHINode">PHINode</a>>(BBI); ++BBI)
+ std::cerr << *PN;
+ </pre>
+
+ <p>Note that the <tt>dyn_cast<></tt> operator, like C++'s
+ <tt>dynamic_cast</tt> or Java's <tt>instanceof</tt> operator, can be abused.
+ In particular you should not use big chained <tt>if/then/else</tt> blocks to
+ check for lots of different variants of classes. If you find yourself
+ wanting to do this, it is much cleaner and more efficient to use the
+ InstVisitor class to dispatch over the instruction type directly.</p>
+
+ </dd>
+
+ <dt><tt>cast_or_null<></tt>: </dt>
+
+ <dd>The <tt>cast_or_null<></tt> operator works just like the
+ <tt>cast<></tt> operator, except that it allows for a null pointer as
+ an argument (which it then propagates). This can sometimes be useful,
+ allowing you to combine several null checks into one.</dd>
+
+ <dt><tt>dyn_cast_or_null<></tt>: </dt>
+
+ <dd>The <tt>dyn_cast_or_null<></tt> operator works just like the
+ <tt>dyn_cast<></tt> operator, except that it allows for a null pointer
+ as an argument (which it then propagates). This can sometimes be useful,
+ allowing you to combine several null checks into one.</dd>
+
+ </dl>
+
+<p>These five templates can be used with any classes, whether they have a
+v-table or not. To add support for these templates, you simply need to add
+<tt>classof</tt> static methods to the class you are interested casting
+to. Describing this is currently outside the scope of this document, but there
+are lots of examples in the LLVM source base.</p>
+
+</div>
+
+<!-- ======================================================================= -->
+<div class="doc_subsection">
+ <a name="DEBUG">The <tt>DEBUG()</tt> macro & <tt>-debug</tt> option</a>
+</div>