aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp19
-rw-r--r--test/CodeGenCXX/debug-info-template.cpp6
2 files changed, 23 insertions, 2 deletions
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<llvm::Value *, 16> TemplateParams;
if (CXXDecl) {
CollectCXXMemberFunctions(CXXDecl, Unit, EltTys, FwdDecl);
CollectCXXFriends(CXXDecl, Unit, EltTys, FwdDecl);
+ if (ClassTemplateSpecializationDecl *TSpecial
+ = dyn_cast<ClassTemplateSpecializationDecl>(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<int>"
+// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s
+
+//CHECK: TC<int>
+//CHECK: DW_TAG_template_type_parameter
+
template<typename T>
class TC {
public: