[clang] [LifetimeSafety] Avoid suggesting lifetimebound attribute on primary templates declarations (PR #203866)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 15 07:53:49 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,
----------------
NeKon69 wrote:
Well, as far as can I see, there is no reliable way to distinguish between clang-generated instantiations and user written ones, that is mostly because they both fall under the same `TSK_ExplicitSpecialization` category..
https://github.com/llvm/llvm-project/pull/203866
More information about the cfe-commits
mailing list