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

Yuan Suo via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 2 22:44:29 PDT 2026


suoyuan666 wrote:

> > Hi, I’ve moved the assignment backtracking logic from `LifetimeChecker` into a dedicated file and refactored the diagnostic handling to align with the format you suggested.
> 
> I do not see the changes yet.

Hi, I’ve updated the assignment backtracking output based on your suggestions and extended it to cover other error types.

Here’s a brief summary of the changes:

- use-after-return: The logic is similar to use-after-free, so the integration was straightforward. Note that I didn't explicitly handle return statements without assignments, as I believe printing them adds little value in those cases.
- dangling field/global warnings: Unlike use-after-xx, dangling pointers lack a clear `UseExpr`/`ReturnExpr` to identify the target CFG Block. To address this, I now persist the `ExpiryExpr` and added `getBlockID` to `FactManager` to retrieve the BlockID directly from the corresponding Fact. This provides the necessary entry point for the search.

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


More information about the cfe-commits mailing list