[clang] [LifetimeSafety] Fix false positives for pointers in loops (PR #182368)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 13 10:19:46 PDT 2026


================
@@ -470,10 +470,28 @@ void FactsGenerator::VisitLambdaExpr(const LambdaExpr *LE) {
   }
 }
 
+bool FactsGenerator::isEscapingOrigin(OriginID OID) const {
+  return llvm::any_of(EscapesInCurrentBlock, [OID](const Fact *F) {
+    if (const auto *EF = F->getAs<OriginEscapesFact>())
----------------
usx95 wrote:

I imagine we need this only for escape through return and not for other escapes because only these would involve a lifetimeend.

In that case, we should more specific here and only check for `ReturnEscapeFact`

s/isEscapingOrigin/escapesViaReturn

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


More information about the cfe-commits mailing list