Total size of array type


Given a QualType (or Type) handle to an array declaration, I need to get the total size in bytes. For example:

int foo[2] // 8 bytes
char foo[2] // 2 bytes

I can get the number of elements using ConstantArray::getSize (which returns 2 in the above cases), but I need the size of the element type as well, in order to compute the total bytes. However, there's no getSize or equivalent for QualType or Type. What am I missing? Thanks,


Try ASTContext::getTypeSizeInChars().