[clang] [LifetimeSafety] Warn on inapplicable `[[clang::lifetimebound]]` when return type can not carry a lifetime (PR #203767)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 15 05:12:35 PDT 2026
================
@@ -11048,6 +11048,11 @@ def warn_lifetime_safety_inapplicable_lifetimebound
InGroup<LifetimeSafetyInapplicableLifetimebound>,
DefaultIgnore;
+def warn_lifetime_safety_inapplicable_lifetimebound_return
+ : Warning<"'lifetimebound' attribute has no effect on this function because return type %0 cannot carry a lifetime. The attribute only applies when the return type is a reference type, pointer type, or non-owner record type">,
+ InGroup<LifetimeSafetyInapplicableLifetimebound>,
----------------
usx95 wrote:
I would prefer having a separate sub diaggroup allowing incremental adoption. It can still be under `LifetimeSafetyInapplicableLifetimebound`.
https://github.com/llvm/llvm-project/pull/203767
More information about the cfe-commits
mailing list