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

Steve Merritt via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 9 10:28:19 PDT 2025


================
@@ -4170,9 +4170,16 @@ llvm::DICompositeType *CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
         llvm::MDNode::replaceWithDistinct(llvm::TempDICompositeType(RealDecl));
     break;
   }
-
-  RegionMap[Ty->getDecl()].reset(RealDecl);
-  TypeCache[QualType(Ty, 0).getAsOpaquePtr()].reset(RealDecl);
+  auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Ty->getDecl());
+  if (CTSD) {
+    CXXRecordDecl *TemplateDecl =
+        CTSD->getSpecializedTemplate()->getTemplatedDecl();
+    RegionMap[TemplateDecl].reset(RealDecl);
+    TypeCache[QualType(Ty, 0).getAsOpaquePtr()].reset(RealDecl);
----------------
stevemerr wrote:

This line is present in both blocks, so it should be pulled out of the if-else.  

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


More information about the cfe-commits mailing list