[LLVMdev] another question

xli3 at uiuc.edu xli3 at uiuc.edu
Mon Sep 16 16:35:00 PDT 2002

In the section expaining "dyn_cast"
There are following lines of code:
 if (AllocationInst *AI = dyn_cast<AllocationInst>(Val)) {
I cannot understand how you take a operand, a value, and cast
it into a Instruction. Can you explain it for me?

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)
      cerr << *PN;

In this case you cast &*BBI. It's not an operand. Can you
explain to me a little about what you can cast and what

Besides, maybe this is a stupid question, but what do you mean
by "&*BBI"?


More information about the llvm-dev mailing list