diff options
author | David Blaikie <dblaikie@gmail.com> | 2013-08-18 17:36:19 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2013-08-18 17:36:19 +0000 |
commit | d27858932960f74bf05223bf63d398f1143a8830 (patch) | |
tree | 03f61b7b023bf6678cb450b707d7cefe17857797 /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | adfbf993d6068a9196ed1036a9039a8cb566b3d2 (diff) | |
download | bcm5719-llvm-d27858932960f74bf05223bf63d398f1143a8830.tar.gz bcm5719-llvm-d27858932960f74bf05223bf63d398f1143a8830.zip |
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
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 13 |
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()) |