[clang] [LifetimeSafety] Detect use-after-return (PR #165370)

Kashika Akhouri via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 6 00:59:39 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;
----------------
kashika0112 wrote:

p2 is not accessible after return statement and the test throws an error that p2 is not found.

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


More information about the cfe-commits mailing list