[clang] [LifetimeSafety] Track a temporary materialized by a default argument (PR #239586)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 6 06:01:39 PST 2026


================
@@ -101,11 +101,14 @@ static const Loan *createLoan(FactManager &FactMgr, const ValueDecl &VD,
 
 /// Creates a loan for the storage location of a temporary object.
 /// \param MTE The MaterializeTemporaryExpr that represents the temporary
-/// binding. \return The new Loan.
+/// binding.
+/// \param IssueExpr The expression the loan is reported at, if not \p MTE.
+/// \return The new Loan.
 static const Loan *createLoan(FactManager &FactMgr,
-                              const MaterializeTemporaryExpr *MTE) {
-  AccessPath Path(MTE);
-  return FactMgr.getLoanMgr().createLoan(Path, MTE);
+                              const MaterializeTemporaryExpr *MTE,
+                              const Expr *IssueExpr = nullptr) {
+  return FactMgr.getLoanMgr().createLoan(AccessPath(MTE),
+                                         IssueExpr ? IssueExpr : MTE);
 }
 
----------------
Xazax-hun wrote:

I pass `CXXDefaultArgExpr::getExpr()`'s result below which is not a MTE.

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


More information about the cfe-commits mailing list