[cfe-dev] Array size in QualType

Douglas Gregor dgregor at apple.com
Mon Nov 8 06:09:45 PST 2010


On Nov 8, 2010, at 7:13 AM, Peter Collingbourne wrote:

> On Mon, Nov 08, 2010 at 02:52:32PM +0700, Pisit Makpaisit wrote:
>> How can I get size of arrays from QualType object?
> 
> For constant sized arrays (the most common case), dyn_cast to
> ConstantArrayType and use ConstantArrayType::getSize.  For the others,
> look at the other subclasses of ArrayType.

dyn_cast won't look through typedefs. Use Context::getAs*ArrayType() to get at the appropriate array type, looking through typedefs.

	- Doug



More information about the cfe-dev mailing list