[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)
Bill Wendling via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 5 13:44:19 PST 2023
bwendling wrote:
> And ideally, the recursive visit should list those expressions explicitly, instead aborting on ones we know are bad.
I'm sorry, I don't understand what you're talking about here. The whole point of the recursive visit is to find a suitable base pointer. If we run across any undesirable expressions (e.g. pointer arithmetic) then we return `nullptr` to signify this. What do you mean we should list those expressions explicitly?
> So you don't recurse; you just look for that exact AST structure.
Looking for the exact AST structure is what I'm trying to accomplish with `ExprLValueMap`. Even in `EmitArraySubscriptExpr`, I'll still have to crawl up the `MemberExpr` to find a suitable base pointer for accessing the `counted_by` field. The information about what LValue was generated for that base pointer is no longer available to us. It's not so bad if the base pointer is a simple `DeclRefExpr`, but if it's a `MemberExpr`, things get more complicated. If I can verify that the `MemberExpr` has no side-effects, then I can call the `EmitMemberExpr` method. This will most likely duplicate code, but not a huge deal. However, if I *can* reusing the `LValue` from the base `MemberExpr` with side-effects, then I can still emit the `counted_by` check, since I won't be re-generating the side-effects.
https://github.com/llvm/llvm-project/pull/73730
More information about the cfe-commits
mailing list