From 9db62af77a0fe049a533f53a92bf1c9e2d267050 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 4 Mar 2014 03:08:14 +0000 Subject: [PATCH] DebugInfo: Improvements/corrections to conservative emission of types in explicit template instantiation declarations * detect out of line definitions correctly * detect member function explicit specializations correctly git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202779 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 3 ++- ...-info-template-explicit-specialization.cpp | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 6c24e8f865..35bd57a053 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1462,7 +1462,8 @@ static bool hasExplicitMemberDefinition(CXXRecordDecl::method_iterator I, CXXRecordDecl::method_iterator End) { for (; I != End; ++I) if (FunctionDecl *Tmpl = I->getInstantiatedFromMemberFunction()) - if (!Tmpl->isImplicit() && Tmpl->hasBody()) + if (!Tmpl->isImplicit() && Tmpl->isThisDeclarationADefinition() && + !I->getMemberSpecializationInfo()->isExplicitSpecialization()) return true; return false; } diff --git a/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp b/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp index 6dfffb6114..86380392a2 100644 --- a/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp +++ b/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp @@ -38,7 +38,10 @@ void e::f() { } extern template class e; e ei; -// CHECK: ; [ DW_TAG_structure_type ] [e] {{.*}} [decl] +// There's no guarantee that the out of line definition will appear before the +// explicit template instantiation definition, so conservatively emit the type +// definition here. +// CHECK: ; [ DW_TAG_structure_type ] [e] {{.*}} [def] template struct f { @@ -49,11 +52,7 @@ template void f::g() { } f fi; -// Is this right? We don't seem to emit a def for 'f::g' (even if it is -// called in this translation unit) so I guess if we're relying on its -// definition to be wherever the explicit instantiation definition is, we can do -// the same for the debug info. -// CHECK: ; [ DW_TAG_structure_type ] [f] {{.*}} [decl] +// CHECK: ; [ DW_TAG_structure_type ] [f] {{.*}} [def] template struct g { @@ -70,3 +69,12 @@ struct h { }; template class h; // CHECK: ; [ DW_TAG_structure_type ] [h] {{.*}} [def] + +template +struct i { + void f() {} +}; +template<> void i::f(); +extern template class i; +i ii; +// CHECK: ; [ DW_TAG_structure_type ] [i] {{.*}} [def] -- 2.40.0