r267630 - Module debugging: Also correctly handle typedef'd foward-declared members.

Adrian Prantl via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 26 16:37:38 PDT 2016


Author: adrian
Date: Tue Apr 26 18:37:38 2016
New Revision: 267630

URL: http://llvm.org/viewvc/llvm-project?rev=267630&view=rev
Log:
Module debugging: Also correctly handle typedef'd foward-declared members.
Thanks again to Richard Smith for pointing this out.

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/test/Modules/ExtDebugInfo.cpp
    cfe/trunk/test/Modules/Inputs/DebugCXX.h
    cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=267630&r1=267629&r2=267630&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Apr 26 18:37:38 2016
@@ -1520,13 +1520,12 @@ static bool isDefinedInClangModule(const
     return false;
   if (!RD->isExternallyVisible() && RD->getName().empty())
     return false;
-  if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
-    if (!CTSD->isCompleteDefinition())
-      return false;
-    // Make sure the instantiation is actually in a module.
-    if (CTSD->field_begin() != CTSD->field_end())
-      return CTSD->field_begin()->isFromASTFile();
-  }
+  if (auto *CXXDecl = dyn_cast<CXXRecordDecl>(RD))
+    if (CXXDecl->getTemplateSpecializationKind() != TSK_Undeclared)
+      // Make sure the instantiation is actually in a module.
+      if (CXXDecl->field_begin() != CXXDecl->field_end())
+        return CXXDecl->field_begin()->isFromASTFile();
+
   return true;
 }
 

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=267630&r1=267629&r2=267630&view=diff
==============================================================================
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Tue Apr 26 18:37:38 2016
@@ -28,6 +28,8 @@ using DebugCXX::Struct;
 
 Struct s;
 DebugCXX::Enum e;
+
+// Template instantiations.
 DebugCXX::Template<long> implicitTemplate;
 DebugCXX::Template<int> explicitTemplate;
 DebugCXX::FloatInstantiation typedefTemplate;
@@ -51,13 +53,16 @@ TypedefFwdDeclTemplate tdfdt;
 
 InAnonymousNamespace anon;
 
-// Forward-declared in the module.
+// Types that are forward-declared in the module and defined here.
 struct PureFwdDecl { int i; };
 PureFwdDecl definedLocally;
 
 struct Specialized<int>::Member { int i; };
 struct Specialized<int>::Member definedLocally2;
 
+template <class T> struct FwdDeclTemplateMember<T>::Member { T t; };
+TypedefFwdDeclTemplateMember tdfdtm;
+
 void foo() {
   anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
 }
@@ -150,6 +155,12 @@ void foo() {
 // CHECK-SAME:             elements:
 // CHECK-SAME:             identifier: "_ZTSN11SpecializedIiE6MemberE")
 
+// This type is defined locally and forward-declared in the module.
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member",
+// CHECK-SAME:             elements:
+// CHECK-SAME:             identifier: "_ZTSN21FwdDeclTemplateMemberIiE6MemberE")
+
+
 // CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: ![[ANON_ENUM:[0-9]+]]
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
 // CHECK-SAME:             line: 16

Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=267630&r1=267629&r2=267630&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
+++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Tue Apr 26 18:37:38 2016
@@ -97,10 +97,11 @@ template <class T> class FwdDeclTemplate
 typedef FwdDeclTemplate<int> TypedefFwdDeclTemplate;
 
 // Member classes of class template specializations.
-template <typename T> struct Specialized {
-};
+template <typename T> struct Specialized {};
 
-template <> struct Specialized<int> { 
-struct Member;// { int i; };
+template <> struct Specialized<int> {
+  struct Member;
 };
 
+template <class T> struct FwdDeclTemplateMember { struct Member; };
+typedef FwdDeclTemplateMember<int>::Member TypedefFwdDeclTemplateMember;

Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=267630&r1=267629&r2=267630&view=diff
==============================================================================
--- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Tue Apr 26 18:37:38 2016
@@ -130,5 +130,9 @@
 // CHECK-SAME:             flags: DIFlagFwdDecl
 // CHECK-SAME:             identifier: "_ZTS15FwdDeclTemplateIiE")
 
+// Forward-declared member of a template.
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member",
+// CHECK-SAME:             flags: DIFlagFwdDecl
+// CHECK-SAME:             identifier: "_ZTSN21FwdDeclTemplateMemberIiE6MemberE")
 
 // CHECK-NEG-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "PureForwardDecl"




More information about the cfe-commits mailing list