[clang] [LifetimeSafety] Detect use-after-return (PR #165370)
Kashika Akhouri via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 6 00:46:53 PST 2025
================
@@ -42,6 +42,11 @@ class LifetimeSafetyReporter {
virtual void reportUseAfterFree(const Expr *IssueExpr, const Expr *UseExpr,
SourceLocation FreeLoc,
Confidence Confidence) {}
+
+ virtual void reportUseAfterReturn(const Expr *IssueExpr,
+ const Stmt *EscapeStmt,
----------------
kashika0112 wrote:
Done. I've updated the signature to use `const Expr* EscapeExpr` as you suggested.
I just wanted to confirm the effect on diagnostics: the warning now correctly points to the variable being returned (e.g., on `local` in `return local;`) instead of the general `return` keyword. This seems more precise, so I'm assuming this was the intended and desirable outcome.
https://github.com/llvm/llvm-project/pull/165370
More information about the cfe-commits
mailing list