<div dir="ltr">The AST actually does retain the information you are looking for. I introduced the DecayedType pointer type so that we could retain it. It's difficult to see with the AST dumper, but if you manually traverse the nodes and handle DecayedType, you will find what you are looking for.<div><br></div><div>Consider this program:</div><div>int f(int A[50][100]) {<br> typedef decltype(A) P;<br> P o;<br> return A[0][0];<br>}<br></div><div><br></div><div>Dumping it shows how the decayed type appears inside decltype:</div><div> | `-TypedefDecl 0x1cb1da4b4c8 <col:3, col:23> col:23 referenced P 'decltype(A)':'int (*)[100]'<br> | `-DecltypeType 0x1cb1da4b490 'decltype(A)' sugar<br> | |-DeclRefExpr 0x1cb1da4b470 <col:20> 'int (*)[100]':'int (*)[100]' lvalue ParmVar 0x1cb1da4b280 'A' 'int (*)[100]':'int (*)[100]' non_odr_use_unevaluated<br> | `-DecayedType 0x1cb1d816580 'int (*)[100]' sugar<br> | |-ConstantArrayType 0x1cb1d8164e0 'int [50][100]' 50<br> | | `-ConstantArrayType 0x1cb1d816480 'int [100]' 100<br> | | `-BuiltinType 0x1cb1d8156d0 'int'<br> | `-PointerType 0x1cb1d816550 'int (*)[100]'<br> | `-ConstantArrayType 0x1cb1d816480 'int [100]' 100<br> | `-BuiltinType 0x1cb1d8156d0 'int'</div><div><br></div><div>Hopefully that helps.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 1, 2019 at 2:22 AM Tingyuan LIANG via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Dear all,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi! I am trying to extracting the size of array from ParamValDecl in AST but I notice the following situation:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
The type of an array “int A[50][100]” in the function interface in source code will turn out to be "int (*)[100]" in AST, which means that I lose the information of the outermost dimension, i.e. the number "50".
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I wonder how I can get the size of the outermost dimension of the array with Clang AST visitor, except processing the string of source code or implementing a specific parser.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
THANKS a lot in advance for your time and patience!<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="gmail-m_1626741116724834617Signature">
<div id="gmail-m_1626741116724834617divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif">
<span id="gmail-m_1626741116724834617ms-rterangepaste-start"></span>
<div><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">Best regards,</span></font><span style="font-size:12pt">
</span><span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0px"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">------------------------------------------</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0px"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">Tingyuan LIANG</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0px"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">MPhil Student</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0px"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">Department of Electronic and Computer Engineering</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0px"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">The Hong Kong University of Science and Technology</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span><span style="font-size:12pt"></span><span id="gmail-m_1626741116724834617ms-rterangepaste-end"></span></div>
</div>
</div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>