diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2091,12 +2091,18 @@ TheCU, Name, TTy, defaultParameter, V)); } break; case TemplateArgument::Template: { + if (Args.TList) { + NamedDecl const *ND = Args.TList->getParam(i); + defaultParameter = TemplateUtils::isSubstitutedDefaultArgument( + CGM.getContext(), TA, ND, Args.Args, Args.TList->getDepth()); + } + std::string QualName; llvm::raw_string_ostream OS(QualName); TA.getAsTemplate().getAsTemplateDecl()->printQualifiedName( OS, getPrintingPolicy()); TemplateParams.push_back(DBuilder.createTemplateTemplateParameter( - TheCU, Name, nullptr, OS.str())); + TheCU, Name, nullptr, OS.str(), defaultParameter)); break; } case TemplateArgument::Pack: diff --git a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp --- a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp +++ b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp @@ -22,17 +22,37 @@ // CXX17: [[THIRD]] = !DITemplateValueParameter(name: "b", type: !{{[0-9]*}}, defaulted: true, value: i1 true) // CHECK: [[FIFTH]] = !DITemplateTypeParameter(name: "d", type: !{{[0-9]*}}, defaulted: true) +// CHECK: DILocalVariable(name: "b1", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]] +// CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: ![[B1_TYPE:[0-9]+]] +// CHECK: [[B1_TYPE]] = !{![[FIRST:[0-9]+]]} +// CHECK: [[FIRST]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_template_param, name: "CT", value: !"qux") + +// CHECK: DILocalVariable(name: "b2", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]] +// CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: ![[B2_TYPE:[0-9]+]] +// CHECK: [[B2_TYPE]] = !{![[FIRST:[0-9]+]]} +// CHECK: [[FIRST]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_template_param, name: "CT", defaulted: true, value: !"bar") + template class bar { }; +template +class qux { +}; + template > class foo { }; +template