[clang] [LifetimeSafety] Detect use-after-scope through fields in member calls (PR #191731)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 13 22:57:25 PDT 2026
================
@@ -728,6 +728,38 @@ void FactsGenerator::handleInvalidatingCall(const Expr *Call,
ThisList->getOuterOriginID(), Call));
}
+void FactsGenerator::handleImplicitObjectFieldUses(const Expr *Call,
+ const FunctionDecl *FD) {
+ const auto *MemberCall = dyn_cast_or_null<CXXMemberCallExpr>(Call);
+ if (!MemberCall)
+ return;
+
+ if (!isa_and_present<CXXThisExpr>(
+ MemberCall->getImplicitObjectArgument()->IgnoreImpCasts()))
+ return;
+
+ const auto *MD = dyn_cast<CXXMethodDecl>(FD);
+ assert(MD && "Expected MD to be a non-null pointer");
+
----------------
usx95 wrote:
nit: change the assertion to mention why we expect that.
`assert(MD && "Function must be a CXXMethodDecl for member calls");`
https://github.com/llvm/llvm-project/pull/191731
More information about the cfe-commits
mailing list