summaryrefslogtreecommitdiffstats
path: root/lldb/source/Symbol/ClangASTImporter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Symbol/ClangASTImporter.cpp')
-rw-r--r--lldb/source/Symbol/ClangASTImporter.cpp182
1 files changed, 93 insertions, 89 deletions
diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp
index 32d0c47693b..5319f794ef9 100644
--- a/lldb/source/Symbol/ClangASTImporter.cpp
+++ b/lldb/source/Symbol/ClangASTImporter.cpp
@@ -30,28 +30,28 @@ ClangASTMetrics::Counters ClangASTMetrics::local_counters = {0, 0, 0, 0, 0, 0};
void ClangASTMetrics::DumpCounters(Log *log,
ClangASTMetrics::Counters &counters) {
- log->Printf(" Number of visible Decl queries by name : %" PRIu64,
- counters.m_visible_query_count);
- log->Printf(" Number of lexical Decl queries : %" PRIu64,
- counters.m_lexical_query_count);
- log->Printf(" Number of imports initiated by LLDB : %" PRIu64,
- counters.m_lldb_import_count);
- log->Printf(" Number of imports conducted by Clang : %" PRIu64,
- counters.m_clang_import_count);
- log->Printf(" Number of Decls completed : %" PRIu64,
- counters.m_decls_completed_count);
- log->Printf(" Number of records laid out : %" PRIu64,
- counters.m_record_layout_count);
+ LLDB_LOGF(log, " Number of visible Decl queries by name : %" PRIu64,
+ counters.m_visible_query_count);
+ LLDB_LOGF(log, " Number of lexical Decl queries : %" PRIu64,
+ counters.m_lexical_query_count);
+ LLDB_LOGF(log, " Number of imports initiated by LLDB : %" PRIu64,
+ counters.m_lldb_import_count);
+ LLDB_LOGF(log, " Number of imports conducted by Clang : %" PRIu64,
+ counters.m_clang_import_count);
+ LLDB_LOGF(log, " Number of Decls completed : %" PRIu64,
+ counters.m_decls_completed_count);
+ LLDB_LOGF(log, " Number of records laid out : %" PRIu64,
+ counters.m_record_layout_count);
}
void ClangASTMetrics::DumpCounters(Log *log) {
if (!log)
return;
- log->Printf("== ClangASTMetrics output ==");
- log->Printf("-- Global metrics --");
+ LLDB_LOGF(log, "== ClangASTMetrics output ==");
+ LLDB_LOGF(log, "-- Global metrics --");
DumpCounters(log, global_counters);
- log->Printf("-- Local metrics --");
+ LLDB_LOGF(log, "-- Local metrics --");
DumpCounters(log, local_counters);
}
@@ -127,14 +127,16 @@ clang::Decl *ClangASTImporter::CopyDecl(clang::ASTContext *dst_ast,
user_id = metadata->GetUserID();
if (NamedDecl *named_decl = dyn_cast<NamedDecl>(decl))
- log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s "
- "'%s', metadata 0x%" PRIx64,
- decl->getDeclKindName(),
- named_decl->getNameAsString().c_str(), user_id);
+ LLDB_LOGF(log,
+ " [ClangASTImporter] WARNING: Failed to import a %s "
+ "'%s', metadata 0x%" PRIx64,
+ decl->getDeclKindName(),
+ named_decl->getNameAsString().c_str(), user_id);
else
- log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s, "
- "metadata 0x%" PRIx64,
- decl->getDeclKindName(), user_id);
+ LLDB_LOGF(log,
+ " [ClangASTImporter] WARNING: Failed to import a %s, "
+ "metadata 0x%" PRIx64,
+ decl->getDeclKindName(), user_id);
}
return nullptr;
}
@@ -211,12 +213,12 @@ private:
if (clang::Decl *escaped_child = GetEscapedChild(decl)) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- log->Printf(" [ClangASTImporter] DeclContextOverride couldn't "
- "override (%sDecl*)%p - its child (%sDecl*)%p escapes",
- decl->getDeclKindName(), static_cast<void *>(decl),
- escaped_child->getDeclKindName(),
- static_cast<void *>(escaped_child));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] DeclContextOverride couldn't "
+ "override (%sDecl*)%p - its child (%sDecl*)%p escapes",
+ decl->getDeclKindName(), static_cast<void *>(decl),
+ escaped_child->getDeclKindName(),
+ static_cast<void *>(escaped_child));
lldbassert(0 && "Couldn't override!");
}
@@ -254,12 +256,12 @@ ClangASTImporter::DeportType(clang::ASTContext *dst_ctx,
lldb::opaque_compiler_type_t type) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- log->Printf(" [ClangASTImporter] DeportType called on (%sType*)0x%llx "
- "from (ASTContext*)%p to (ASTContext*)%p",
- QualType::getFromOpaquePtr(type)->getTypeClassName(),
- (unsigned long long)type, static_cast<void *>(src_ctx),
- static_cast<void *>(dst_ctx));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] DeportType called on (%sType*)0x%llx "
+ "from (ASTContext*)%p to (ASTContext*)%p",
+ QualType::getFromOpaquePtr(type)->getTypeClassName(),
+ (unsigned long long)type, static_cast<void *>(src_ctx),
+ static_cast<void *>(dst_ctx));
ImporterDelegateSP delegate_sp(GetDelegate(dst_ctx, src_ctx));
@@ -294,11 +296,11 @@ clang::Decl *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 (ASTContext*)%p",
- decl->getDeclKindName(), static_cast<void *>(decl),
- static_cast<void *>(src_ctx), static_cast<void *>(dst_ctx));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] DeportDecl called on (%sDecl*)%p from "
+ "(ASTContext*)%p to (ASTContext*)%p",
+ decl->getDeclKindName(), static_cast<void *>(decl),
+ static_cast<void *>(src_ctx), static_cast<void *>(dst_ctx));
ImporterDelegateSP delegate_sp(GetDelegate(dst_ctx, src_ctx));
@@ -321,11 +323,11 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
if (!result)
return nullptr;
- if (log)
- log->Printf(
- " [ClangASTImporter] DeportDecl deported (%sDecl*)%p to (%sDecl*)%p",
- decl->getDeclKindName(), static_cast<void *>(decl),
- result->getDeclKindName(), static_cast<void *>(result));
+ LLDB_LOGF(
+ log,
+ " [ClangASTImporter] DeportDecl deported (%sDecl*)%p to (%sDecl*)%p",
+ decl->getDeclKindName(), static_cast<void *>(decl),
+ result->getDeclKindName(), static_cast<void *>(result));
return result;
}
@@ -533,9 +535,8 @@ void ClangASTImporter::InsertRecordDecl(clang::RecordDecl *decl,
void ClangASTImporter::CompleteDecl(clang::Decl *decl) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- log->Printf(" [ClangASTImporter] CompleteDecl called on (%sDecl*)%p",
- decl->getDeclKindName(), static_cast<void *>(decl));
+ LLDB_LOGF(log, " [ClangASTImporter] CompleteDecl called on (%sDecl*)%p",
+ decl->getDeclKindName(), static_cast<void *>(decl));
if (ObjCInterfaceDecl *interface_decl = dyn_cast<ObjCInterfaceDecl>(decl)) {
if (!interface_decl->getDefinition()) {
@@ -817,9 +818,9 @@ void ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl) {
void ClangASTImporter::ForgetDestination(clang::ASTContext *dst_ast) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- log->Printf(" [ClangASTImporter] Forgetting destination (ASTContext*)%p",
- static_cast<void *>(dst_ast));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Forgetting destination (ASTContext*)%p",
+ static_cast<void *>(dst_ast));
m_metadata_map.erase(dst_ast);
}
@@ -830,10 +831,10 @@ void ClangASTImporter::ForgetSource(clang::ASTContext *dst_ast,
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- log->Printf(" [ClangASTImporter] Forgetting source->dest "
- "(ASTContext*)%p->(ASTContext*)%p",
- static_cast<void *>(src_ast), static_cast<void *>(dst_ast));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Forgetting source->dest "
+ "(ASTContext*)%p->(ASTContext*)%p",
+ static_cast<void *>(src_ast), static_cast<void *>(dst_ast));
if (!md)
return;
@@ -1045,15 +1046,17 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
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(), static_cast<void *>(to),
- name_string.c_str(), static_cast<void *>(from), user_id);
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Imported (%sDecl*)%p, named %s (from "
+ "(Decl*)%p), metadata 0x%" PRIx64,
+ 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(), static_cast<void *>(to),
- static_cast<void *>(from), user_id);
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Imported (%sDecl*)%p (from "
+ "(Decl*)%p), metadata 0x%" PRIx64,
+ from->getDeclKindName(), static_cast<void *>(to),
+ static_cast<void *>(from), user_id);
}
}
@@ -1080,14 +1083,14 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
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",
- static_cast<void *>(origin_iter->second.decl),
- static_cast<void *>(origin_iter->second.ctx),
- static_cast<void *>(&from->getASTContext()),
- static_cast<void *>(&to->getASTContext()));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Propagated origin "
+ "(Decl*)%p/(ASTContext*)%p from (ASTContext*)%p to "
+ "(ASTContext*)%p",
+ 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 {
if (m_decls_to_deport && m_decls_already_deported) {
if (isa<TagDecl>(to) || isa<ObjCInterfaceDecl>(to)) {
@@ -1107,10 +1110,10 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
to_context_md->m_origins[to] = DeclOrigin(m_source_ctx, from);
}
- if (log)
- log->Printf(" [ClangASTImporter] Decl has no origin information in "
- "(ASTContext*)%p",
- static_cast<void *>(&from->getASTContext()));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Decl has no origin information in "
+ "(ASTContext*)%p",
+ static_cast<void *>(&from->getASTContext()));
}
if (clang::NamespaceDecl *to_namespace =
@@ -1130,11 +1133,11 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
} 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",
- static_cast<void *>(from), static_cast<void *>(m_source_ctx),
- static_cast<void *>(&to->getASTContext()));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Sourced origin "
+ "(Decl*)%p/(ASTContext*)%p into (ASTContext*)%p",
+ static_cast<void *>(from), static_cast<void *>(m_source_ctx),
+ static_cast<void *>(&to->getASTContext()));
}
if (TagDecl *from_tag_decl = dyn_cast<TagDecl>(from)) {
@@ -1143,13 +1146,13 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
to_tag_decl->setHasExternalLexicalStorage();
to_tag_decl->getPrimaryContext()->setMustBuildLookupTable();
- if (log)
- log->Printf(
- " [ClangASTImporter] To is a TagDecl - attributes %s%s [%s->%s]",
- (to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
- (to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""),
- (from_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"),
- (to_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"));
+ LLDB_LOGF(
+ log,
+ " [ClangASTImporter] To is a TagDecl - attributes %s%s [%s->%s]",
+ (to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
+ (to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""),
+ (from_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"),
+ (to_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"));
}
if (isa<NamespaceDecl>(from)) {
@@ -1171,15 +1174,16 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
if (log) {
if (ObjCInterfaceDecl *to_interface_decl =
llvm::dyn_cast<ObjCInterfaceDecl>(to_container_decl)) {
- log->Printf(
+ LLDB_LOGF(
+ log,
" [ClangASTImporter] To is an ObjCInterfaceDecl - attributes "
"%s%s%s",
(to_interface_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
(to_interface_decl->hasExternalVisibleStorage() ? " Visible" : ""),
(to_interface_decl->hasDefinition() ? " HasDefinition" : ""));
} else {
- log->Printf(
- " [ClangASTImporter] To is an %sDecl - attributes %s%s",
+ LLDB_LOGF(
+ log, " [ClangASTImporter] To is an %sDecl - attributes %s%s",
((Decl *)to_container_decl)->getDeclKindName(),
(to_container_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
(to_container_decl->hasExternalVisibleStorage() ? " Visible" : ""));
OpenPOWER on IntegriCloud