diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -1204,7 +1204,8 @@ // arguments. if (const auto *Spec = dyn_cast(D)) { ArrayRef Args; - if (TypeSourceInfo *TAW = Spec->getTypeAsWritten()) { + TypeSourceInfo *TAW = Spec->getTypeAsWritten(); + if (!Policy.PrintCanonicalTypes && TAW) { const TemplateSpecializationType *TST = cast(TAW->getType()); Args = TST->template_arguments(); 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 @@ -314,7 +314,9 @@ if (isa(RD)) { SmallString<128> Name; llvm::raw_svector_ostream OS(Name); - RD->getNameForDiagnostic(OS, getPrintingPolicy(), + PrintingPolicy PP = getPrintingPolicy(); + PP.PrintCanonicalTypes = true; + RD->getNameForDiagnostic(OS, PP, /*Qualified*/ false); // Copy this name on the side and use its reference. diff --git a/clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp b/clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp --- a/clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp +++ b/clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp @@ -105,7 +105,12 @@ }; extern template class j; j jj; +template +struct j_wrap { +}; +j_wrap> j_wrap_j; // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j" +// CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j_wrap >" template struct k {