[clang] [Clang] Fix 'counted_by' for nested struct pointers (PR #110497)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 2 16:47:26 PDT 2024
efriedma-quic wrote:
> I'm not sure what you mean by "or it finds a pointer that's the base". The MemberExpr the visitor returns doesn't have to be a pointer---e.g. ptr->a.b.c.d returning ptr->a.b, where b isn't a pointer---or do you mean something else?
In an expression which does not contain "->" operators, StructAccessBase should return an lvalue: the expression which describes the base of the relevant struct. There might be addressof/dereference/array decay/etc. in the middle, but that's the ultimate result. The "or it finds a pointer" bit isn't relevant in this case.
"LHS->member" is equivalent to "(*LHS).member"... and sometimes StructAccessBase wants to return "*LHS". This is where the "or it finds a pointer" bit comes in; there is no expression *LHS in the AST, so it returns a pointer which needs to be dereferenced to turn it into an lvalue.
https://github.com/llvm/llvm-project/pull/110497
More information about the cfe-commits
mailing list