[cfe-dev] AST for expresions in array sizes

Dávid Bolvanský via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 1 03:35:29 PDT 2018


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/3b8c8f1d/attachment.html>


More information about the cfe-dev mailing list