summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2011-11-16 18:20:47 +0000
committerSean Callanan <scallanan@apple.com>2011-11-16 18:20:47 +0000
commit686b2319e540050d5fec5c91f2cb7b972630ba26 (patch)
tree6b2690df47d07eeb7a946d22663efcb5213e71d0 /lldb/source
parent8855ff61cb4e554a7ca74ed47a97299c7b2a8b9e (diff)
downloadbcm5719-llvm-686b2319e540050d5fec5c91f2cb7b972630ba26.tar.gz
bcm5719-llvm-686b2319e540050d5fec5c91f2cb7b972630ba26.zip
I made the ClangASTImporter owned by the target
rather than individually on behalf of each ASTContext. This allows the ASTImporter to know about all containers of types, which will let it be smarter about forwarding information about type origins. That means that the following sequence of steps will be possible (after a few more changes): - Import a type from a Module's ASTContext into an expression parser ASTContext, tracking its origin information -- this works now. - Because the result of the expression uses that type, import it from the expression parser ASTContext into the Target's scratch AST context, forwarding the origin information -- this needs to be added. - For a later expression that uses the result, import the type from the Target's scratch AST context, still forwarding origin information -- this also needs to be added. - Use the intact origin information to complete the type as needed -- this works now if the origin information is present. To this end, I made the following changes: - ASTImporter top-level copy functions now require both a source and a destination AST context parameter. - The ASTImporter now knows how to purge records related to an ASTContext that is going away. - The Target now owns and creates the ASTImporter whenever the main executable changes or (in the absence of a main executable) on demand. llvm-svn: 144802
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Expression/ClangASTSource.cpp11
-rw-r--r--lldb/source/Symbol/ClangASTImporter.cpp29
-rw-r--r--lldb/source/Target/Target.cpp21
3 files changed, 47 insertions, 14 deletions
diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp
index bfdab164ff9..678504646a6 100644
--- a/lldb/source/Expression/ClangASTSource.cpp
+++ b/lldb/source/Expression/ClangASTSource.cpp
@@ -24,6 +24,7 @@ using namespace lldb_private;
ClangASTSource::~ClangASTSource()
{
+ m_ast_importer->PurgeMaps(m_ast_context);
}
void
@@ -249,7 +250,7 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
log->Printf(" FELD[%d] Adding lexical decl %s", current_id, ast_dumper.GetCString());
}
- Decl *copied_decl = m_ast_importer->CopyDecl(original_ctx, decl);
+ Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, original_ctx, decl);
decls.push_back(copied_decl);
}
@@ -551,7 +552,7 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
if (found_interface_decl->getName() == interface_decl->getName())
{
- Decl *copied_decl = m_ast_importer->CopyDecl(&method_decl->getASTContext(), method_decl);
+ Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, &method_decl->getASTContext(), method_decl);
if (!copied_decl)
continue;
@@ -610,7 +611,7 @@ ClangASTSource::FindObjCPropertyDecls (NameSearchContext &context)
if (!property_decl)
return;
- Decl *copied_decl = m_ast_importer->CopyDecl(orig_ast_ctx, property_decl);
+ Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, orig_ast_ctx, property_decl);
if (!copied_decl)
return;
@@ -734,7 +735,7 @@ ClangASTSource::AddNamespace (NameSearchContext &context, ClangASTImporter::Name
const ClangNamespaceDecl &namespace_decl = namespace_decls->begin()->second;
- Decl *copied_decl = m_ast_importer->CopyDecl(namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl());
+ Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl());
NamespaceDecl *copied_namespace_decl = dyn_cast<NamespaceDecl>(copied_decl);
@@ -750,7 +751,7 @@ ClangASTSource::GuardedCopyType (ASTContext *dest_context,
{
SetImportInProgress(true);
- QualType ret_qual_type = m_ast_importer->CopyType (source_context, QualType::getFromOpaquePtr(clang_type));
+ QualType ret_qual_type = m_ast_importer->CopyType (m_ast_context, source_context, QualType::getFromOpaquePtr(clang_type));
void *ret = ret_qual_type.getAsOpaquePtr();
diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp
index 92c2325dd40..93ce2adba03 100644
--- a/lldb/source/Symbol/ClangASTImporter.cpp
+++ b/lldb/source/Symbol/ClangASTImporter.cpp
@@ -19,10 +19,11 @@ using namespace lldb_private;
using namespace clang;
clang::QualType
-ClangASTImporter::CopyType (clang::ASTContext *src_ast,
+ClangASTImporter::CopyType (clang::ASTContext *dst_ast,
+ clang::ASTContext *src_ast,
clang::QualType type)
{
- MinionSP minion_sp (GetMinion(src_ast, false));
+ MinionSP minion_sp (GetMinion(dst_ast, src_ast));
if (minion_sp)
return minion_sp->Import(type);
@@ -31,15 +32,13 @@ ClangASTImporter::CopyType (clang::ASTContext *src_ast,
}
clang::Decl *
-ClangASTImporter::CopyDecl (clang::ASTContext *src_ast,
+ClangASTImporter::CopyDecl (clang::ASTContext *dst_ast,
+ clang::ASTContext *src_ast,
clang::Decl *decl)
{
MinionSP minion_sp;
- if (isa<clang::NamespaceDecl>(decl))
- minion_sp = GetMinion(src_ast, true);
- else
- minion_sp = GetMinion(src_ast, false);
+ minion_sp = GetMinion(dst_ast, src_ast);
if (minion_sp)
{
@@ -77,7 +76,7 @@ ClangASTImporter::CompleteTagDecl (clang::TagDecl *decl)
if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
return;
- MinionSP minion_sp (GetMinion(decl_origin.ctx, false));
+ MinionSP minion_sp (GetMinion(&decl->getASTContext(), decl_origin.ctx));
if (minion_sp)
minion_sp->ImportDefinition(decl_origin.decl);
@@ -98,7 +97,7 @@ ClangASTImporter::CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface
if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
return;
- MinionSP minion_sp (GetMinion(decl_origin.ctx, false));
+ MinionSP minion_sp (GetMinion(&interface_decl->getASTContext(), decl_origin.ctx));
if (minion_sp)
minion_sp->ImportDefinition(decl_origin.decl);
@@ -148,6 +147,18 @@ ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl)
RegisterNamespaceMap (decl, new_map);
}
+void
+ClangASTImporter::PurgeMaps (clang::ASTContext *dst_ast)
+{
+ for (MinionMap::iterator i = m_minions.begin(); i != m_minions.end(); )
+ {
+ if ((*i).first.dst == dst_ast)
+ m_minions.erase(i++);
+ else
+ ++i;
+ }
+}
+
ClangASTImporter::NamespaceMapCompleter::~NamespaceMapCompleter ()
{
return;
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index e06f11580b5..53e8ccfdac6 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -61,6 +61,8 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::Plat
m_search_filter_sp (),
m_image_search_paths (ImageSearchPathsChanged, this),
m_scratch_ast_context_ap (NULL),
+ m_scratch_ast_source_ap (NULL),
+ m_ast_importer_ap (NULL),
m_persistent_variables (),
m_source_manager(*this),
m_stop_hooks (),
@@ -173,6 +175,7 @@ Target::Destroy()
m_image_search_paths.Clear(notify);
m_scratch_ast_context_ap.reset();
m_scratch_ast_source_ap.reset();
+ m_ast_importer_ap.reset();
m_persistent_variables.Clear();
m_stop_hooks.clear();
m_stop_hook_next_id = 0;
@@ -797,6 +800,7 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
m_images.Clear();
m_scratch_ast_context_ap.reset();
m_scratch_ast_source_ap.reset();
+ m_ast_importer_ap.reset();
if (executable_sp.get())
{
@@ -837,6 +841,7 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
}
}
+ m_ast_importer_ap.reset(new ClangASTImporter());
}
UpdateInstanceName();
@@ -865,6 +870,8 @@ Target::SetArchitecture (const ArchSpec &arch_spec)
ModuleSP executable_sp = GetExecutableModule ();
m_images.Clear();
m_scratch_ast_context_ap.reset();
+ m_scratch_ast_source_ap.reset();
+ m_ast_importer_ap.reset();
// Need to do something about unsetting breakpoints.
if (executable_sp)
@@ -1342,6 +1349,20 @@ Target::GetScratchClangASTContext()
return m_scratch_ast_context_ap.get();
}
+ClangASTImporter *
+Target::GetClangASTImporter()
+{
+ ClangASTImporter *ast_importer = m_ast_importer_ap.get();
+
+ if (!ast_importer)
+ {
+ ast_importer = new ClangASTImporter();
+ m_ast_importer_ap.reset(ast_importer);
+ }
+
+ return ast_importer;
+}
+
void
Target::SettingsInitialize ()
{
OpenPOWER on IntegriCloud