================
@@ -1332,6 +1332,54 @@ llvm::DIType *CGDebugInfo::CreateType(const 
TemplateSpecializationType *Ty,
   auto PP = getPrintingPolicy();
   Ty->getTemplateName().print(OS, PP, TemplateName::Qualified::None);
 
+  SourceLocation Loc = AliasDecl->getLocation();
+
+  if (CGM.getCodeGenOpts().DebugTemplateAlias) {
+    // TemplateSpecializationType doesn't know if its template args are
+    // being substituted into a parameter pack. We can find out if that's
+    // the case now by inspecting the TypeAliasTemplateDecl template
+    // parameters. Insert Ty's template args into SpecArgs, bundling args
+    // passed to a parameter pack into a TemplateArgument::Pack.
+    SmallVector<TemplateArgument> SpecArgs;
+    {
+      ArrayRef SubstArgs = Ty->template_arguments();
+      for (const NamedDecl *P : TD->getTemplateParameters()->asArray()) {
+        if (P->isParameterPack()) {
+          SpecArgs.push_back(TemplateArgument(SubstArgs));
+          break;
+        }
+        // Skip defaulted args.
+        if (SubstArgs.empty()) {
+          // If SubstArgs is now empty (we're taking from it each iteration) 
and
+          // this template parameter isn't a pack, then that should mean we're
+          // using default values for the remaining template parameters.
+          break;
----------------
Michael137 wrote:

Ah I see, thanks for clarifying! Just thought I'd point it out in case this 
wasn't expected. The DWARF spec has this to say about the template parameters 
of an alias:
```
The template alias entry has child entries describing the template actual 
parameters (see Section 2.23 on page 57).
```
Which to me implies that the parameters of an alias instantiation follow the 
same rules as those for class template instantiations.

Regarding name reconstruction, defaulted template arguments should have their 
`IsDefaulted` bit set, so when reconstructing the name we should be able to 
drop defaulted arguments? If that's too much of a hassle maybe not emitting 
them at all as you do now is also fine?

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

Reply via email to