[clang] [LifetimeSafety] Propagate loans through pointer arithmetic (PR #189546)

via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 31 05:04:13 PDT 2026


================
@@ -371,11 +371,22 @@ void FactsGenerator::handleAssignment(const Expr *LHSExpr,
   flow(LHSList->peelOuterOrigin(), RHSList, /*Kill=*/true);
 }
 
+void FactsGenerator::handlePointerArithmetic(const BinaryOperator *BO) {
+  if (Expr *RHS = BO->getRHS(); RHS->getType()->isPointerType()) {
+    killAndFlowOrigin(*BO, *RHS);
+    return;
+  }
+  Expr *LHS = BO->getLHS();
+  assert(LHS->getType()->isPointerType() &&
----------------
NeKon69 wrote:

Yes, sorry i forgot to test that.

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


More information about the cfe-commits mailing list