[clang] [LifetimeSafety] Warn when lifetimebound attribute is present on the definition but not on declaration (PR #197753)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Tue May 19 04:04:03 PDT 2026


================
@@ -631,6 +631,19 @@ This warning may produce false-positives diagnostics when it cannot fully model
   }];
 }
 
+def LifetimeSafetyCrossTUMisplacedLifetimebound
+    : DiagGroup<"lifetime-safety-cross-tu-misplaced-lifetimebound">;
+def LifetimeSafetyIntraTUMisplacedLifetimebound
+    : DiagGroup<"lifetime-safety-intra-tu-misplaced-lifetimebound">;
+def LifetimeSafetyMisplacedLifetimebound
+    : DiagGroup<"lifetime-safety-misplaced-lifetimebound",
+                [LifetimeSafetyCrossTUMisplacedLifetimebound,
+                 LifetimeSafetyIntraTUMisplacedLifetimebound]> {
+    code Documentation = [{
+Detects function definitions whose parameters or implicit this argument are marked as [[clang::lifetimebound]] when the canonical declaration is not.
----------------
Xazax-hun wrote:

I think users not supposed to know what a canonical declaration is, but we plan to make further improvements to this diagnostic soon, so I am fine keeping it temporarily. 

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


More information about the cfe-commits mailing list