Add all Decls found through FindExternalLexicalDecls

to the DeclContext.  This fulfils the contract that
we make with Clang by returning ELR_AlreadyLoaded.

This is a little aggressive in that it does not allow
the ASTImporter to import the child decls with any
lexical parent other than the Decl that reported them
as children.

<rdar://problem/13517713>

llvm-svn: 181498
This commit is contained in:
Sean Callanan 2013-05-09 01:09:49 +00:00
parent da144dc216
commit 04b2bfa3a9
1 changed files with 12 additions and 0 deletions

View File

@ -472,6 +472,18 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
}
decls.push_back(copied_decl);
DeclContext *decl_context_non_const = const_cast<DeclContext *>(decl_context);
if (copied_decl->getDeclContext() != decl_context)
{
if (copied_decl->getDeclContext()->containsDecl(copied_decl))
copied_decl->getDeclContext()->removeDecl(copied_decl);
copied_decl->setDeclContext(decl_context_non_const);
}
if (!decl_context_non_const->containsDecl(copied_decl))
decl_context_non_const->addDeclInternal(copied_decl);
}
}