[clang] [LifetimeSafety] Introduce a liveness-based lifetime policy (PR #159991)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 7 10:20:09 PDT 2025


================
@@ -1120,109 +1114,194 @@ class LoanPropagationAnalysis
         OriginLoanMapFactory.add(In.Origins, DestOID, MergedLoans));
   }
 
-  LoanSet getLoans(OriginID OID, ProgramPoint P) {
+  LoanSet getLoans(OriginID OID, ProgramPoint P) const {
     return getLoans(getState(P), OID);
   }
 
 private:
-  LoanSet getLoans(Lattice L, OriginID OID) {
+  LoanSet getLoans(Lattice L, OriginID OID) const {
     if (auto *Loans = L.Origins.lookup(OID))
       return *Loans;
     return LoanSetFactory.getEmptySet();
   }
 };
 
 // ========================================================================= //
-//                         Expired Loans Analysis
+//                         Live Origins Analysis
 // ========================================================================= //
 
-/// The dataflow lattice for tracking the set of expired loans.
-struct ExpiredLattice {
-  /// Map from an expired `LoanID` to the `ExpireFact` that made it expire.
-  ExpiredLoanMap Expired;
+/// Information about why an origin is live at a program point.
+struct LivenessInfo {
+  /// The use that makes the origin live. If liveness is propagated from
+  /// multiple uses along different paths, this will point to the use appearing
+  /// before in the translation unit.
+  const UseFact *CausingUseFact;
+  /// The confidence in the liveness of the origin.
----------------
usx95 wrote:

Added how is it used later.

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


More information about the cfe-commits mailing list