[LLVMdev] StructType member offset

Alexander Herz
2010-10-26T12:32:39Z

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