[clang] [LifetimeSafety] Merge lifetimebound attribute on implicit 'this' across method redeclarations (PR #172146)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 13 04:41:45 PST 2025
================
@@ -4469,6 +4469,52 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S,
return true;
}
+/// Check if a function has a lifetimebound attribute on its function type
+/// (which represents the implicit 'this' parameter for methods).
+/// Returns the attribute if found, nullptr otherwise.
+static const LifetimeBoundAttr *
+getLifetimeBoundAttrFromType(const TypeSourceInfo *TSI) {
+ if (!TSI)
+ return nullptr;
+
+ for (TypeLoc TL = TSI->getTypeLoc();;) {
+ auto ATL = TL.getAsAdjusted<AttributedTypeLoc>();
+ if (!ATL)
+ break;
+ if (auto *LBAttr = ATL.getAttrAs<LifetimeBoundAttr>())
+ return LBAttr;
+ TL = ATL.getModifiedLoc();
+ }
----------------
cor3ntin wrote:
This might be a bit too clever - I'd prefer a while(true) with a comment
https://github.com/llvm/llvm-project/pull/172146
More information about the cfe-commits
mailing list