[clang] [LifetimeSafety] Trace assignment history for use-after-scope errors (PR #188467)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Fri May 1 04:27:47 PDT 2026


usx95 wrote:

This is great work and will significantly improve the diagnostic experience for users. Thank you for the effort you've put into this! Unfortunately, the PR has grown quite large and touches many areas simultaneously, which makes thorough review challenging. I suggest splitting this into smaller, more reviewable increments:

**PR1: Single-block assignment tracking (NFC).** Add flow tracking with the core algorithm for tracing assignments within one CFG block, with no diagnostic changes and no lit test updates. If you can, include **unit tests** to check the algorithm works in isolation.

**PR2: First diagnostic integration.** Wire up PR1's tracking to ONE diagnostics (e.g., annotation suggestions) and update only `warn-lifetime-safety-suggestions.cpp` (a small test file). This gets early feedback on the diagnostic format/granularity before committing to large test updates.

**PR3: Expand to remaining categories.** Once the diagnostic format is agreed upon in PR2, mechanically apply it to other error types and update the remaining test files. This can be one PR or split by test file depending on the churn.

**PR4: Multi-block support.** Add traversal to track flows across CFG blocks, building on the single-block algorithm from PR1. Include some focused tests on multi-block scenarios.

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


More information about the cfe-commits mailing list