forked from OSchip/llvm-project
Fixed a bug in the ASTImporter that affects
types that have been imported multiple times. The discussion below uses this diagram: ASTContext A B C Decl Da Db Dc ASTImporter \-Iab-/\-Iac-/ \-----Iac----/ When a Decl D is imported from ASTContext A to ASTContext B, the ASTImporter Iab records the pair <Da, Db> in a DenseMap. That way, if Iab ever encounters Da again (for example, as the DeclContext for another Decl), it can use the imported version. This is not an optimization, it is critical: if I import the field "st_dev" as part of importing "struct stat," the field must have DeclContext equal to the parent structure or we end up with multiple different Decls containing different parts of "struct stat." "struct stat" is imported once and recorded in the DenseMap; then the ASTImporter finds that same version when looking for the DeclContext of "st_dev." The bug arises when Db is imported into another ASTContext C and ASTContext B goes away. This often occurs when LLDB produces result variables for expressions. Ibc is aware of the transport of Db to Dc, but a brand new ASTImporter, Iac, is responsible for completing Dc from its source upon request. That ASTImporter has no mappings, so it will produce a clone of Dc when attempting to import its children. That means that type completion operations on Dc will fail. The solution is to create Iac as soon as Ibc imports D from B to C, and inform Iac of the mapping between Da and Dc. This allows type completion to happen correctly. llvm-svn: 147016
This commit is contained in:
parent
43c1ff4db3
commit
5bc5a76d9b
|
@ -356,6 +356,11 @@ clang::Decl
|
|||
{
|
||||
to_context_md->m_origins[to] = origin_iter->second;
|
||||
|
||||
MinionSP direct_completer = m_master.GetMinion(&to->getASTContext(), origin_iter->second.ctx);
|
||||
|
||||
if (direct_completer.get() != this)
|
||||
direct_completer->ASTImporter::Imported(origin_iter->second.decl, to);
|
||||
|
||||
if (log)
|
||||
log->Printf(" [ClangASTImporter] Propagated origin (Decl*)%p/(ASTContext*)%p from (ASTContext*)%p to (ASTContext*)%p",
|
||||
origin_iter->second.decl,
|
||||
|
|
Loading…
Reference in New Issue