From: Devang Patel Date: Wed, 2 Feb 2011 21:38:49 +0000 (+0000) Subject: Emit debug info for template type parameters. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa275dfad7c4eb053ffef423a863afbe15534476;p=clang Emit debug info for template type parameters. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124753 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index a98c32a8d0..c4a6d570f2 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -953,9 +953,23 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty) { } CollectRecordFields(RD, Unit, EltTys); + llvm::SmallVector TemplateParams; if (CXXDecl) { CollectCXXMemberFunctions(CXXDecl, Unit, EltTys, FwdDecl); CollectCXXFriends(CXXDecl, Unit, EltTys, FwdDecl); + if (ClassTemplateSpecializationDecl *TSpecial + = dyn_cast(RD)) { + const TemplateArgumentList &TAL = TSpecial->getTemplateArgs(); + for (unsigned i = 0, e = TAL.size(); i != e; ++i) { + const TemplateArgument &TA = TAL[i]; + if (TA.getKind() == TemplateArgument::Type) { + llvm::DIType TTy = getOrCreateType(TA.getAsType(), Unit); + llvm::DITemplateTypeParameter TTP = + DBuilder.CreateTemplateTypeParameter(TheCU, TTy.getName(), TTy); + TemplateParams.push_back(TTP); + } + } + } } RegionStack.pop_back(); @@ -1000,9 +1014,12 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty) { } else if (CXXDecl->isDynamicClass()) ContainingType = FwdDecl; + llvm::DIArray TParamsArray = + DBuilder.GetOrCreateArray(TemplateParams.data(), TemplateParams.size()); RealDecl = DBuilder.CreateClassType(RDContext, RDName, DefUnit, Line, Size, Align, 0, 0, llvm::DIType(), - Elements, ContainingType); + Elements, ContainingType, + TParamsArray); } // Now that we have a real decl for the struct, replace anything using the diff --git a/test/CodeGenCXX/debug-info-template.cpp b/test/CodeGenCXX/debug-info-template.cpp index 233090c049..3fbfebf915 100644 --- a/test/CodeGenCXX/debug-info-template.cpp +++ b/test/CodeGenCXX/debug-info-template.cpp @@ -1,4 +1,8 @@ -// RUN: %clang_cc1 -emit-llvm-only -g -S %s -o - | grep "TC" +// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s + +//CHECK: TC +//CHECK: DW_TAG_template_type_parameter + template class TC { public: