[cfe-dev] AST for expresions in array sizes

Dávid Bolvanský via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 1 04:18:42 PDT 2018


Thanks!

Basically macro info (e.g. whether MAX or 10) is not needed, but info
about BinaryOperator
would be quite useful.

po 1. 10. 2018 o 12:35 Dávid Bolvanský <david.bolvansky at gmail.com>
napísal(a):

> Hello,
>
> #define MAX 10
>
> int main() // (int n)
> {
> char arr[MAX * 3]; // arr[n + 3]
> }
>
> I expected that AST would be more detailed (e.g. Binary Operator) but
> Clang seems to fold it:
> TranslationUnitDecl
> `-FunctionDecl <line:11:1, line:14:1> line:11:5 main 'int ()'
> `-CompoundStmt <line:12:1, line:14:1>
> `-DeclStmt <line:13:3, col:20>
> `-VarDecl <col:3, col:19> col:8 arr 'char [30]'
>
> or raw output
> `-VarDecl <col:3, col:15> col:8 a 'char [n * 3]'
>
> So with the current AST output we are unable to determine overflowing in
> array sizes, as requested in https://bugs.llvm.org/show_bug.cgi?id=27439,
> right?
>
> Is it possible to disable that folding / enhance VarDecl for arrays?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181001/2c51503a/attachment.html>


More information about the cfe-dev mailing list