[clang] [LifetimeSafety] Report the alias chain for returned stack memory (PR #226395)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 4 09:42:48 PDT 2026
================
@@ -3887,27 +3887,27 @@ namespace GH191954 {
int x;
int* f = &x; // expected-warning {{stack memory associated with local variable 'x' is returned}}
int* a;
- a = std::move(f);
+ a = std::move(f); // expected-note {{result of call to 'move<int *&>' aliases the storage of local variable 'x'}}
return a; // expected-note {{returned here}}
}
int* return_moved_pointer2() {
int x;
int* f = &x; // expected-warning {{stack memory associated with local variable 'x' is returned}}
- return std::move(f); // expected-note {{returned here}}
+ return std::move(f); // expected-note {{returned here}} expected-note {{result of call to 'move<int *&>' aliases the storage of local variable 'x'}}
----------------
usx95 wrote:
nit: We have been using ` \` to split the assertions across multiple line.
```cpp
return std::move(f); // expected-note {{returned here}} \
// expected-note {{result of call to 'move<int *&>' aliases the storage of local variable 'x'}}
```
Same for all the tests.
https://github.com/llvm/llvm-project/pull/226395
More information about the cfe-commits
mailing list