[clang] [LifetimeSafety] Merge lifetimebound attribute on implicit 'this' across method redeclarations (PR #172146)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 15 03:06:03 PST 2025
================
@@ -4485,12 +4532,17 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old,
// Merge attributes from the parameters. These can mismatch with K&R
// declarations.
if (New->getNumParams() == Old->getNumParams())
- for (unsigned i = 0, e = New->getNumParams(); i != e; ++i) {
- ParmVarDecl *NewParam = New->getParamDecl(i);
- ParmVarDecl *OldParam = Old->getParamDecl(i);
- mergeParamDeclAttributes(NewParam, OldParam, *this);
- mergeParamDeclTypes(NewParam, OldParam, *this);
- }
+ for (unsigned i = 0, e = New->getNumParams(); i != e; ++i) {
+ ParmVarDecl *NewParam = New->getParamDecl(i);
+ ParmVarDecl *OldParam = Old->getParamDecl(i);
+ mergeParamDeclAttributes(NewParam, OldParam, *this);
+ mergeParamDeclTypes(NewParam, OldParam, *this);
+ }
+
+ // Merge function type attributes (e.g., lifetimebound on implicit 'this').
+ if (auto *NewMethod = dyn_cast<CXXMethodDecl>(New))
+ if (auto *OldMethod = dyn_cast<CXXMethodDecl>(Old))
----------------
Xazax-hun wrote:
Is it possible for the old to not be a `CXXMethodDecl` when the new is already one? Should this be a `cast` instead?
https://github.com/llvm/llvm-project/pull/172146
More information about the cfe-commits
mailing list