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

Michael Buch via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 6 01:06:04 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);
+  }
----------------
Michael137 wrote:

I'd still like to understand if there is a way for us to grab the `ClassTemplateSpecializationDecl` from the non-template dependent `TypedefDecl`. @AaronBallman any idea if that's possible? Specifically my comments [here](https://github.com/llvm/llvm-project/pull/146729#pullrequestreview-3019468533) and [here](https://github.com/llvm/llvm-project/pull/146729#issuecomment-3072970267)

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


More information about the cfe-commits mailing list