From 16431f7b3cf854c4d5276aa347f21e055a18b666 Mon Sep 17 00:00:00 2001
From: Chris Lattner
Note that you should not use an isa<> test followed @@ -322,21 +323,12 @@ file (note that you very rarely have to include this file directly).
call to isa<> and a call to cast<> into one statement, which is very convenient. -Another common example is:
- -- // Loop over all of the phi nodes in a basic block - BasicBlock::iterator BBI = BB->begin(); - for (; PHINode *PN = dyn_cast<PHINode>(BBI); ++BBI) - std::cerr << *PN; --
Note that the dyn_cast<> operator, like C++'s dynamic_cast or Java's instanceof operator, can be abused. In particular you should not use big chained if/then/else 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.
+ InstVisitor class to dispatch over the instruction type directly.