From: David Blaikie Date: Thu, 1 Aug 2013 20:31:40 +0000 (+0000) Subject: DebugInfo: Emit template arguments for limited types used for context. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8058833e12dd9cd38107f6dde3d5a17021ad3a5d;p=clang DebugInfo: Emit template arguments for limited types used for context. We emit definitions with no members when a nested type is referenced/required (GCC does the same, to be fair) but failed to attach the template arguments in such a case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187608 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 8267d4449a..0e3b98d90e 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1473,20 +1473,16 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, bool Declaration) { // Collect data fields (including static variables and any initializers). CollectRecordFields(RD, DefUnit, EltTys, FwdDecl); - llvm::DIArray TParamsArray; if (CXXDecl) { CollectCXXMemberFunctions(CXXDecl, DefUnit, EltTys, FwdDecl); CollectCXXFriends(CXXDecl, DefUnit, EltTys, FwdDecl); - if (const ClassTemplateSpecializationDecl *TSpecial - = dyn_cast(RD)) - TParamsArray = CollectCXXTemplateParams(TSpecial, DefUnit); } LexicalBlockStack.pop_back(); RegionMap.erase(Ty->getDecl()); llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys); - FwdDecl.setTypeArray(Elements, TParamsArray); + FwdDecl.setTypeArray(Elements); RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDecl); return FwdDecl; @@ -2247,6 +2243,10 @@ llvm::DIType CGDebugInfo::CreateLimitedType(const RecordType *Ty) { ContainingType = RealDecl; RealDecl.setContainingType(ContainingType); + if (const ClassTemplateSpecializationDecl *TSpecial = + dyn_cast(CXXDecl)) + RealDecl.setTypeArray(llvm::DIArray(), + CollectCXXTemplateParams(TSpecial, DefUnit)); } return llvm::DIType(RealDecl); } diff --git a/test/CodeGenCXX/debug-info-template.cpp b/test/CodeGenCXX/debug-info-template.cpp index da58f9e6c8..596178d4e3 100644 --- a/test/CodeGenCXX/debug-info-template.cpp +++ b/test/CodeGenCXX/debug-info-template.cpp @@ -4,8 +4,9 @@ // CHECK: [[INT:![0-9]*]] = {{.*}} ; [ DW_TAG_base_type ] [int] -// CHECK: metadata [[TCI:![0-9]*]], i32 0, i32 1, %class.TC* @tci, null} ; [ DW_TAG_variable ] [tci] -// CHECK: [[TC:![0-9]*]] = {{.*}}, metadata [[TCARGS:![0-9]*]]} ; [ DW_TAG_class_type ] [TC] +// CHECK: metadata [[TCNESTED:![0-9]*]], i32 0, i32 1, %"struct.TC::nested"* @tci, null} ; [ DW_TAG_variable ] [tci] +// CHECK: [[TCNESTED]] = metadata !{i32 {{[0-9]*}}, metadata !{{[0-9]*}}, metadata [[TC:![0-9]*]], {{.*}} ; [ DW_TAG_structure_type ] [nested] +// CHECK: [[TC]] = {{.*}}, metadata [[TCARGS:![0-9]*]]} ; [ DW_TAG_structure_type ] [TC] // CHECK: [[TCARGS]] = metadata !{metadata [[TCARG1:![0-9]*]], metadata [[TCARG2:![0-9]*]], metadata [[TCARG3:![0-9]*]], metadata [[TCARG4:![0-9]*]], metadata [[TCARG5:![0-9]*]], metadata [[TCARG6:![0-9]*]], metadata [[TCARG7:![0-9]*]], metadata [[TCARG8:![0-9]*]]} // // We seem to be missing file/line/col info on template value parameters - @@ -47,8 +48,8 @@ // CHECK: [[TCARG8_3]] = {{.*}}metadata !"", metadata [[INT]], i32 3, {{.*}} ; [ DW_TAG_template_value_parameter ] -// CHECK: metadata [[TCNT:![0-9]*]], i32 0, i32 1, %class.TC.0* @tcn, null} ; [ DW_TAG_variable ] [tcn] -// CHECK: [[TCNT:![0-9]*]] = {{.*}}, metadata [[TCNARGS:![0-9]*]]} ; [ DW_TAG_class_type ] [TC] +// CHECK: metadata [[TCNT:![0-9]*]], i32 0, i32 1, %struct.TC* @tcn, null} ; [ DW_TAG_variable ] [tcn] +// CHECK: [[TCNT:![0-9]*]] = {{.*}}, metadata [[TCNARGS:![0-9]*]]} ; [ DW_TAG_structure_type ] [TC] // CHECK: [[TCNARGS]] = metadata !{metadata [[TCNARG1:![0-9]*]], metadata [[TCNARG2:![0-9]*]], metadata [[TCNARG3:![0-9]*]], metadata [[TCNARG4:![0-9]*]], metadata [[TCNARG5:![0-9]*]], metadata [[TCNARG6:![0-9]*]], metadata [[TCARG7:![0-9]*]], metadata [[TCNARG8:![0-9]*]]} // CHECK: [[TCNARG1]] = {{.*}}metadata !"T", metadata [[INT]], {{.*}} ; [ DW_TAG_template_type_parameter ] // CHECK: [[TCNARG2]] = {{.*}}metadata !"", metadata [[INT]], i32 -3, {{.*}} ; [ DW_TAG_template_value_parameter ] @@ -75,7 +76,9 @@ struct foo { }; template class tmpl, int ...Is> -class TC { +struct TC { + struct nested { + }; }; int glb; @@ -85,5 +88,5 @@ template struct tmpl_impl { }; -TC tci; +TC::nested tci; TC tcn;