r202779 - DebugInfo: Improvements/corrections to conservative emission of types in explicit template instantiation declarations

David Blaikie dblaikie at gmail.com
Mon Mar 3 19:08:14 PST 2014


Author: dblaikie
Date: Mon Mar  3 21:08:14 2014
New Revision: 202779

URL: http://llvm.org/viewvc/llvm-project?rev=202779&view=rev
Log:
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

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=202779&r1=202778&r2=202779&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Mar  3 21:08:14 2014
@@ -1462,7 +1462,8 @@ static bool hasExplicitMemberDefinition(
                                         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;
 }

Modified: cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp?rev=202779&r1=202778&r2=202779&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp Mon Mar  3 21:08:14 2014
@@ -38,7 +38,10 @@ void e<T>::f() {
 }
 extern template class e<int>;
 e<int> ei;
-// CHECK: ; [ DW_TAG_structure_type ] [e<int>] {{.*}} [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<int>] {{.*}} [def]
 
 template <typename T>
 struct f {
@@ -49,11 +52,7 @@ template <typename T>
 void f<T>::g() {
 }
 f<int> fi;
-// Is this right? We don't seem to emit a def for 'f<int>::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<int>] {{.*}} [decl]
+// CHECK: ; [ DW_TAG_structure_type ] [f<int>] {{.*}} [def]
 
 template <typename T>
 struct g {
@@ -70,3 +69,12 @@ struct h {
 };
 template class h<int>;
 // CHECK: ; [ DW_TAG_structure_type ] [h<int>] {{.*}} [def]
+
+template <typename T>
+struct i {
+  void f() {}
+};
+template<> void i<int>::f();
+extern template class i<int>;
+i<int> ii;
+// CHECK: ; [ DW_TAG_structure_type ] [i<int>] {{.*}} [def]





More information about the cfe-commits mailing list