]> granicus.if.org Git - clang/commitdiff
Module Debugging: Defer the emission of anonymous tag decls
authorAdrian Prantl <aprantl@apple.com>
Tue, 19 Jan 2016 18:02:47 +0000 (18:02 +0000)
committerAdrian Prantl <aprantl@apple.com>
Tue, 19 Jan 2016 18:02:47 +0000 (18:02 +0000)
until we are visiting their declcontext.

This fixes a regression introduced in r256962:
When building debug info for a typdef'd anonymous tag type, we would be
visiting the inner anonymous type first thus creating a "typedef changes
linkage of anonymous type, but linkage was already computed" error.

rdar://problem/24199640

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

lib/CodeGen/ObjectFilePCHContainerOperations.cpp
test/Modules/ExtDebugInfo.cpp
test/Modules/Inputs/DebugCXX.h
test/Modules/ModuleDebugInfo.cpp

index f385e53fa01fe1742ab03f301b39b29e47dec94e..2c0c3ca8a90e23dffd2dce257ce7ecc8ca12598b 100644 (file)
@@ -190,6 +190,10 @@ public:
     if (D->isFromASTFile())
       return;
 
+    // Anonymous tag decls are deferred until we are building their declcontext.
+    if (D->getName().empty())
+      return;
+
     DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, false);
     DTV.TraverseDecl(D);
     Builder->UpdateCompletedType(D);
index b255042cbfec4bd5383bd2cd77d40f97a68101a0..b0bca88b89e4273c94e5ab4e0b9a0f6f7e2f3761 100644 (file)
@@ -35,6 +35,10 @@ enum {
 auto anon_enum = DebugCXX::e2;
 char _anchor = anon_enum + conflicting_uid;
 
+TypedefUnion tdu;
+TypedefEnum tde;
+TypedefStruct tds;
+
 // CHECK: ![[NS:.*]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]],
 // CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugCXX
 
@@ -62,6 +66,13 @@ char _anchor = anon_enum + conflicting_uid;
 // CHECK-SAME:             flags: DIFlagFwdDecl,
 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE")
 
+// CHECK: !DICompositeType(tag: DW_TAG_union_type,
+// CHECK-SAME:             flags: DIFlagFwdDecl, identifier: "_ZTS12TypedefUnion")
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
+// CHECK-SAME:             flags: DIFlagFwdDecl, identifier: "_ZTS11TypedefEnum")
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
+// CHECK-SAME:             flags: DIFlagFwdDecl, identifier: "_ZTS13TypedefStruct")
+
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "static_member",
 // CHECK-SAME:           scope: !"_ZTSN8DebugCXX6StructE"
 
index b6a52579fc3a18051a7641257d49a340ff124bd6..285e094171c3d710a72e46c5caa673b5f6153d3a 100644 (file)
@@ -58,3 +58,7 @@ class FwdVirtual {
 };
 
 struct PureForwardDecl;
+
+typedef union { int i; } TypedefUnion;
+typedef enum { e0 = 0 } TypedefEnum;
+typedef struct { int i; } TypedefStruct;
index bbe36cb225d0ab9d2edc45a7858f73caa22266a8..c1248fd4d8eebb7bcc7de1ed39f3415b6aa4c23a 100644 (file)
 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX4EnumE")
 // CHECK: !DINamespace(name: "DebugCXX"
 
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
+// CHECK-SAME-NOT:         name:
+// CHECK-SAME:             identifier: "_ZTS11TypedefEnum")
+
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct"
 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX6StructE")
 
 // CHECK-SAME:             identifier: "_ZTS10FwdVirtual")
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "_vptr$FwdVirtual"
 
+// CHECK: !DICompositeType(tag: DW_TAG_union_type,
+// CHECK-SAME-NOT:         name:
+// CHECK-SAME:             identifier: "_ZTS12TypedefUnion")
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
+// CHECK-SAME-NOT:         name:
+// CHECK-SAME:             identifier: "_ZTS13TypedefStruct")
+
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
 // no mangled name here yet.