[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:54:24 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:

I would love to find an easier solution for this though.

https://github.com/llvm/llvm-project/pull/203866


More information about the cfe-commits mailing list