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

Benedek Kaibas via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 5 05:03:55 PDT 2026


================
@@ -52,6 +52,11 @@ static bool isDanglingStackSource(const MemRegion *Source,
         })) {
       return false;
     }
+    // Only a source whose frame is still live on the current stack can
+    // dangle. If that frame is not on the stack then the source outlives
+    // the returned value. The source is still alive when the returned value
+    // is used, so it does not dangle.
+    return is_contained(make_pointer_range(C.stackframes()), SF);
----------------
benedekaibas wrote:

Yes, you are right. That is a silly mistake, sorry. Resolved here: [08d4f6f](https://github.com/llvm/llvm-project/pull/213779/commits/08d4f6f4e7238374ce19e7f449db66ba1ca3c43f)

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


More information about the cfe-commits mailing list