[clang] [clang] Check specialization for annotation (PR #117315)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 25 01:39:28 PST 2024


================
@@ -253,9 +253,12 @@ static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
                                                   LocalVisitor Visit);
 
 template <typename T> static bool isRecordWithAttr(QualType Type) {
-  if (auto *RD = Type->getAsCXXRecordDecl())
-    return RD->hasAttr<T>();
-  return false;
+  auto *RD = Type->getAsCXXRecordDecl();
+  if (!RD)
+    return false;
+  if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
+    RD = CTSD->getSpecializedTemplate()->getTemplatedDecl();
----------------
hokein wrote:

It would be nice if we have a testcase for this.

I think we should find a way to reuse the `isPointerLikeType`, we have two duplicated version in clang now. (perhaps move it to `Sema.h`)

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


More information about the cfe-commits mailing list