[clang] [LifetimeSafety] Detect use-after-return (PR #165370)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 5 19:17:01 PST 2025
================
@@ -1202,5 +1202,242 @@ TEST_F(LifetimeAnalysisTest, LivenessOutsideLoop) {
EXPECT_THAT(Origins({"p"}), MaybeLiveAt("p1"));
}
+TEST_F(LifetimeAnalysisTest, SimpleReturnStackAddress) {
+ SetupTest(R"(
+ MyObj* target() {
+ MyObj s;
+ MyObj* p = &s;
+ POINT(p1);
+ return p;
----------------
usx95 wrote:
Could you also try to test the point after return.
```cpp
POINT(p1);
return p;
POINT(p2);
```
(Not sure whether we have the point p2 in the CFG as it is dead code so feel free to ignore if p2 is not available.)
https://github.com/llvm/llvm-project/pull/165370
More information about the cfe-commits
mailing list