mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
remove 'another common example', which doesn't work with VC++, and indent
another example properly git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21442 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ea3e5e56fd
commit
53f72b3bab
@ -292,8 +292,9 @@ file (note that you very rarely have to include this file directly).</p>
|
||||
if (isa<<a href="#Constant">Constant</a>>(V) || isa<<a href="#Argument">Argument</a>>(V) || isa<<a href="#GlobalValue">GlobalValue</a>>(V))
|
||||
return true;
|
||||
|
||||
<i>// Otherwise, it must be an instruction...</i>
|
||||
return !L->contains(cast<<a href="#Instruction">Instruction</a>>(V)->getParent());
|
||||
<i>// Otherwise, it must be an instruction...</i>
|
||||
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
|
||||
@ -322,21 +323,12 @@ file (note that you very rarely have to include this file directly).</p>
|
||||
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>
|
||||
<tt>InstVisitor</tt> class to dispatch over the instruction type directly.</p>
|
||||
|
||||
</dd>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user