[clang] [LifetimeSafety] Track origins through nested subobject fields (PR #232867)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 16 13:46:34 PDT 2026


================
@@ -1211,15 +1211,30 @@ void FactsGenerator::handleUse(const Expr *E) {
 // class and its bases. It represents the storage the field refers to, as
 // opposed to the field itself (covered by $this).
 void FactsGenerator::issueFieldPlaceholderLoans(
-    const CXXMethodDecl *MD, llvm::SmallVectorImpl<Fact *> &Facts) {
-  const CXXRecordDecl *ClassDecl = MD->getParent()->getDefinition();
-  if (!ClassDecl)
-    return;
+    const CXXRecordDecl *ClassDef, llvm::SmallVectorImpl<Fact *> &Facts) {
+  assert(ClassDef);
----------------
steakhal wrote:

Partially my problem is that there is not much I could say in the message than what the assert already says.
What I think it would make sense to express why I think it's a reasonable precondition - but that's the callsite's property - because that's where we know that we deal with the parent class of a method.
The abstraction (function) technically accepts classes in general. - I'd need to think about if that would even make sense but simply looking at the types.

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


More information about the cfe-commits mailing list