[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 5 13:07:54 PST 2023


efriedma-quic wrote:

If you do need a map for something, I'd prefer to make it as narrow as possible.  For example, I can imagine you could need to specifically look up the corresponding allocation for a CompoundLiteralExpr; that might make sense.  I don't think we should need to look up arbitrary lvalues.  For __builtin_dynamic_object_size, we should support a limited set of expressions as the base.  (And ideally, the recursive visit should list those expressions explicitly, instead aborting on ones we know are bad.)

> But if I placed some code in EmitArraySubscriptExpr, I'm guessing your suggestion is more-or-less this:

Not sure it goes at the end. But to restate more explicitly, if you have something like ArraySubscriptExpr(MemberExpr(StructBase), ArrayIndex), you emit StructBase, then you emit the addresses of the array member and the counted_by member, then you use that to emit a bounds-checked array access.  So you don't recurse; you just look for that exact AST structure.

https://github.com/llvm/llvm-project/pull/73730


More information about the cfe-commits mailing list