[Lldb-commits] [lldb] r148152 - /lldb/trunk/source/Symbol/ClangASTImporter.cpp
Sean Callanan
scallanan at apple.com
Fri Jan 13 14:55:55 PST 2012
Author: spyffe
Date: Fri Jan 13 16:55:55 2012
New Revision: 148152
URL: http://llvm.org/viewvc/llvm-project?rev=148152&view=rev
Log:
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.
Modified:
lldb/trunk/source/Symbol/ClangASTImporter.cpp
Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=148152&r1=148151&r2=148152&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Fri Jan 13 16:55:55 2012
@@ -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 @@
{
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
{
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 @@
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)
{
More information about the lldb-commits
mailing list