Implemented the reverse-lookup API in the AST

importer to avoid duplicate imports of anonymous
structs.

<rdar://problem/14421722>

llvm-svn: 192327
This commit is contained in:
Sean Callanan
2013-10-09 22:33:34 +00:00
parent 4c3261d1b3
commit 931a0def9e
2 changed files with 17 additions and 0 deletions

View File

@@ -278,6 +278,8 @@ private:
clang::Decl *Imported (clang::Decl *from, clang::Decl *to);
clang::Decl *GetOriginalDecl (clang::Decl *To);
std::set<clang::NamedDecl *> *m_decls_to_deport;
std::set<clang::NamedDecl *> *m_decls_already_deported;
ClangASTImporter &m_master;

View File

@@ -716,3 +716,18 @@ ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to)
return clang::ASTImporter::Imported(from, to);
}
clang::Decl *ClangASTImporter::Minion::GetOriginalDecl (clang::Decl *To)
{
ASTContextMetadataSP to_context_md = m_master.GetContextMetadata(&To->getASTContext());
if (!to_context_md)
return NULL;
OriginMap::iterator iter = to_context_md->m_origins.find(To);
if (iter == to_context_md->m_origins.end())
return NULL;
return const_cast<clang::Decl*>(iter->second.decl);
}