From 5a9a42778ab565913b6c1b66c4e15cfa80b7a610 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 7 Mar 2016 20:58:52 +0000 Subject: Module Debugging: Fix a crash when emitting debug info for nested tag types whose DeclContext is not yet complete by deferring their emission. rdar://problem/24918680 llvm-svn: 262851 --- clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp') diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp index 9675252..d609cf2 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(DeclCtx)) + if (!D->isCompleteDefinition()) + return; + DeclCtx = DeclCtx->getParent(); + } + DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx); DTV.TraverseDecl(D); Builder->UpdateCompletedType(D); -- cgit v1.1