[cfe-dev] Multi-dimensional arrays

Richard Smith richard at metafoo.co.uk
Wed Dec 5 18:50:38 PST 2012


On Wed, Dec 5, 2012 at 6:23 PM, TROUVE Antoine <trouve at isit.or.jp> wrote:

> Hello everybody
>
> I would like to know how to access to all the dimensions of an array with
> more than one dimension from its Decl object
> In other words, if I have the type "int[42][51]", I would like to get both
> the "42" and the "51".
>
> I figured out how to do so with a single-dimension using an ASTContext,
> but not for multiple dimensions yet.


Use getAsConstantArrayType to get the ConstantArrayType* and extract the
first dimension. Then, use getElementType() on the ConstantArrayType to get
the element type, and use getAsConstantArrayType on that. Lather, rinse,
repeat as needed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121205/a990b4c5/attachment.html>


More information about the cfe-dev mailing list