[all-commits] [llvm/llvm-project] f25fc5: [LifetimeSafety] Implement dataflow analysis for l...

Utkarsh Saxena via All-commits all-commits at lists.llvm.org
Mon Jul 14 11:21:30 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f25fc5fe1ea1efd18a18d5cf58ee483fd33ccfc3
      https://github.com/llvm/llvm-project/commit/f25fc5fe1ea1efd18a18d5cf58ee483fd33ccfc3
  Author: Utkarsh Saxena <usx at google.com>
  Date:   2025-07-14 (Mon, 14 Jul 2025)

  Changed paths:
    M clang/lib/Analysis/LifetimeSafety.cpp
    M clang/test/Sema/warn-lifetime-safety-dataflow.cpp

  Log Message:
  -----------
  [LifetimeSafety] Implement dataflow analysis for loan propagation (#148065)

This patch introduces the core dataflow analysis infrastructure for the C++ Lifetime Safety checker. This change implements the logic to propagate "loan" information across the control-flow graph. The primary goal is to compute a fixed-point state that accurately models which pointer (Origin) can hold which borrow (Loan) at any given program point.

Key components 

* `LifetimeLattice`: Defines the dataflow state, mapping an `OriginID` to a `LoanSet` using `llvm::ImmutableMap`.

* `Transferer`: Implements the transfer function, which updates the `LifetimeLattice` by applying the lifetime facts (Issue, AssignOrigin, etc.) generated for each basic block.

* `LifetimeDataflow`: A forward dataflow analysis driver that uses a worklist algorithm to iterate over the CFG until the lattice state converges.

The existing test suite has been extended to check the final dataflow results.

This work is a prerequisite for the final step of the analysis: consuming these results to identify and report lifetime violations.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list