[llvm-branch-commits] [clang] [LifetimeSafety] Track per-field origins for record types (PR #195603)

Zhijie Wang via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed May 6 00:34:27 PDT 2026


================
@@ -563,9 +592,14 @@ void FactsGenerator::VisitCXXFunctionalCastExpr(
 void FactsGenerator::VisitInitListExpr(const InitListExpr *ILE) {
   if (!hasOrigins(ILE))
     return;
-  // For list initialization with a single element, like `View{...}`, the
-  // origin of the list itself is the origin of its single element.
-  if (ILE->getNumInits() == 1)
+  // For list initialization with a single element of the same type, like
+  // `View{other}`, the origin of the list itself is the origin of its single
+  // element.
+  //
+  // TODO: Handle aggregate (record/array) list initialization.
+  if (ILE->getNumInits() == 1 &&
+      ILE->getType().getCanonicalType() ==
+          ILE->getInit(0)->getType().getCanonicalType())
     killAndFlowOrigin(*ILE, *ILE->getInit(0));
 }
----------------
aeft wrote:

Without the type check, it crashes in `placement_new_pointer_field_from_dead_scope`. This is because record types now have origins, and in that function `src` and `dst` have different pointee-chain lengths, which fails the assertion in `flow()`.

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


More information about the llvm-branch-commits mailing list