[clang] [LifetimeSafety] Model scope-exit destructor and cleanup callback as a use (PR #204650)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 2 01:54:32 PST 2026


================
@@ -11173,6 +11173,14 @@ def warn_lifetime_safety_field_origin_escape
     : Warning<"return value depends on the object referenced by %0, not on '*this'">,
       InGroup<LifetimeSafetyFieldOriginEscape>,
       DefaultIgnore;
+def warn_lifetime_safety_destructor_use_after_scope
+    : Warning<"%0 does not live long enough">,
+      InGroup<LifetimeSafetyDestructorUse>,
+      DefaultIgnore;
+def warn_lifetime_safety_destructor_use_after_invalidation
+    : Warning<"%0 is later invalidated">,
+      InGroup<LifetimeSafetyDestructorUse>,
+      DefaultIgnore;
----------------
Xazax-hun wrote:

Updated the PR to do something similar to what you suggested. I made some small modifications, e.g., I folded the UseExpr into the UseSite structure.

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


More information about the cfe-commits mailing list