<div dir="ltr"><div>Great! Thanks</div><div></div></div><br><div class="gmail_quote"><div dir="ltr">po 1. 10. 2018 o 20:55 David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> napísal(a):<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I chatted with Richard Smith about this and he pointed out that the extra info for MAX * 3 is stored in the TypeLocInfo (which can be retrieved from the VarDecl), rather than the Type itself.<br><br>For example, in gdb, once I've found the VarDecl (pointer stored in the GDB temporary expression $10), I could retrieve the expression:<br><br><div>p ((clang::ArrayTypeLoc)((VarDecl*)$10)->getTypeSourceInfo()->getTypeLoc()).getSizeExpr()->dump()</div><div>BinaryOperator 0xcc8f7c8 'int' '*'</div><div>|-IntegerLiteral 0xcc8f788 'int' 10</div><div>`-IntegerLiteral 0xcc8f7a8 'int' 3<br><br>You can find the macro details by looking at the source location stuff - I don't know that piece in detail, but should work as well/in the same way here as in the rest of the AST.<br><br>Hope that helps!<br>- Dave</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 1, 2018 at 3:35 AM Dávid Bolvanský via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Hello,<div style="color:rgb(0,0,0);background-color:rgb(255,255,254)"><span style="color:rgb(0,0,255)"><br></span></div>#define MAX 10<br><br>int main() // (int n)<br>{<br>char arr[MAX * 3]; // arr[n + 3]<br>}<br><br>I expected that AST would be more detailed (e.g. Binary Operator) but Clang seems to fold it:<br>TranslationUnitDecl<br>`-FunctionDecl <line:11:1, line:14:1> line:11:5 main 'int ()'<br>`-CompoundStmt <line:12:1, line:14:1><br>`-DeclStmt <line:13:3, col:20><br>`-VarDecl <col:3, col:19> col:8 arr 'char [30]'</div><div><br></div><div>or raw output</div><div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254)"><div>`-VarDecl <col:<span style="color:rgb(9,136,90)">3</span>, col:<span style="color:rgb(9,136,90)">15</span>> col:<span style="color:rgb(9,136,90)">8</span> a <span style="color:rgb(163,21,21)">'</span><span style="color:rgb(0,0,255)">char</span> [n * <span style="color:rgb(9,136,90)">3</span>]<span style="color:rgb(163,21,21)">'</span></div></div></div><div><br></div><div>So with the current AST output we are unable to determine overflowing in array sizes, as requested in <a href="https://bugs.llvm.org/show_bug.cgi?id=27439" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=27439</a>, right?</div><div><br></div><div>Is it possible to disable that folding / enhance VarDecl for arrays?</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="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>
</blockquote></div>