[clang] Thread Safety Analysis: Fix implicit member access in attributes (PR #194457)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon May 4 07:37:36 PDT 2026


AaronBallman wrote:

> I think this should be fixed in the AST, and not worked around in the TIL translation. Fields should never be referenced by a `DeclRefExpr`, but only by `MemberExpr`s. It would also be good to keep a correspondence `DeclRefExpr` ↔ `til::LiteralPtr`, `MemberExpr` ↔ `til::Project`.
> 
> I know this is an issue in C, but this should better be fixed by introducing a built-in equivalent to `CXXThisExpr`.

On the one hand, yes (though I would argue it's not "fixed"; C has no such notion so this is purely a language extension at this point); it would make more sense to model this as a kind of member expression. On the other hand, that's a fairly significant amount of effort by comparison. But on the third hand, I think that effort may help in other circumstances like with bounds safety attributes which also want to be able to model fields which can implicitly reference other fields. CC @rapidsna in case there's already been investigation into this approach.

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


More information about the cfe-commits mailing list