]> granicus.if.org Git - clang/commitdiff
Module Debugging: Fix a crash when emitting debug info for nested tag types
authorAdrian Prantl <aprantl@apple.com>
Mon, 7 Mar 2016 20:58:52 +0000 (20:58 +0000)
committerAdrian Prantl <aprantl@apple.com>
Mon, 7 Mar 2016 20:58:52 +0000 (20:58 +0000)
whose DeclContext is not yet complete by deferring their emission.

rdar://problem/24918680

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

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

index 96752528d7105fc46c87aedcf4a2c3292c0d5201..d609cf2648ae1d8f19fbee2ac3c0aaafaccbda86 100644 (file)
@@ -201,6 +201,15 @@ public:
     if (D->getName().empty())
       return;
 
+    // Defer tag decls until their declcontext is complete.
+    auto *DeclCtx = D->getDeclContext();
+    while (DeclCtx) {
+      if (auto *D = dyn_cast<TagDecl>(DeclCtx))
+        if (!D->isCompleteDefinition())
+          return;
+      DeclCtx = DeclCtx->getParent();
+    }
+
     DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);
     DTV.TraverseDecl(D);
     Builder->UpdateCompletedType(D);
index 39dda959ce2f13a0485d442f30e06e43c3de8249..2e17a2ecfde9a2ab370863383db78c5e185564ab 100644 (file)
@@ -72,3 +72,14 @@ namespace {
     struct InAnonymousNamespace { int i; };
   }
 }
+
+class Base;
+class A {
+  virtual Base *getParent() const;
+};
+class Base {};
+class Derived : Base {
+  class B : A {
+    Derived *getParent() const override;
+  };
+};
index 82b558af099112ae170408c149a89a0c481574e3..d0e304bb134c2f1263c9567d742ee6f85d670739 100644 (file)
 // CHECK-NOT:              name:
 // CHECK-SAME:             identifier: "_ZTS13TypedefStruct")
 
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Derived",
+// CHECK-SAME:             identifier: "_ZTS7Derived")
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "B", scope: !"_ZTS7Derived",
+// CHECK-SAME:             elements: ![[B_MBRS:.*]], vtableHolder: !"_ZTS1A"
+// CHECK: ![[B_MBRS]] = !{{{.*}}, ![[GET_PARENT:.*]]}
+// CHECK: ![[GET_PARENT]] = !DISubprogram(name: "getParent"
+
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
 // no mangled name here yet.