[clang] [analyzer] Discard non-live source frames from the current stack (PR #213779)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 4 04:48:39 PDT 2026


steakhal wrote:

According to claude, this is a more ergonomic reproducer:
```c++
// An object passed by value to a function that is not inlined is constructed
// directly into the parameter region of the callee, which lives in a stack
// frame that is never entered. That frame is not on the stack while the
// constructor body runs, but the argument still outlives the call, so nothing
// dangles here.
struct Chained {
  Chained &self() [[clang::lifetimebound]] { return *this; }
  // The second call is what matters: the first one records `self()`'s return
  // value as bound to the parameter region, the second one looks it up again.
  Chained() {
    self();
    self(); // no-warning
  }
};

void takes_by_value(Chained arg);

void no_dangling_by_value_argument() {
  takes_by_value(Chained()); // no-warning
}
```

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


More information about the cfe-commits mailing list