[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:34 PDT 2026
https://github.com/usx95 requested changes to this pull request.
I do not think we can extend the current check to return types. In fact, we need to be quite permissive for these. This is the reason why we have `LifetimeAnnotatedOriginTypeCollector`.
Currently this change will suggest lifetimebound on some constructors (with escaping fields) but adding that annotation would go against the current policy (see `LifetimeBoundCtor` test; `SWithUserDefinedCopyLikeOps` ctor is also correctly annotated).
The purpose of the bug is to only reject clearly wrong types like builtin types `int getInt(const std::string &s [[clang::lifetimebound]]);`
https://github.com/llvm/llvm-project/pull/203767
More information about the cfe-commits
mailing list