[LLVMdev] StructType member offset
Alexander Herz
alexander.herz at mytum.de
Tue Oct 26 05:32:39 PDT 2010
Hi,
how can i correctly calculate the size of a member of a struct
(including alignment etc)?
This doesn't work :
const StructType *STy = cast<StructType>(Ty);
for (StructType::element_iterator I = STy->element_begin(),
E = STy->element_end(); I != E; ++I)
{
usigned size =I->get()->getScalarSizeInBits(); //often
returns 0, not what I need
}
Basically I want to add up the sizes of the different members to
calculate the offset (which I want to compare to
DIType::getOffsetInBits()). Or if there is a direct way to get the
offset of a struct member without adding their sizes that'd be even better.
Thx,
Alex
More information about the llvm-dev
mailing list