[cfe-dev] Number of elements in ArrayType?

Kenth Eriksson via cfe-dev cfe-dev at lists.llvm.org
Tue Oct 29 08:32:37 PDT 2019


On Tue, 2019-10-29 at 15:03 +0100, Csaba Dabis wrote:
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> 
> 
> Assume that you have the desired `VarDecl` `D`:
> ```
>        const Expr *SizeExpr = nullptr;
>         if (D->getType()->isArrayType())
>           if (const TypeSourceInfo *TSI = D->getTypeSourceInfo())
>             if (const auto ATL = TSI->getTypeLoc().getAs<ArrayTypeLoc>())
>               SizeExpr = ATL.getSizeExpr();
> ```
> 
I'm having a MemberExpr not a VarDecl. I thought it was thru TypeInfo I
could get the number of elements in the array?




More information about the cfe-dev mailing list