From: David Blaikie Date: Wed, 28 Aug 2013 23:06:52 +0000 (+0000) Subject: DebugInfo: Further fix/improvements to r189494 (and LLVM r189495). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=11fa7518cb2cf92db977ccc15f0db97307eac58c;p=clang DebugInfo: Further fix/improvements to r189494 (and LLVM r189495). Selfhosting was crashing with the same type of problem but involving template specializations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189530 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 42e648d79c..e7d70660f6 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1140,6 +1140,16 @@ CollectCXXMemberFunctions(const CXXRecordDecl *RD, llvm::DIFile Unit, EltTys.push_back(CreateCXXMemberFunction(Method, Unit, RecordTy)); } else EltTys.push_back(MI->second); + } else if (const FunctionTemplateDecl *FTD = dyn_cast(*I)) { + // Add any template specializations that have already been seen. Like + // implicit member functions, these may have been added to a declaration + // in the case of vtable-based debug info reduction. + for (FunctionTemplateDecl::spec_iterator SI = FTD->spec_begin(), SE = FTD->spec_end(); SI != SE; ++SI) { + llvm::DenseMap::iterator MI = + SPCache.find(cast(*SI)->getCanonicalDecl()); + if (MI != SPCache.end()) + EltTys.push_back(MI->second); + } } } } diff --git a/test/CodeGenCXX/debug-info-template-member.cpp b/test/CodeGenCXX/debug-info-template-member.cpp index cb9922cc1f..afca2ac96a 100644 --- a/test/CodeGenCXX/debug-info-template-member.cpp +++ b/test/CodeGenCXX/debug-info-template-member.cpp @@ -4,6 +4,8 @@ struct MyClass { template int add(int j) { return i + j; } + virtual void func() { + } }; int add2(int x) { @@ -14,9 +16,12 @@ inline int add3(int x) { return MyClass().add<3>(x); // even though add<3> is ODR used, don't emit it since we don't codegen it } -// CHECK: metadata [[C_MEM:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_structure_type ] [MyClass] -// CHECK: [[C_MEM]] = metadata !{metadata [[C_TEMP:![0-9]*]]} -// CHECK: [[C_TEMP]] = {{.*}} ; [ DW_TAG_subprogram ] [line 4] [add<2>] +// CHECK: [[C:![0-9]*]] = {{.*}}, metadata [[C_MEM:![0-9]*]], i32 0, metadata [[C]], null, null} ; [ DW_TAG_structure_type ] [MyClass] +// CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata [[C_ADD:![0-9]*]], metadata [[C_FUNC:![0-9]*]], metadata [[C_CTOR:![0-9]*]]} +// CHECK: [[C_VPTR]] = {{.*}} ; [ DW_TAG_member ] [_vptr$MyClass] +// CHECK: [[C_ADD]] = {{.*}} ; [ DW_TAG_subprogram ] [line 4] [add<2>] +// CHECK: [[C_FUNC]] = {{.*}} ; [ DW_TAG_subprogram ] [line 7] [func] +// CHECK: [[C_CTOR]] = {{.*}} ; [ DW_TAG_subprogram ] [line 0] [MyClass] template struct outer {