[clang] [LifetimeSafety] Avoid suggesting lifetimebound attribute on primary templates declarations (PR #203866)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 15 07:47:33 PDT 2026
================
@@ -82,6 +82,39 @@ class LifetimeChecker {
llvm_unreachable("unhandled causing fact in PointerUnion");
}
+ /// For an explicit specialization, returns the source-level specialization
+ /// declaration to target for attribute placement, if one exists. Skips
+ /// implicit specialization redeclarations that are backed by the template
+ /// pattern. In other cases, returns nullptr.
+ static const FunctionDecl *
+ getExplicitSpecializationDeclForAttr(const FunctionDecl *FDef) {
+ if (FDef->getTemplateSpecializationKindForInstantiation() !=
+ TSK_ExplicitSpecialization)
+ return nullptr;
+
+ auto IsImplicitTemplateSpecialization = [](const FunctionDecl *Redecl,
----------------
Xazax-hun wrote:
Isn't there a better way to check if a function is an implicit specialization (that is not based on the source location)?
https://github.com/llvm/llvm-project/pull/203866
More information about the cfe-commits
mailing list