[clang] [LifetimeSafety] Implement dataflow analysis for loan propagation (PR #148065)
Yitzhak Mandelbaum via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 14 09:59:24 PDT 2025
================
@@ -493,7 +496,241 @@ class FactGenerator : public ConstStmtVisitor<FactGenerator> {
};
// ========================================================================= //
-// TODO: Run dataflow analysis to propagate loans, analyse and error reporting.
+// The Dataflow Lattice
+// ========================================================================= //
+
+// Using LLVM's immutable collections is efficient for dataflow analysis
+// as it avoids deep copies during state transitions.
+// TODO(opt): Consider using a bitset to represent the set of loans.
+using LoanSet = llvm::ImmutableSet<LoanID>;
+using OriginLoanMap = llvm::ImmutableMap<OriginID, LoanSet>;
+
+/// An object to hold the factories for immutable collections, ensuring
+/// that all created states share the same underlying memory management.
+struct LifetimeFactory {
+ OriginLoanMap::Factory OriginMapFact;
----------------
ymand wrote:
+1
https://github.com/llvm/llvm-project/pull/148065
More information about the cfe-commits
mailing list