Hello,<br><br>I'm wondering if it's possible to dereference a PointerType. I have an AllocaInst and although I can find the number of elements allocated, (using Instruction::getOperand(0)), I can't find a way to get the size of each element. What I'd like to do is:<br>
<br>AllocaInst *alloca;<br><br>PointerType *ptr_type = dynamic_cast<PointerType*>(alloca);<br>assert(ptr_type);<br>Type *allocated_type = ptr_type->dereference(); // this is the operation that doesn't seem to exist.<br>
size_t size;<br>if (isa<PointerType>(allocated_type)) {<br>  size = sizeof(void*) * 8;<br>} else {<br>  size = allocated_type->getPrimitiveSizeInBits();<br>}<br>// size now equals the size (in bits) of the type allocated<br>
<br>If it doesn't exist, how do you manage without it? Is there another way to write the above code?<br><br>Thanks,<br><br>Daniel<br>