[cfe-dev] Type of Array ParmVarDecl becomes PointerType
Douglas Gregor
dgregor at apple.com
Thu Dec 22 08:35:00 PST 2011
On Dec 22, 2011, at 1:57 AM, Peter wrote:
> Hi everybody,
>
> I am using Version 3.0 and I am trying to parse the parameter of the following function declaration.
>
> void test(int myParam[])
> {
>
>
> }
>
> I have written an ASTVisitor to iterate over the "ParamDecl's"of my "FunctionDecl's"
> The type of the "ParmVarDecl" myParam is always a "PointerType", although I am expecting
> an "ArrayType". Is this normal behavior?
Yes. The language specifies that parameters of array or function type are adjusted to the corresponding pointer type.
> Also when I parse the following code I am loosing the size information. Sure, the
> 99 doesn't make much sense, but I need it for internal analysis ;)
>
> void test(int myParam[99])
> {
>
>
> }
>
> I hope someone can help!
Use ParmVarDecl::getOriginalType() to get the type as it was spelled in the source code, before the adjustment applied.
- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111222/b1050892/attachment.html>
More information about the cfe-dev
mailing list