Changed ClangASTImporter to allow finer-grained

management of what allocations remain after an
expression finishes executing.  This saves around
2.5KiB per expression for simple expressions.

llvm-svn: 145342
This commit is contained in:
Sean Callanan 2011-11-29 00:42:02 +00:00
parent fe2d028ab1
commit 9973231fb0
3 changed files with 38 additions and 3 deletions

View File

@ -106,7 +106,8 @@ public:
void BuildNamespaceMap (const clang::NamespaceDecl *decl);
void PurgeMaps (clang::ASTContext *dest_ast_ctx);
void ForgetDestination (clang::ASTContext *dst_ctx);
void ForgetSource (clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx);
private:
struct DeclOrigin
{

View File

@ -24,7 +24,20 @@ using namespace lldb_private;
ClangASTSource::~ClangASTSource()
{
m_ast_importer->PurgeMaps(m_ast_context);
m_ast_importer->ForgetDestination(m_ast_context);
ClangASTContext *scratch_clang_ast_context = m_target->GetScratchClangASTContext();
if (!scratch_clang_ast_context)
return;
clang::ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext();
if (!scratch_ast_context)
return;
if (m_ast_context != scratch_ast_context)
m_ast_importer->ForgetSource(scratch_ast_context, m_ast_context);
}
void

View File

@ -179,11 +179,32 @@ ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl)
}
void
ClangASTImporter::PurgeMaps (clang::ASTContext *dst_ast)
ClangASTImporter::ForgetDestination (clang::ASTContext *dst_ast)
{
m_metadata_map.erase(dst_ast);
}
void
ClangASTImporter::ForgetSource (clang::ASTContext *dst_ast, clang::ASTContext *src_ast)
{
ASTContextMetadataSP md = MaybeGetContextMetadata (dst_ast);
if (!md)
return;
md->m_minions.erase(src_ast);
for (OriginMap::iterator iter = md->m_origins.begin();
iter != md->m_origins.end();
)
{
if (iter->second.ctx == src_ast)
md->m_origins.erase(iter++);
else
++iter;
}
}
ClangASTImporter::NamespaceMapCompleter::~NamespaceMapCompleter ()
{
return;