]> granicus.if.org Git - clang/commitdiff
Module debugging: Use the definition to determine module-defined types.
authorAdrian Prantl <aprantl@apple.com>
Tue, 26 Apr 2016 21:58:18 +0000 (21:58 +0000)
committerAdrian Prantl <aprantl@apple.com>
Tue, 26 Apr 2016 21:58:18 +0000 (21:58 +0000)
Follow-up to r267464. Thanks to Richard Smith for pointing this out!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267611 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/Modules/ExtDebugInfo.cpp

index 0050b78f04bb23f815a4394d8706caf146779310..e275f060dfd3bfd6fecfefba85dbdcfef01ce0fb 100644 (file)
@@ -1516,9 +1516,7 @@ static bool hasExplicitMemberDefinition(CXXRecordDecl::method_iterator I,
 
 /// Does a type definition exist in an imported clang module?
 static bool isDefinedInClangModule(const RecordDecl *RD) {
-  if (!RD->isFromASTFile())
-    return false;
-  if (!RD->getDefinition())
+  if (!RD || !RD->isFromASTFile())
     return false;
   if (!RD->isExternallyVisible() && RD->getName().empty())
     return false;
@@ -1535,7 +1533,7 @@ static bool isDefinedInClangModule(const RecordDecl *RD) {
 static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
                                  bool DebugTypeExtRefs, const RecordDecl *RD,
                                  const LangOptions &LangOpts) {
-  if (DebugTypeExtRefs && isDefinedInClangModule(RD))
+  if (DebugTypeExtRefs && isDefinedInClangModule(RD->getDefinition()))
     return true;
 
   if (DebugKind > codegenoptions::LimitedDebugInfo)
index cefb21eba2a0cca7aa48e2e96e23dd441003cc2e..e16d5a85f28a1fdbf6c81161e0bef7bbf18617f4 100644 (file)
@@ -51,6 +51,10 @@ TypedefFwdDeclTemplate tdfdt;
 
 InAnonymousNamespace anon;
 
+// Forward-declared in the module.
+struct PureFwdDecl { int i; };
+PureFwdDecl definedLocally;
+
 void foo() {
   anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
 }
@@ -133,6 +137,11 @@ void foo() {
 // CHECK-SAME:             templateParams:
 // CHECK-SAME:             identifier: "_ZTS15FwdDeclTemplateIiE")
 
+// This type is defined locally and forward-declare in the module.
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "PureFwdDecl",
+// CHECK-SAME:             elements:
+// CHECK-SAME:             identifier: "_ZTS11PureFwdDecl")
+
 // CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: ![[ANON_ENUM:[0-9]+]]
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
 // CHECK-SAME:             line: 16