[clang] [LifetimeSafety] Introduce buildOriginFlowChain for use-after-scope (PR #199345)

Yuan Suo via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 11 05:07:51 PDT 2026


================
@@ -1239,13 +1270,15 @@ void parentheses(bool cond) {
   MyObj* p;
----------------
suoyuan666 wrote:

Below is the output for this case:

```txt
test.cpp:7:17: warning: local variable 'a' does not live long enough [-Wlifetime-safety-use-after-scope]
    7 |     MyObj* b = &a;
      |                 ^
test.cpp:9:3: note: destroyed here
    9 |   }
      |   ^
test.cpp:7:16: note: expression aliases the storage of local variable 'a'
    7 |     MyObj* b = &a;
      |                ^~
test.cpp:10:10: note: later used here
   10 |   (void)*p;
      |          ^
```

The expression `p = (((b)));` is not printed. As I understand it, this happens because `shouldShowInAliasChain` currently only calls `IgnoreImpCasts()` and does not call `IgnoreParens()` as well.

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


More information about the cfe-commits mailing list