summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp9
-rw-r--r--clang/test/Modules/Inputs/DebugCXX.h11
-rw-r--r--clang/test/Modules/ModuleDebugInfo.cpp7
3 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 96752528d71..d609cf2648a 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -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);
diff --git a/clang/test/Modules/Inputs/DebugCXX.h b/clang/test/Modules/Inputs/DebugCXX.h
index 39dda959ce2..2e17a2ecfde 100644
--- a/clang/test/Modules/Inputs/DebugCXX.h
+++ b/clang/test/Modules/Inputs/DebugCXX.h
@@ -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;
+ };
+};
diff --git a/clang/test/Modules/ModuleDebugInfo.cpp b/clang/test/Modules/ModuleDebugInfo.cpp
index 82b558af099..d0e304bb134 100644
--- a/clang/test/Modules/ModuleDebugInfo.cpp
+++ b/clang/test/Modules/ModuleDebugInfo.cpp
@@ -71,6 +71,13 @@
// 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.
OpenPOWER on IntegriCloud