[clang] [LifetimeSafety] Warn on inapplicable `[[clang::lifetimebound]]` when return type can not carry a lifetime (PR #203767)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 28 04:15:20 PDT 2026
================
@@ -631,8 +631,16 @@ This warning may produce false-positives diagnostics when it cannot fully model
}];
}
+def LifetimeSafetyInapplicableLifetimeboundReturn
+ : DiagGroup<"lifetime-safety-inapplicable-lifetimebound-return"> {
+ code Documentation = [{
+Detects uses of [[clang::lifetimebound]] that have no effect because the function return type cannot carry a lifetime.
----------------
Xazax-hun wrote:
I guess this is not entirely true. We might have some code paths that make these types carry lifetimes locally. That being said, this diagnostic is a telltale sign that either a type misses an annotation or a lifetimebound annotation is incorrect. I wonder if the diagnostic message should be formulated like that.
https://github.com/llvm/llvm-project/pull/203767
More information about the cfe-commits
mailing list