r375304 - DebugInfo: Render the canonical name of a class template specialization, even when nested in another class template specialization

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 18 16:58:34 PDT 2019


Author: dblaikie
Date: Fri Oct 18 16:58:34 2019
New Revision: 375304

URL: http://llvm.org/viewvc/llvm-project?rev=375304&view=rev
Log:
DebugInfo: Render the canonical name of a class template specialization, even when nested in another class template specialization

Differential Revision: https://reviews.llvm.org/D63031

Modified:
    cfe/trunk/lib/AST/TypePrinter.cpp
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=375304&r1=375303&r2=375304&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Fri Oct 18 16:58:34 2019
@@ -1204,7 +1204,8 @@ void TypePrinter::printTag(TagDecl *D, r
   // arguments.
   if (const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
     ArrayRef<TemplateArgument> Args;
-    if (TypeSourceInfo *TAW = Spec->getTypeAsWritten()) {
+    TypeSourceInfo *TAW = Spec->getTypeAsWritten();
+    if (!Policy.PrintCanonicalTypes && TAW) {
       const TemplateSpecializationType *TST =
         cast<TemplateSpecializationType>(TAW->getType());
       Args = TST->template_arguments();

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=375304&r1=375303&r2=375304&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Oct 18 16:58:34 2019
@@ -314,7 +314,9 @@ StringRef CGDebugInfo::getClassName(cons
   if (isa<ClassTemplateSpecializationDecl>(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.

Modified: cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp?rev=375304&r1=375303&r2=375304&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp Fri Oct 18 16:58:34 2019
@@ -105,7 +105,12 @@ struct j {
 };
 extern template class j<int>;
 j<int> jj;
+template <typename T>
+struct j_wrap {
+};
+j_wrap<j<int>> j_wrap_j;
 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j<int, int>"
+// CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j_wrap<j<int, int> >"
 
 template <typename T>
 struct k {




More information about the cfe-commits mailing list