[clang] [LifetimeSafety] Add warning for member functions returning field origins (PR #229784)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 14 02:50:34 PDT 2026
================
@@ -1214,10 +1215,23 @@ llvm::SmallVector<Fact *> FactsGenerator::issuePlaceholderLoans() {
llvm::SmallVector<Fact *> PlaceholderLoanFacts;
if (auto ThisOrigins = FactMgr.getOriginMgr().getThisOrigins()) {
OriginList *List = *ThisOrigins;
- const Loan *L =
- FactMgr.getLoanMgr().createPlaceholderLoan(cast<CXXMethodDecl>(FD));
+ const auto *MD = cast<CXXMethodDecl>(FD);
+ const Loan *L = FactMgr.getLoanMgr().createPlaceholderLoan(MD);
PlaceholderLoanFacts.push_back(
FactMgr.createFact<IssueFact>(L->getID(), List->getOuterOriginID()));
+ // $this.field represents the storage a field refers to, as opposed to the
+ // field itself (covered by $this).
+ if (!isa<CXXConstructorDecl>(MD))
+ if (const CXXRecordDecl *ClassDecl = MD->getParent()->getDefinition())
----------------
usx95 wrote:
Good point. I added those as well.
https://github.com/llvm/llvm-project/pull/229784
More information about the cfe-commits
mailing list