[clang] [LifetimeSafety] Warn when lifetimebound attribute is present on the definition but not on declaration (PR #197753)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Mon May 18 04:56:47 PDT 2026
================
@@ -134,6 +136,10 @@ class LifetimeChecker {
if (PVD->hasAttr<LifetimeBoundAttr>()) {
// Track that this lifetimebound parameter correctly escapes.
VerifiedLiftimeboundEscapes.insert(PVD);
+ if (auto [UnannotatedFDecl, Scope] =
+ getUnannotatedDeclBestMatch(cast<FunctionDecl>(FD), PVD);
+ UnannotatedFDecl)
+ DeclarationsToAnnotate.try_emplace(UnannotatedFDecl, Scope);
----------------
usx95 wrote:
This is largely a policy change about where to put the annotation and not about escape analysis itself. I would prefer to do this separately as part of `reportMisplacedLifetimebound` and not `checkAnnotations` (which checks for escape semantics).
https://github.com/llvm/llvm-project/pull/197753
More information about the cfe-commits
mailing list