[clang] [LifetimeSafety] Add support for tracking temporary objects (PR #172007)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 14 01:23:56 PST 2025


================
@@ -218,9 +227,18 @@ void FactsGenerator::VisitMaterializeTemporaryExpr(
     const MaterializeTemporaryExpr *MTE) {
   if (!hasOrigin(MTE))
     return;
-  // A temporary object's origin is the same as the origin of the
-  // expression that initializes it.
-  killAndFlowOrigin(*MTE, *MTE->getSubExpr());
+  const Expr *Child = MTE->getSubExpr()->IgnoreImpCasts();
+  if (const CXXBindTemporaryExpr *BTE =
+          dyn_cast<const CXXBindTemporaryExpr>(Child)) {
+    // Issue a loan to MTE for the storage location represented by BTE
----------------
usx95 wrote:

nit: end the comment with a `.`

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


More information about the cfe-commits mailing list