[cfe-dev] can we know if an array definition has an explicit size ??

kevinlynx kevinlynx at gmail.com
Sun Jan 6 00:14:16 PST 2013


No. 

     int arr[3] = { 1, 2, 3 }
still get a ConstantArrayType.

Actually, if there's no explict size, RecursiveASTVisitor::VisitIncompleteArrayType will get called, but in this function context, i can not get the source location (because the argument to VisitIncompleteArrayType is only a type, not a stmt). 

Thanks



------------------ Original ------------------
From:  "Sean Silva"<silvas at purdue.edu>;
Date:  Sun, Jan 6, 2013 04:09 PM
To:  "kevinlynx"<kevinlynx at gmail.com>; 
Cc:  "cfe-dev"<cfe-dev at cs.uiuc.edu>; 
Subject:  Re: [cfe-dev] can we know if an array definition has an explicit size ??



You can probably check that it is a ConstantArrayType
<http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html>.

-- Sean Silva

On Sun, Jan 6, 2013 at 1:10 AM, kevinlynx <kevinlynx at gmail.com> wrote:
> say,
>
>     int arr[] = { 1, 2, 3 }
>
> here `arr` size is determined by the initializer expression automatically,
> but how to know this ? I implement `RecursiveASTVisitor::VisitVarDecl` and
> get a `VarDecl` object.
>
> Thanks
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130106/5d7aa647/attachment.html>


More information about the cfe-dev mailing list