summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp13
1 files changed, 13 insertions, 0 deletions
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<Decl>(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())
OpenPOWER on IntegriCloud