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.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@145342 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangASTSource.cpp b/source/Expression/ClangASTSource.cpp
index 4c6ba7e..5f3c8b1 100644
--- a/source/Expression/ClangASTSource.cpp
+++ b/source/Expression/ClangASTSource.cpp
@@ -24,7 +24,20 @@
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
diff --git a/source/Symbol/ClangASTImporter.cpp b/source/Symbol/ClangASTImporter.cpp
index a854852..43a7532 100644
--- a/source/Symbol/ClangASTImporter.cpp
+++ b/source/Symbol/ClangASTImporter.cpp
@@ -179,11 +179,32 @@
}
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;