]> granicus.if.org Git - clang/commitdiff
Module Debugging: Don't emit external type references to anonymous types.
authorAdrian Prantl <aprantl@apple.com>
Tue, 19 Jan 2016 23:42:53 +0000 (23:42 +0000)
committerAdrian Prantl <aprantl@apple.com>
Tue, 19 Jan 2016 23:42:53 +0000 (23:42 +0000)
Even if they exist in the module, they can't be matched with the forward
declaration in the object file.
<rdar://problem/24199640>

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

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

index 2511b249f0f57f9ecaaac416f2d32ff8bd8b5fba..fa501fce756c1dfbb5e004daf8240fa646cb375d 100644 (file)
@@ -1536,8 +1536,9 @@ static bool shouldOmitDefinition(CodeGenOptions::DebugInfoKind DebugKind,
                                  const RecordDecl *RD,
                                  const LangOptions &LangOpts) {
   // Does the type exist in an imported clang module?
-  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition())
-      return true;
+  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition() &&
+      RD->isExternallyVisible())
+    return true;
 
   if (DebugKind > CodeGenOptions::LimitedDebugInfo)
     return false;
index 6c5bd559fc99430072ec6d6f3e982fc50d462884..101b0f1e16b2937375b990f528afa3dd97b37541 100644 (file)
@@ -84,4 +84,13 @@ void foo() {
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
 // CHECK-SAME:             line: 16
 
+// CHECK: !DIGlobalVariable(name: "GlobalUnion",
+// CHECK-SAME:              type: ![[GLOBAL_UNION:[0-9]+]]
+// CHECK: ![[GLOBAL_UNION]] = !DICompositeType(tag: DW_TAG_union_type,
+// CHECK-SAME:                elements: !{{[0-9]+}})
+// CHECK: !DIGlobalVariable(name: "GlobalStruct",
+// CHECK-SAME:              type: ![[GLOBAL_STRUCT:[0-9]+]]
+// CHECK: ![[GLOBAL_STRUCT]] = !DICompositeType(tag: DW_TAG_structure_type,
+// CHECK-SAME:                elements: !{{[0-9]+}})
+
 // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !"_ZTSN8DebugCXX6StructE", line: 24)