================
@@ -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);
+  }
----------------
mizvekov wrote:

I am just explaining the rules and limitations of the AST, and why you can't 
just grab the class instantiation from a non-dependent typedef.

If you do what's in this patch, you get weird debug info, pointing to a 
template instead of an instantiation.
I think the change might not be enough for this approach, you could add a test 
for a typedef inside a class template partial specialization as well.

The other approach would be to fix these typedefs so their parent is set 
correctly to the instantiation. This might have some performance impact, but no 
one is going to figure out by how much of we don't get data; it might not be a 
lot.

I am not an expert in debug info though, so I won't press an opinion on how 
acceptable this workaround is.

https://github.com/llvm/llvm-project/pull/146729
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to