[clang] [LifetimeSafety] Track static data members accessed via MemberExpr (PR #238398)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 4 01:22:03 PST 2026
================
@@ -976,8 +986,10 @@ void FactsGenerator::handleInvalidatingCall(const Expr *Call,
// Heuristics to turn-down false positives. Skip member field expressions for
// now. This is not a perfect filter and will still surface some false
- // positives (e.g. `auto& r = s.v`).
- if (!isa<DeclRefExpr>(Args[0]->IgnoreImpCasts()))
+ // positives (e.g. `auto& r = s.v`). Static data members are not fields.
+ const Expr *Obj = Args[0]->IgnoreImpCasts();
+ if (const auto *ME = dyn_cast<MemberExpr>(Obj);
+ !isa<DeclRefExpr>(Obj) && !(ME && isa<VarDecl>(ME->getMemberDecl())))
----------------
NeKon69 wrote:
I think this is somewhat hard to read, maybe something like this would be cleaner?
```cpp
if (const auto *ME = dyn_cast<MemberExpr>(Obj);
!(isa<DeclRefExpr>(Obj) || ME && isa<VarDecl>(ME->getMemberDecl())))
```
This more of a preference than a suggestion, so feel free to leave it as it is if you find your version cleaner.
https://github.com/llvm/llvm-project/pull/238398
More information about the cfe-commits
mailing list