summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2012-01-13 22:55:55 +0000
committerSean Callanan <scallanan@apple.com>2012-01-13 22:55:55 +0000
commitcbbe3ac4a9e7bd4f3ee835582ca71c54d51b45bd (patch)
tree8ae08e154e69044a6eef2233ea6f060c0abbb885
parent35545421c862b5d084460b0bd6d35b842b17b995 (diff)
downloadbcm5719-llvm-cbbe3ac4a9e7bd4f3ee835582ca71c54d51b45bd.tar.gz
bcm5719-llvm-cbbe3ac4a9e7bd4f3ee835582ca71c54d51b45bd.zip
I made two major improvements to the way the
master AST importer imports types. - First, before importing the definition of a Decl from its source, notify the underlying importer of the source->destination mapping. Especially for anonymous strucutres that are otherwise hard to unique in the target AST context, this hint is very helpful. - When deporting a type or Decl from one ASTContext to another (deporting occurs in the case of moving result types from the parser's AST context to the result AST context), don't forget their origin if the origin is the original debug information. llvm-svn: 148152
-rw-r--r--lldb/source/Symbol/ClangASTImporter.cpp47
1 files changed, 37 insertions, 10 deletions
diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp
index 60dd20d460e..59c2f6a737d 100644
--- a/lldb/source/Symbol/ClangASTImporter.cpp
+++ b/lldb/source/Symbol/ClangASTImporter.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
@@ -93,11 +94,15 @@ ClangASTImporter::DeportType (clang::ASTContext *dst_ctx,
{
MinionSP minion_sp (GetMinion (dst_ctx, src_ctx));
- minion_sp->ImportDefinition(tag_decl);
+ minion_sp->ImportDefinitionTo(result_tag_decl, tag_decl);
ASTContextMetadataSP to_context_md = GetContextMetadata(dst_ctx);
- to_context_md->m_origins.erase(result_tag_decl);
+ OriginMap::iterator oi = to_context_md->m_origins.find(result_tag_decl);
+
+ if (oi != to_context_md->m_origins.end() &&
+ oi->second.ctx == src_ctx)
+ to_context_md->m_origins.erase(oi);
}
}
@@ -119,11 +124,15 @@ ClangASTImporter::DeportDecl (clang::ASTContext *dst_ctx,
MinionSP minion_sp (GetMinion (dst_ctx, src_ctx));
if (minion_sp && isa<TagDecl>(decl))
- minion_sp->ImportDefinition(decl);
+ minion_sp->ImportDefinitionTo(result, decl);
ASTContextMetadataSP to_context_md = GetContextMetadata(dst_ctx);
- to_context_md->m_origins.erase(result);
+ OriginMap::iterator oi = to_context_md->m_origins.find(decl);
+
+ if (oi != to_context_md->m_origins.end() &&
+ oi->second.ctx == src_ctx)
+ to_context_md->m_origins.erase(oi);
return result;
}
@@ -142,8 +151,8 @@ ClangASTImporter::CompleteTagDecl (clang::TagDecl *decl)
MinionSP minion_sp (GetMinion(&decl->getASTContext(), decl_origin.ctx));
if (minion_sp)
- minion_sp->ImportDefinition(decl_origin.decl);
-
+ minion_sp->ImportDefinitionTo(decl, decl_origin.decl);
+
return true;
}
@@ -158,8 +167,8 @@ ClangASTImporter::CompleteTagDeclWithOrigin(clang::TagDecl *decl, clang::TagDecl
MinionSP minion_sp (GetMinion(&decl->getASTContext(), origin_ast_ctx));
if (minion_sp)
- minion_sp->ImportDefinition(origin_decl);
-
+ minion_sp->ImportDefinitionTo(decl, origin_decl);
+
ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
OriginMap &origins = context_md->m_origins;
@@ -185,8 +194,8 @@ ClangASTImporter::CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface
MinionSP minion_sp (GetMinion(&interface_decl->getASTContext(), decl_origin.ctx));
if (minion_sp)
- minion_sp->ImportDefinition(decl_origin.decl);
-
+ minion_sp->ImportDefinitionTo(interface_decl, decl_origin.decl);
+
return true;
}
@@ -258,6 +267,11 @@ ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl)
void
ClangASTImporter::ForgetDestination (clang::ASTContext *dst_ast)
{
+ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log)
+ log->Printf(" [ClangASTImporter] Forgetting destination (ASTContext*)%p", dst_ast);
+
m_metadata_map.erase(dst_ast);
}
@@ -266,6 +280,11 @@ ClangASTImporter::ForgetSource (clang::ASTContext *dst_ast, clang::ASTContext *s
{
ASTContextMetadataSP md = MaybeGetContextMetadata (dst_ast);
+ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log)
+ log->Printf(" [ClangASTImporter] Forgetting source->dest (ASTContext*)%p->(ASTContext*)%p", src_ast, dst_ast);
+
if (!md)
return;
@@ -319,6 +338,14 @@ ClangASTImporter::BuildObjCInterfaceMap (const clang::ObjCInterfaceDecl *decl)
context_md->m_objc_interface_maps[decl] = new_map;
}
+void
+ClangASTImporter::Minion::ImportDefinitionTo (clang::Decl *to, clang::Decl *from)
+{
+ ASTImporter::Imported(from, to);
+
+ ImportDefinition(from);
+}
+
clang::Decl
*ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to)
{
OpenPOWER on IntegriCloud