[clang] [analyzer] Implement BugReporterVisitor for UseAfterLifetimeEnd to trace lifetime source binding (PR #207052)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 27 01:45:46 PDT 2026


================
@@ -38,21 +61,84 @@ void UseAfterLifetimeEnd::checkEndFunction(const ReturnStmt *RS,
   if (ExplodedNode *N =
           C.generateNonFatalErrorNode(State, C.getPredecessor())) {
     for (const MemRegion *R : RetValRegion)
-      reportDanglingSource(R, N, C);
+      reportDanglingSource(R, RetVal, N, C);
   }
 }
 
+static SourceRange getRegionDeclRange(const MemRegion *Source) {
+  if (const auto *VR = dyn_cast<VarRegion>(Source))
----------------
isuckatcs wrote:

What if `Source` is `nullptr`?

```suggestion
  if (const auto *VR = dyn_cast_or_null<VarRegion>(Source))
```

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


More information about the cfe-commits mailing list