[LLVMdev] Dereference PointerType?

Óscar Fuentes ofv at wanadoo.es
Tue Oct 20 03:23:19 PDT 2009


Daniel Waterworth <da.waterworth at googlemail.com> writes:

[snip]

Use the getElementType method of PointerType.

>> size_t size;
>> if (isa<PointerType>(allocated_type)) {
>>   size = sizeof(void*) * 8;
>> } else {
>>   size = allocated_type->getPrimitiveSizeInBits();
>> }
>> // size now equals the size (in bits) of the type allocated

This looks suspicious to me. Maybe you intented

if (isa<PointerType>(allocated_type)) {
  size = sizeof(void*);
} else {
  size = allocated_type->getPrimitiveSizeInBits() * 8;
}

but take a look at getPrimitiveSizeInBits' documentation to make sure
that it is really what you want:

http://llvm.org/doxygen/classllvm_1_1Type.html

-- 
Óscar




More information about the llvm-dev mailing list