[clang] [LifetimeSafety] Add support for `new`/`delete` (PR #192504)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 21 06:38:15 PDT 2026


================
@@ -615,6 +623,30 @@ void FactsGenerator::VisitArraySubscriptExpr(const ArraySubscriptExpr *ASE) {
       Dst->getOuterOriginID(), Src->getOuterOriginID(), /*Kill=*/true));
 }
 
+void FactsGenerator::VisitCXXNewExpr(const CXXNewExpr *NE) {
+  OriginList *NewList = getOriginsList(*NE);
+
+  const Loan *L = createLoan(FactMgr, NE);
+  CurrentBlockFacts.push_back(
+      FactMgr.createFact<IssueFact>(L->getID(), NewList->getOuterOriginID()));
+
+  NewList = NewList->peelOuterOrigin();
+
+  if (!NewList)
+    return;
+
+  // FIXME: Once arrays are handled properly, remove the check for Init is
+  // non-null.
----------------
usx95 wrote:

Can you also briefly document what the target `new` expression which needs to be handled.

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


More information about the cfe-commits mailing list