[clang] Fix scope of typedefs present inside a template class (PR #146729)

via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 14 13:19:18 PDT 2025


================
@@ -4189,8 +4189,13 @@ llvm::DICompositeType *CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
         llvm::MDNode::replaceWithDistinct(llvm::TempDICompositeType(RealDecl));
     break;
   }
-
-  RegionMap[Ty->getDecl()].reset(RealDecl);
+  if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Ty->getDecl())) {
+    CXXRecordDecl *TemplateDecl =
+        CTSD->getSpecializedTemplate()->getTemplatedDecl();
+    RegionMap[TemplateDecl].reset(RealDecl);
+  } else {
+    RegionMap[Ty->getDecl()].reset(RealDecl);
+  }
----------------
ykhatav wrote:

Yeah, I am not sure why, but the `getTemplateInstantiationPattern` also returns null in this case. 

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


More information about the cfe-commits mailing list