From d27858932960f74bf05223bf63d398f1143a8830 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sun, 18 Aug 2013 17:36:19 +0000 Subject: DebugInfo: Avoid duplicating types that may be created during the process of creating their context A partner to r188639, this is a somewhat heavy-handed fix to the general issue, since even after that prior change the issue does still unavoidably arise with template parameters (see test case). There are other ways we could consider addressing this (see FIXME). llvm-svn: 188640 --- clang/lib/CodeGen/CGDebugInfo.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp') diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 31422830f19..7ffaf7d1dd2 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2183,6 +2183,19 @@ llvm::DIType CGDebugInfo::CreateLimitedType(const RecordType *Ty) { else RDContext = getContextDescriptor(cast(RD->getDeclContext())); + // If we ended up creating the type during the context chain construction, + // just return that. + // FIXME: this could be dealt with better if the type was recorded as + // completed before we started this (see the CompletedTypeCache usage in + // CGDebugInfo::CreateTypeDefinition(const RecordType*) - that would need to + // be pushed to before context creation, but after it was known to be + // destined for completion (might still have an issue if this caller only + // required a declaration but the context construction ended up creating a + // definition) + if (llvm::DIType T = getTypeOrNull(CGM.getContext().getRecordType(RD))) + if (!T.isForwardDecl() || !RD->getDefinition()) + return T; + // If this is just a forward declaration, construct an appropriately // marked node and just return it. if (!RD->getDefinition()) -- cgit v1.2.3