diff options
Diffstat (limited to 'lldb/source/Symbol/ClangASTImporter.cpp')
-rw-r--r-- | lldb/source/Symbol/ClangASTImporter.cpp | 140 |
1 files changed, 67 insertions, 73 deletions
diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp index afdca97ece2..1bf35f34c3b 100644 --- a/lldb/source/Symbol/ClangASTImporter.cpp +++ b/lldb/source/Symbol/ClangASTImporter.cpp @@ -142,39 +142,36 @@ ClangASTImporter::DeportDecl (clang::ASTContext *dst_ctx, clang::Decl *decl) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - + if (log) log->Printf(" [ClangASTImporter] DeportDecl called on (%sDecl*)%p from (ASTContext*)%p to (ASTContex*)%p", - decl->getDeclKindName(), - decl, - src_ctx, - dst_ctx); - + decl->getDeclKindName(), static_cast<void*>(decl), + static_cast<void*>(src_ctx), + static_cast<void*>(dst_ctx)); + MinionSP minion_sp (GetMinion (dst_ctx, src_ctx)); - + if (!minion_sp) return NULL; - + std::set<NamedDecl *> decls_to_deport; std::set<NamedDecl *> decls_already_deported; - + minion_sp->InitDeportWorkQueues(&decls_to_deport, &decls_already_deported); - + clang::Decl *result = CopyDecl(dst_ctx, src_ctx, decl); minion_sp->ExecuteDeportWorkQueues(); - + if (!result) return NULL; - + if (log) log->Printf(" [ClangASTImporter] DeportDecl deported (%sDecl*)%p to (%sDecl*)%p", - decl->getDeclKindName(), - decl, - result->getDeclKindName(), - result); - + decl->getDeclKindName(), static_cast<void*>(decl), + result->getDeclKindName(), static_cast<void*>(result)); + return result; } @@ -183,11 +180,10 @@ ClangASTImporter::CompleteDecl (clang::Decl *decl) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - if (log) + if (log) log->Printf(" [ClangASTImporter] CompleteDecl called on (%sDecl*)%p", - decl->getDeclKindName(), - decl); - + decl->getDeclKindName(), static_cast<void*>(decl)); + if (ObjCInterfaceDecl *interface_decl = dyn_cast<ObjCInterfaceDecl>(decl)) { if (!interface_decl->getDefinition()) @@ -412,9 +408,10 @@ void ClangASTImporter::ForgetDestination (clang::ASTContext *dst_ast) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - + if (log) - log->Printf(" [ClangASTImporter] Forgetting destination (ASTContext*)%p", dst_ast); + log->Printf(" [ClangASTImporter] Forgetting destination (ASTContext*)%p", + static_cast<void*>(dst_ast)); m_metadata_map.erase(dst_ast); } @@ -423,17 +420,18 @@ void ClangASTImporter::ForgetSource (clang::ASTContext *dst_ast, clang::ASTContext *src_ast) { ASTContextMetadataSP md = MaybeGetContextMetadata (dst_ast); - + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - + if (log) - log->Printf(" [ClangASTImporter] Forgetting source->dest (ASTContext*)%p->(ASTContext*)%p", src_ast, dst_ast); - + log->Printf(" [ClangASTImporter] Forgetting source->dest (ASTContext*)%p->(ASTContext*)%p", + static_cast<void*>(src_ast), static_cast<void*>(dst_ast)); + if (!md) return; - + md->m_minions.erase(src_ast); - + for (OriginMap::iterator iter = md->m_origins.begin(); iter != md->m_origins.end(); ) @@ -572,64 +570,60 @@ clang::Decl * ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to) { ClangASTMetrics::RegisterClangImport(); - + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - + if (log) { lldb::user_id_t user_id; ClangASTMetadata *metadata = m_master.GetDeclMetadata(from); if (metadata) user_id = metadata->GetUserID(); - + if (NamedDecl *from_named_decl = dyn_cast<clang::NamedDecl>(from)) { std::string name_string; llvm::raw_string_ostream name_stream(name_string); from_named_decl->printName(name_stream); name_stream.flush(); - + log->Printf(" [ClangASTImporter] Imported (%sDecl*)%p, named %s (from (Decl*)%p), metadata 0x%" PRIx64, - from->getDeclKindName(), - to, - name_string.c_str(), - from, + from->getDeclKindName(), static_cast<void*>(to), + name_string.c_str(), static_cast<void*>(from), user_id); } else { log->Printf(" [ClangASTImporter] Imported (%sDecl*)%p (from (Decl*)%p), metadata 0x%" PRIx64, - from->getDeclKindName(), - to, - from, - user_id); + from->getDeclKindName(), static_cast<void*>(to), + static_cast<void*>(from), user_id); } } ASTContextMetadataSP to_context_md = m_master.GetContextMetadata(&to->getASTContext()); ASTContextMetadataSP from_context_md = m_master.MaybeGetContextMetadata(m_source_ctx); - + if (from_context_md) { OriginMap &origins = from_context_md->m_origins; - + OriginMap::iterator origin_iter = origins.find(from); - + if (origin_iter != origins.end()) { to_context_md->m_origins[to] = origin_iter->second; - + MinionSP direct_completer = m_master.GetMinion(&to->getASTContext(), origin_iter->second.ctx); - + if (direct_completer.get() != this) direct_completer->ASTImporter::Imported(origin_iter->second.decl, to); - + if (log) log->Printf(" [ClangASTImporter] Propagated origin (Decl*)%p/(ASTContext*)%p from (ASTContext*)%p to (ASTContext*)%p", - origin_iter->second.decl, - origin_iter->second.ctx, - &from->getASTContext(), - &to->getASTContext()); + static_cast<void*>(origin_iter->second.decl), + static_cast<void*>(origin_iter->second.ctx), + static_cast<void*>(&from->getASTContext()), + static_cast<void*>(&to->getASTContext())); } else { @@ -638,27 +632,27 @@ ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to) if (isa<TagDecl>(to) || isa<ObjCInterfaceDecl>(to)) { NamedDecl *to_named_decl = dyn_cast<NamedDecl>(to); - + if (!m_decls_already_deported->count(to_named_decl)) m_decls_to_deport->insert(to_named_decl); } } to_context_md->m_origins[to] = DeclOrigin(m_source_ctx, from); - + if (log) log->Printf(" [ClangASTImporter] Decl has no origin information in (ASTContext*)%p", - &from->getASTContext()); + static_cast<void*>(&from->getASTContext())); } - + if (clang::NamespaceDecl *to_namespace = dyn_cast<clang::NamespaceDecl>(to)) { clang::NamespaceDecl *from_namespace = dyn_cast<clang::NamespaceDecl>(from); - + NamespaceMetaMap &namespace_maps = from_context_md->m_namespace_maps; - + NamespaceMetaMap::iterator namespace_map_iter = namespace_maps.find(from_namespace); - + if (namespace_map_iter != namespace_maps.end()) to_context_md->m_namespace_maps[to_namespace] = namespace_map_iter->second; } @@ -666,21 +660,21 @@ ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to) else { to_context_md->m_origins[to] = DeclOrigin (m_source_ctx, from); - + if (log) log->Printf(" [ClangASTImporter] Sourced origin (Decl*)%p/(ASTContext*)%p into (ASTContext*)%p", - from, - m_source_ctx, - &to->getASTContext()); + static_cast<void*>(from), + static_cast<void*>(m_source_ctx), + static_cast<void*>(&to->getASTContext())); } - + if (TagDecl *from_tag_decl = dyn_cast<TagDecl>(from)) { TagDecl *to_tag_decl = dyn_cast<TagDecl>(to); - + to_tag_decl->setHasExternalLexicalStorage(); to_tag_decl->setMustBuildLookupTable(); - + if (log) log->Printf(" [ClangASTImporter] To is a TagDecl - attributes %s%s [%s->%s]", (to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""), @@ -688,32 +682,32 @@ ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to) (from_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"), (to_tag_decl->isCompleteDefinition() ? "complete" : "incomplete")); } - + if (isa<NamespaceDecl>(from)) { NamespaceDecl *to_namespace_decl = dyn_cast<NamespaceDecl>(to); - + m_master.BuildNamespaceMap(to_namespace_decl); - + to_namespace_decl->setHasExternalVisibleStorage(); } - + if (isa<ObjCInterfaceDecl>(from)) { ObjCInterfaceDecl *to_interface_decl = dyn_cast<ObjCInterfaceDecl>(to); - + to_interface_decl->setHasExternalLexicalStorage(); to_interface_decl->setHasExternalVisibleStorage(); - + /*to_interface_decl->setExternallyCompleted();*/ - + if (log) log->Printf(" [ClangASTImporter] To is an ObjCInterfaceDecl - attributes %s%s%s", (to_interface_decl->hasExternalLexicalStorage() ? " Lexical" : ""), (to_interface_decl->hasExternalVisibleStorage() ? " Visible" : ""), (to_interface_decl->hasDefinition() ? " HasDefinition" : "")); } - + return clang::ASTImporter::Imported(from, to); } |