summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp')
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp400
1 files changed, 164 insertions, 236 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index bf3023be5f60d..8c49898e1d6ca 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1,4 +1,4 @@
-//===-- ClangExpressionDeclMap.cpp -----------------------------*- C++ -*-===//
+//===-- ClangExpressionDeclMap.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,15 +11,15 @@
#include "ClangASTSource.h"
#include "ClangModulesDeclVendor.h"
#include "ClangPersistentVariables.h"
+#include "ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Expression/Materializer.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerDeclContext.h"
@@ -65,8 +65,8 @@ const char *g_lldb_local_vars_namespace_cstr = "$__lldb_local_vars";
ClangExpressionDeclMap::ClangExpressionDeclMap(
bool keep_result_in_memory,
Materializer::PersistentVariableDelegate *result_delegate,
- const lldb::TargetSP &target, const lldb::ClangASTImporterSP &importer,
- ValueObject *ctx_obj)
+ const lldb::TargetSP &target,
+ const std::shared_ptr<ClangASTImporter> &importer, ValueObject *ctx_obj)
: ClangASTSource(target, importer), m_found_entities(), m_struct_members(),
m_keep_result_in_memory(keep_result_in_memory),
m_result_delegate(result_delegate), m_ctx_obj(ctx_obj), m_parser_vars(),
@@ -109,7 +109,7 @@ bool ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx,
m_parser_vars->m_persistent_vars = llvm::cast<ClangPersistentVariables>(
target->GetPersistentExpressionStateForLanguage(eLanguageTypeC));
- if (!ClangASTContext::GetScratch(*target))
+ if (!TypeSystemClang::GetScratch(*target))
return false;
}
@@ -174,19 +174,14 @@ ClangExpressionDeclMap::TargetInfo ClangExpressionDeclMap::GetTargetInfo() {
return ret;
}
-TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target,
- ClangASTContext &source,
+TypeFromUser ClangExpressionDeclMap::DeportType(TypeSystemClang &target,
+ TypeSystemClang &source,
TypeFromParser parser_type) {
- assert(&target == ClangASTContext::GetScratch(*m_target));
+ assert(&target == TypeSystemClang::GetScratch(*m_target));
assert((TypeSystem *)&source == parser_type.GetTypeSystem());
assert(&source.getASTContext() == m_ast_context);
- if (m_ast_importer_sp) {
- return TypeFromUser(m_ast_importer_sp->DeportType(target, parser_type));
- } else {
- lldbassert(0 && "No mechanism for deporting a type!");
- return TypeFromUser();
- }
+ return TypeFromUser(m_ast_importer_sp->DeportType(target, parser_type));
}
bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
@@ -196,8 +191,8 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
bool is_lvalue) {
assert(m_parser_vars.get());
- ClangASTContext *ast =
- llvm::dyn_cast_or_null<ClangASTContext>(parser_type.GetTypeSystem());
+ TypeSystemClang *ast =
+ llvm::dyn_cast_or_null<TypeSystemClang>(parser_type.GetTypeSystem());
if (ast == nullptr)
return false;
@@ -209,7 +204,7 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
if (target == nullptr)
return false;
- auto *clang_ast_context = ClangASTContext::GetScratch(*target);
+ auto *clang_ast_context = TypeSystemClang::GetScratch(*target);
if (!clang_ast_context)
return false;
@@ -231,7 +226,6 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
var->GetParserVars(GetParserID());
parser_vars->m_named_decl = decl;
- parser_vars->m_parser_type = parser_type;
var->EnableJITVars(GetParserID());
@@ -248,14 +242,14 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
if (target == nullptr)
return false;
- ClangASTContext *context = ClangASTContext::GetScratch(*target);
+ TypeSystemClang *context = TypeSystemClang::GetScratch(*target);
if (!context)
return false;
TypeFromUser user_type = DeportType(*context, *ast, parser_type);
if (!user_type.GetOpaqueQualType()) {
- LLDB_LOGF(log, "Persistent variable's type wasn't copied successfully");
+ LLDB_LOG(log, "Persistent variable's type wasn't copied successfully");
return false;
}
@@ -297,7 +291,7 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
var->m_flags |= ClangExpressionVariable::EVKeepInTarget;
}
- LLDB_LOGF(log, "Created persistent variable with flags 0x%hx", var->m_flags);
+ LLDB_LOG(log, "Created persistent variable with flags {0:x}", var->m_flags);
var->EnableParserVars(GetParserID());
@@ -305,7 +299,6 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
var->GetParserVars(GetParserID());
parser_vars->m_named_decl = decl;
- parser_vars->m_parser_type = parser_type;
return true;
}
@@ -339,9 +332,8 @@ bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
if (!var)
return false;
- LLDB_LOGF(log, "Adding value for (NamedDecl*)%p [%s - %s] to the structure",
- static_cast<const void *>(decl), name.GetCString(),
- var->GetName().GetCString());
+ LLDB_LOG(log, "Adding value for (NamedDecl*)%p [%s - %s] to the structure",
+ decl, name, var->GetName());
// We know entity->m_parser_vars is valid because we used a parser variable
// to find it
@@ -355,8 +347,7 @@ bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
llvm::cast<ClangExpressionVariable>(var)->GetJITVars(GetParserID())) {
// We already laid this out; do not touch
- LLDB_LOGF(log, "Already placed at 0x%llx",
- (unsigned long long)jit_vars->m_offset);
+ LLDB_LOG(log, "Already placed at {0:x}", jit_vars->m_offset);
}
llvm::cast<ClangExpressionVariable>(var)->EnableJITVars(GetParserID());
@@ -391,7 +382,7 @@ bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
if (!err.Success())
return false;
- LLDB_LOGF(log, "Placed at 0x%llx", (unsigned long long)offset);
+ LLDB_LOG(log, "Placed at {0:x}", offset);
jit_vars->m_offset =
offset; // TODO DoStructLayout() should not change this.
@@ -600,7 +591,7 @@ addr_t ClangExpressionDeclMap::GetSymbolAddress(ConstString name,
lldb::VariableSP ClangExpressionDeclMap::FindGlobalVariable(
Target &target, ModuleSP &module, ConstString name,
- CompilerDeclContext *namespace_decl) {
+ const CompilerDeclContext &namespace_decl) {
VariableList vars;
if (module && namespace_decl)
@@ -613,7 +604,7 @@ lldb::VariableSP ClangExpressionDeclMap::FindGlobalVariable(
return vars.GetVariableAtIndex(0);
}
-ClangASTContext *ClangExpressionDeclMap::GetClangASTContext() {
+TypeSystemClang *ClangExpressionDeclMap::GetTypeSystemClang() {
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
if (frame == nullptr)
return nullptr;
@@ -627,7 +618,7 @@ ClangASTContext *ClangExpressionDeclMap::GetClangASTContext() {
if (!frame_decl_context)
return nullptr;
- return llvm::dyn_cast_or_null<ClangASTContext>(
+ return llvm::dyn_cast_or_null<TypeSystemClang>(
frame_decl_context.GetTypeSystem());
}
@@ -641,34 +632,23 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (GetImportInProgress()) {
- if (log && log->GetVerbose())
- LLDB_LOGF(log, "Ignoring a query during an import");
- return;
- }
-
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
-
if (log) {
if (!context.m_decl_context)
- LLDB_LOGF(log,
- "ClangExpressionDeclMap::FindExternalVisibleDecls[%u] for "
- "'%s' in a NULL DeclContext",
- current_id, name.GetCString());
+ LLDB_LOG(log,
+ "ClangExpressionDeclMap::FindExternalVisibleDecls for "
+ "'{0}' in a NULL DeclContext",
+ name);
else if (const NamedDecl *context_named_decl =
dyn_cast<NamedDecl>(context.m_decl_context))
- LLDB_LOGF(log,
- "ClangExpressionDeclMap::FindExternalVisibleDecls[%u] for "
- "'%s' in '%s'",
- current_id, name.GetCString(),
- context_named_decl->getNameAsString().c_str());
+ LLDB_LOG(log,
+ "ClangExpressionDeclMap::FindExternalVisibleDecls for "
+ "'{0}' in '{1}'",
+ name, context_named_decl->getNameAsString());
else
- LLDB_LOGF(log,
- "ClangExpressionDeclMap::FindExternalVisibleDecls[%u] for "
- "'%s' in a '%s'",
- current_id, name.GetCString(),
- context.m_decl_context->getDeclKindName());
+ LLDB_LOG(log,
+ "ClangExpressionDeclMap::FindExternalVisibleDecls for "
+ "'{0}' in a '{1}'",
+ name, context.m_decl_context->getDeclKindName());
}
if (const NamespaceDecl *namespace_context =
@@ -678,42 +658,31 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
CompilerDeclContext compiler_decl_ctx =
m_clang_ast_context->CreateDeclContext(
const_cast<clang::DeclContext *>(context.m_decl_context));
- FindExternalVisibleDecls(context, lldb::ModuleSP(), compiler_decl_ctx,
- current_id);
+ FindExternalVisibleDecls(context, lldb::ModuleSP(), compiler_decl_ctx);
return;
}
ClangASTImporter::NamespaceMapSP namespace_map =
- m_ast_importer_sp
- ? m_ast_importer_sp->GetNamespaceMap(namespace_context)
- : ClangASTImporter::NamespaceMapSP();
+ m_ast_importer_sp->GetNamespaceMap(namespace_context);
if (!namespace_map)
return;
- if (log && log->GetVerbose())
- log->Printf(" CEDM::FEVD[%u] Inspecting (NamespaceMap*)%p (%d entries)",
- current_id, static_cast<void *>(namespace_map.get()),
- (int)namespace_map->size());
+ LLDB_LOGV(log, " CEDM::FEVD Inspecting (NamespaceMap*){0:x} ({1} entries)",
+ namespace_map.get(), namespace_map->size());
- for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
- e = namespace_map->end();
- i != e; ++i) {
- if (log)
- log->Printf(" CEDM::FEVD[%u] Searching namespace %s in module %s",
- current_id, i->second.GetName().AsCString(),
- i->first->GetFileSpec().GetFilename().GetCString());
+ for (ClangASTImporter::NamespaceMapItem &n : *namespace_map) {
+ LLDB_LOG(log, " CEDM::FEVD Searching namespace {0} in module {1}",
+ n.second.GetName(), n.first->GetFileSpec().GetFilename());
- FindExternalVisibleDecls(context, i->first, i->second, current_id);
+ FindExternalVisibleDecls(context, n.first, n.second);
}
} else if (isa<TranslationUnitDecl>(context.m_decl_context)) {
CompilerDeclContext namespace_decl;
- if (log)
- log->Printf(" CEDM::FEVD[%u] Searching the root namespace", current_id);
+ LLDB_LOG(log, " CEDM::FEVD Searching the root namespace");
- FindExternalVisibleDecls(context, lldb::ModuleSP(), namespace_decl,
- current_id);
+ FindExternalVisibleDecls(context, lldb::ModuleSP(), namespace_decl);
}
ClangASTSource::FindExternalVisibleDecls(context);
@@ -734,7 +703,7 @@ clang::NamedDecl *ClangExpressionDeclMap::GetPersistentDecl(ConstString name) {
if (!target)
return nullptr;
- ClangASTContext::GetScratch(*target);
+ TypeSystemClang::GetScratch(*target);
if (!m_parser_vars->m_persistent_vars)
return nullptr;
@@ -742,8 +711,7 @@ clang::NamedDecl *ClangExpressionDeclMap::GetPersistentDecl(ConstString name) {
}
void ClangExpressionDeclMap::SearchPersistenDecls(NameSearchContext &context,
- const ConstString name,
- unsigned int current_id) {
+ const ConstString name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
NamedDecl *persistent_decl = GetPersistentDecl(name);
@@ -766,14 +734,12 @@ void ClangExpressionDeclMap::SearchPersistenDecls(NameSearchContext &context,
MaybeRegisterFunctionBody(parser_function_decl);
}
- LLDB_LOGF(log, " CEDM::FEVD[%u] Found persistent decl %s", current_id,
- name.GetCString());
+ LLDB_LOG(log, " CEDM::FEVD Found persistent decl %s", name);
context.AddNamedDecl(parser_named_decl);
}
-void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
- unsigned int current_id) {
+void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
@@ -788,8 +754,7 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
if (!ctx_obj_ptr || status.Fail())
return;
- AddThisType(context, TypeFromUser(m_ctx_obj->GetCompilerType()),
- current_id);
+ AddContextClassType(context, TypeFromUser(m_ctx_obj->GetCompilerType()));
m_struct_vars->m_object_pointer_type =
TypeFromUser(ctx_obj_ptr->GetCompilerType());
@@ -814,7 +779,7 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
return;
clang::CXXMethodDecl *method_decl =
- ClangASTContext::DeclContextGetAsCXXMethodDecl(function_decl_ctx);
+ TypeSystemClang::DeclContextGetAsCXXMethodDecl(function_decl_ctx);
if (method_decl) {
clang::CXXRecordDecl *class_decl = method_decl->getParent();
@@ -824,10 +789,10 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
TypeFromUser class_user_type(class_qual_type.getAsOpaquePtr(),
function_decl_ctx.GetTypeSystem());
- LLDB_LOG(log, " CEDM::FEVD[{0}] Adding type for $__lldb_class: {1}",
- current_id, class_qual_type.getAsString());
+ LLDB_LOG(log, " CEDM::FEVD Adding type for $__lldb_class: {1}",
+ class_qual_type.getAsString());
- AddThisType(context, class_user_type, current_id);
+ AddContextClassType(context, class_user_type);
if (method_decl->isInstance()) {
// self is a pointer to the object
@@ -866,17 +831,16 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
TypeFromUser pointee_type =
this_type->GetForwardCompilerType().GetPointeeType();
- LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_class: {1}", current_id,
+ LLDB_LOG(log, " FEVD Adding type for $__lldb_class: {1}",
ClangUtil::GetQualType(pointee_type).getAsString());
- AddThisType(context, pointee_type, current_id);
+ AddContextClassType(context, pointee_type);
TypeFromUser this_user_type(this_type->GetFullCompilerType());
m_struct_vars->m_object_pointer_type = this_user_type;
}
}
-void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
- unsigned int current_id) {
+void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
@@ -887,7 +851,7 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
if (!ctx_obj_ptr || status.Fail())
return;
- AddOneType(context, TypeFromUser(m_ctx_obj->GetCompilerType()), current_id);
+ AddOneType(context, TypeFromUser(m_ctx_obj->GetCompilerType()));
m_struct_vars->m_object_pointer_type =
TypeFromUser(ctx_obj_ptr->GetCompilerType());
@@ -915,7 +879,7 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
return;
clang::ObjCMethodDecl *method_decl =
- ClangASTContext::DeclContextGetAsObjCMethodDecl(function_decl_ctx);
+ TypeSystemClang::DeclContextGetAsObjCMethodDecl(function_decl_ctx);
if (method_decl) {
ObjCInterfaceDecl *self_interface = method_decl->getClassInterface();
@@ -933,9 +897,9 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
function_decl_ctx.GetTypeSystem());
LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
- current_id, ClangUtil::ToString(interface_type));
+ ClangUtil::ToString(interface_type));
- AddOneType(context, class_user_type, current_id);
+ AddOneType(context, class_user_type);
if (method_decl->isInstanceMethod()) {
// self is a pointer to the object
@@ -984,10 +948,10 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
CompilerType self_clang_type = self_type->GetFullCompilerType();
- if (ClangASTContext::IsObjCClassType(self_clang_type)) {
+ if (TypeSystemClang::IsObjCClassType(self_clang_type)) {
return;
}
- if (!ClangASTContext::IsObjCObjectPointerType(self_clang_type))
+ if (!TypeSystemClang::IsObjCObjectPointerType(self_clang_type))
return;
self_clang_type = self_clang_type.GetPointeeType();
@@ -995,11 +959,11 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
return;
LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
- current_id, ClangUtil::ToString(self_type->GetFullCompilerType()));
+ ClangUtil::ToString(self_type->GetFullCompilerType()));
TypeFromUser class_user_type(self_clang_type);
- AddOneType(context, class_user_type, current_id);
+ AddOneType(context, class_user_type);
TypeFromUser self_user_type(self_type->GetFullCompilerType());
@@ -1015,25 +979,25 @@ void ClangExpressionDeclMap::LookupLocalVarNamespace(
if (!frame_decl_context)
return;
- ClangASTContext *frame_ast = llvm::dyn_cast_or_null<ClangASTContext>(
+ TypeSystemClang *frame_ast = llvm::dyn_cast_or_null<TypeSystemClang>(
frame_decl_context.GetTypeSystem());
if (!frame_ast)
return;
clang::NamespaceDecl *namespace_decl =
m_clang_ast_context->GetUniqueNamespaceDeclaration(
- g_lldb_local_vars_namespace_cstr, nullptr);
+ g_lldb_local_vars_namespace_cstr, nullptr, OptionalClangModuleID());
if (!namespace_decl)
return;
name_context.AddNamedDecl(namespace_decl);
clang::DeclContext *ctxt = clang::Decl::castToDeclContext(namespace_decl);
ctxt->setHasExternalVisibleStorage(true);
- name_context.m_found.local_vars_nsp = true;
+ name_context.m_found_local_vars_nsp = true;
}
void ClangExpressionDeclMap::LookupInModulesDeclVendor(
- NameSearchContext &context, ConstString name, unsigned current_id) {
+ NameSearchContext &context, ConstString name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
if (!m_target)
@@ -1054,16 +1018,14 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor(
clang::NamedDecl *const decl_from_modules = decls[0];
LLDB_LOG(log,
- " CAS::FEVD[{0}] Matching decl found for "
+ " CAS::FEVD Matching decl found for "
"\"{1}\" in the modules",
- current_id, name);
+ name);
clang::Decl *copied_decl = CopyDecl(decl_from_modules);
if (!copied_decl) {
- LLDB_LOG(log,
- " CAS::FEVD[{0}] - Couldn't export a "
- "declaration from the modules",
- current_id);
+ LLDB_LOG(log, " CAS::FEVD - Couldn't export a "
+ "declaration from the modules");
return;
}
@@ -1072,17 +1034,17 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor(
context.AddNamedDecl(copied_function);
- context.m_found.function_with_type_info = true;
- context.m_found.function = true;
+ context.m_found_function_with_type_info = true;
+ context.m_found_function = true;
} else if (auto copied_var = dyn_cast<clang::VarDecl>(copied_decl)) {
context.AddNamedDecl(copied_var);
- context.m_found.variable = true;
+ context.m_found_variable = true;
}
}
bool ClangExpressionDeclMap::LookupLocalVariable(
- NameSearchContext &context, ConstString name, unsigned current_id,
- SymbolContext &sym_ctx, CompilerDeclContext &namespace_decl) {
+ NameSearchContext &context, ConstString name, SymbolContext &sym_ctx,
+ const CompilerDeclContext &namespace_decl) {
if (sym_ctx.block == nullptr)
return false;
@@ -1117,8 +1079,8 @@ bool ClangExpressionDeclMap::LookupLocalVariable(
if (var && !variable_found) {
variable_found = true;
ValueObjectSP valobj = ValueObjectVariable::Create(frame, var);
- AddOneVariable(context, var, valobj, current_id);
- context.m_found.variable = true;
+ AddOneVariable(context, var, valobj);
+ context.m_found_variable = true;
}
}
return variable_found;
@@ -1148,7 +1110,7 @@ SymbolContextList ClangExpressionDeclMap::SearchFunctionsInSymbolContexts(
decl_infos.reserve(num_indices);
clang::DeclContext *frame_decl_ctx =
(clang::DeclContext *)frame_decl_context.GetOpaqueDeclContext();
- ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(
+ TypeSystemClang *ast = llvm::dyn_cast_or_null<TypeSystemClang>(
frame_decl_context.GetTypeSystem());
for (uint32_t index = 0; index < num_indices; ++index) {
@@ -1222,11 +1184,9 @@ SymbolContextList ClangExpressionDeclMap::SearchFunctionsInSymbolContexts(
return sc_func_list;
}
-void ClangExpressionDeclMap::LookupFunction(NameSearchContext &context,
- lldb::ModuleSP module_sp,
- ConstString name,
- CompilerDeclContext &namespace_decl,
- unsigned current_id) {
+void ClangExpressionDeclMap::LookupFunction(
+ NameSearchContext &context, lldb::ModuleSP module_sp, ConstString name,
+ const CompilerDeclContext &namespace_decl) {
if (!m_parser_vars)
return;
@@ -1246,7 +1206,7 @@ void ClangExpressionDeclMap::LookupFunction(NameSearchContext &context,
if (namespace_decl && module_sp) {
const bool include_symbols = false;
- module_sp->FindFunctions(name, &namespace_decl, eFunctionNameTypeBase,
+ module_sp->FindFunctions(name, namespace_decl, eFunctionNameTypeBase,
include_symbols, include_inlines, sc_list);
} else if (target && !namespace_decl) {
const bool include_symbols = true;
@@ -1304,9 +1264,9 @@ void ClangExpressionDeclMap::LookupFunction(NameSearchContext &context,
if (decl_ctx.IsClassMethod(nullptr, nullptr, nullptr))
continue;
- AddOneFunction(context, sym_ctx.function, nullptr, current_id);
- context.m_found.function_with_type_info = true;
- context.m_found.function = true;
+ AddOneFunction(context, sym_ctx.function, nullptr);
+ context.m_found_function_with_type_info = true;
+ context.m_found_function = true;
} else if (sym_ctx.symbol) {
if (sym_ctx.symbol->GetType() == eSymbolTypeReExported && target) {
sym_ctx.symbol = sym_ctx.symbol->ResolveReExportedSymbol(*target);
@@ -1321,26 +1281,26 @@ void ClangExpressionDeclMap::LookupFunction(NameSearchContext &context,
}
}
- if (!context.m_found.function_with_type_info) {
+ if (!context.m_found_function_with_type_info) {
for (clang::NamedDecl *decl : decls_from_modules) {
if (llvm::isa<clang::FunctionDecl>(decl)) {
clang::NamedDecl *copied_decl =
llvm::cast_or_null<FunctionDecl>(CopyDecl(decl));
if (copied_decl) {
context.AddNamedDecl(copied_decl);
- context.m_found.function_with_type_info = true;
+ context.m_found_function_with_type_info = true;
}
}
}
}
- if (!context.m_found.function_with_type_info) {
+ if (!context.m_found_function_with_type_info) {
if (extern_symbol) {
- AddOneFunction(context, nullptr, extern_symbol, current_id);
- context.m_found.function = true;
+ AddOneFunction(context, nullptr, extern_symbol);
+ context.m_found_function = true;
} else if (non_extern_symbol) {
- AddOneFunction(context, nullptr, non_extern_symbol, current_id);
- context.m_found.function = true;
+ AddOneFunction(context, nullptr, non_extern_symbol);
+ context.m_found_function = true;
}
}
}
@@ -1348,7 +1308,7 @@ void ClangExpressionDeclMap::LookupFunction(NameSearchContext &context,
void ClangExpressionDeclMap::FindExternalVisibleDecls(
NameSearchContext &context, lldb::ModuleSP module_sp,
- CompilerDeclContext &namespace_decl, unsigned int current_id) {
+ const CompilerDeclContext &namespace_decl) {
assert(m_ast_context);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -1373,16 +1333,16 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
// Try the persistent decls, which take precedence over all else.
if (!namespace_decl)
- SearchPersistenDecls(context, name, current_id);
+ SearchPersistenDecls(context, name);
if (name.GetStringRef().startswith("$") && !namespace_decl) {
if (name == "$__lldb_class") {
- LookUpLldbClass(context, current_id);
+ LookUpLldbClass(context);
return;
}
if (name == "$__lldb_objc_class") {
- LookUpLldbObjCClass(context, current_id);
+ LookUpLldbObjCClass(context);
return;
}
if (name == g_lldb_local_vars_namespace_cstr) {
@@ -1402,7 +1362,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
m_parser_vars->m_persistent_vars->GetVariable(name));
if (pvar_sp) {
- AddOneVariable(context, pvar_sp, current_id);
+ AddOneVariable(context, pvar_sp);
return;
}
@@ -1415,10 +1375,9 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
reg_name));
if (reg_info) {
- LLDB_LOGF(log, " CEDM::FEVD[%u] Found register %s", current_id,
- reg_info->name);
+ LLDB_LOG(log, " CEDM::FEVD Found register {0}", reg_info->name);
- AddOneRegister(context, reg_info, current_id);
+ AddOneRegister(context, reg_info);
}
}
return;
@@ -1427,29 +1386,29 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
bool local_var_lookup = !namespace_decl || (namespace_decl.GetName() ==
g_lldb_local_vars_namespace_cstr);
if (frame && local_var_lookup)
- if (LookupLocalVariable(context, name, current_id, sym_ctx, namespace_decl))
+ if (LookupLocalVariable(context, name, sym_ctx, namespace_decl))
return;
if (target) {
ValueObjectSP valobj;
VariableSP var;
- var = FindGlobalVariable(*target, module_sp, name, &namespace_decl);
+ var = FindGlobalVariable(*target, module_sp, name, namespace_decl);
if (var) {
valobj = ValueObjectVariable::Create(target, var);
- AddOneVariable(context, var, valobj, current_id);
- context.m_found.variable = true;
+ AddOneVariable(context, var, valobj);
+ context.m_found_variable = true;
return;
}
}
- LookupFunction(context, module_sp, name, namespace_decl, current_id);
+ LookupFunction(context, module_sp, name, namespace_decl);
// Try the modules next.
- if (!context.m_found.function_with_type_info)
- LookupInModulesDeclVendor(context, name, current_id);
+ if (!context.m_found_function_with_type_info)
+ LookupInModulesDeclVendor(context, name);
- if (target && !context.m_found.variable && !namespace_decl) {
+ if (target && !context.m_found_variable && !namespace_decl) {
// We couldn't find a non-symbol variable for this. Now we'll hunt for a
// generic data symbol, and -- if it is found -- treat it as a variable.
Status error;
@@ -1471,8 +1430,8 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
m_ast_context->getDiagnostics().getCustomDiagID(
clang::DiagnosticsEngine::Level::Warning, "%0");
m_ast_context->getDiagnostics().Report(diag_id) << warning.c_str();
- AddOneGenericVariable(context, *data_symbol, current_id);
- context.m_found.variable = true;
+ AddOneGenericVariable(context, *data_symbol);
+ context.m_found_variable = true;
}
}
}
@@ -1486,25 +1445,22 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
Type *var_type = var->GetType();
if (!var_type) {
- if (log)
- log->PutCString("Skipped a definition because it has no type");
+ LLDB_LOG(log, "Skipped a definition because it has no type");
return false;
}
CompilerType var_clang_type = var_type->GetFullCompilerType();
if (!var_clang_type) {
- if (log)
- log->PutCString("Skipped a definition because it has no Clang type");
+ LLDB_LOG(log, "Skipped a definition because it has no Clang type");
return false;
}
- ClangASTContext *clang_ast = llvm::dyn_cast_or_null<ClangASTContext>(
+ TypeSystemClang *clang_ast = llvm::dyn_cast_or_null<TypeSystemClang>(
var_type->GetForwardCompilerType().GetTypeSystem());
if (!clang_ast) {
- if (log)
- log->PutCString("Skipped a definition because it has no Clang AST");
+ LLDB_LOG(log, "Skipped a definition because it has no Clang AST");
return false;
}
@@ -1521,7 +1477,7 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
const_value_extractor.GetByteSize());
var_location.SetValueType(Value::eValueTypeHostAddress);
} else {
- LLDB_LOGF(log, "Error evaluating constant variable: %s", err.AsCString());
+ LLDB_LOG(log, "Error evaluating constant variable: {0}", err.AsCString());
return false;
}
}
@@ -1529,8 +1485,8 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
CompilerType type_to_use = GuardedCopyType(var_clang_type);
if (!type_to_use) {
- LLDB_LOGF(log,
- "Couldn't copy a variable's type into the parser's AST context");
+ LLDB_LOG(log,
+ "Couldn't copy a variable's type into the parser's AST context");
return false;
}
@@ -1567,8 +1523,7 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
VariableSP var,
- ValueObjectSP valobj,
- unsigned int current_id) {
+ ValueObjectSP valobj) {
assert(m_parser_vars.get());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -1611,7 +1566,6 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
entity->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars =
entity->GetParserVars(GetParserID());
- parser_vars->m_parser_type = pt;
parser_vars->m_named_decl = var_decl;
parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_value = var_location;
@@ -1620,15 +1574,12 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
if (is_reference)
entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
- LLDB_LOG(log,
- " CEDM::FEVD[{0}] Found variable {1}, returned\n{2} (original {3})",
- current_id, decl_name, ClangUtil::DumpDecl(var_decl),
- ClangUtil::ToString(ut));
+ LLDB_LOG(log, " CEDM::FEVD Found variable {1}, returned\n{2} (original {3})",
+ decl_name, ClangUtil::DumpDecl(var_decl), ClangUtil::ToString(ut));
}
void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
- ExpressionVariableSP &pvar_sp,
- unsigned int current_id) {
+ ExpressionVariableSP &pvar_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
TypeFromUser user_type(
@@ -1637,8 +1588,8 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
TypeFromParser parser_type(GuardedCopyType(user_type));
if (!parser_type.GetOpaqueQualType()) {
- LLDB_LOGF(log, " CEDM::FEVD[%u] Couldn't import type for pvar %s",
- current_id, pvar_sp->GetName().GetCString());
+ LLDB_LOG(log, " CEDM::FEVD Couldn't import type for pvar {0}",
+ pvar_sp->GetName());
return;
}
@@ -1650,18 +1601,16 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
ClangExpressionVariable::ParserVars *parser_vars =
llvm::cast<ClangExpressionVariable>(pvar_sp.get())
->GetParserVars(GetParserID());
- parser_vars->m_parser_type = parser_type;
parser_vars->m_named_decl = var_decl;
parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_value.Clear();
- LLDB_LOG(log, " CEDM::FEVD[{0}] Added pvar {1}, returned\n{2}", current_id,
+ LLDB_LOG(log, " CEDM::FEVD Added pvar {1}, returned\n{2}",
pvar_sp->GetName(), ClangUtil::DumpDecl(var_decl));
}
void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
- const Symbol &symbol,
- unsigned int current_id) {
+ const Symbol &symbol) {
assert(m_parser_vars.get());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -1671,7 +1620,7 @@ void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
if (target == nullptr)
return;
- ClangASTContext *scratch_ast_context = ClangASTContext::GetScratch(*target);
+ TypeSystemClang *scratch_ast_context = TypeSystemClang::GetScratch(*target);
if (!scratch_ast_context)
return;
@@ -1704,18 +1653,16 @@ void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
parser_vars->m_lldb_value.GetScalar() = symbol_load_addr;
parser_vars->m_lldb_value.SetValueType(Value::eValueTypeLoadAddress);
- parser_vars->m_parser_type = parser_type;
parser_vars->m_named_decl = var_decl;
parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_sym = &symbol;
- LLDB_LOG(log, " CEDM::FEVD[{0}] Found variable {1}, returned\n{2}",
- current_id, decl_name, ClangUtil::DumpDecl(var_decl));
+ LLDB_LOG(log, " CEDM::FEVD Found variable {1}, returned\n{2}", decl_name,
+ ClangUtil::DumpDecl(var_decl));
}
void ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
- const RegisterInfo *reg_info,
- unsigned int current_id) {
+ const RegisterInfo *reg_info) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
CompilerType clang_type =
@@ -1723,8 +1670,8 @@ void ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
reg_info->encoding, reg_info->byte_size * 8);
if (!clang_type) {
- LLDB_LOGF(log, " Tried to add a type for %s, but couldn't get one",
- context.m_decl_name.getAsString().c_str());
+ LLDB_LOG(log, " Tried to add a type for {0}, but couldn't get one",
+ context.m_decl_name.getAsString());
return;
}
@@ -1744,20 +1691,18 @@ void ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
entity->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars =
entity->GetParserVars(GetParserID());
- parser_vars->m_parser_type = parser_clang_type;
parser_vars->m_named_decl = var_decl;
parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_value.Clear();
entity->m_flags |= ClangExpressionVariable::EVBareRegister;
- LLDB_LOG(log, " CEDM::FEVD[{0}] Added register {1}, returned\n{2}",
- current_id, context.m_decl_name.getAsString(),
- ClangUtil::DumpDecl(var_decl));
+ LLDB_LOG(log, " CEDM::FEVD Added register {1}, returned\n{2}",
+ context.m_decl_name.getAsString(), ClangUtil::DumpDecl(var_decl));
}
void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
- Function *function, Symbol *symbol,
- unsigned int current_id) {
+ Function *function,
+ Symbol *symbol) {
assert(m_parser_vars.get());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -1780,7 +1725,7 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
if (!extern_c) {
TypeSystem *type_system = function->GetDeclContext().GetTypeSystem();
- if (llvm::isa<ClangASTContext>(type_system)) {
+ if (llvm::isa<TypeSystemClang>(type_system)) {
clang::DeclContext *src_decl_context =
(clang::DeclContext *)function->GetDeclContext()
.GetOpaqueDeclContext();
@@ -1800,9 +1745,9 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
function->DumpSymbolContext(&ss);
LLDB_LOG(log,
- " CEDM::FEVD[{0}] Imported decl for function template"
+ " CEDM::FEVD Imported decl for function template"
" {1} (description {2}), returned\n{3}",
- current_id, copied_function_template->getNameAsString(),
+ copied_function_template->getNameAsString(),
ss.GetData(),
ClangUtil::DumpDecl(copied_function_template));
}
@@ -1819,35 +1764,31 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
function->DumpSymbolContext(&ss);
LLDB_LOG(log,
- " CEDM::FEVD[{0}]] Imported decl for function {1} "
+ " CEDM::FEVD Imported decl for function {1} "
"(description {2}), returned\n{3}",
- current_id, copied_function_decl->getNameAsString(),
- ss.GetData(), ClangUtil::DumpDecl(copied_function_decl));
+ copied_function_decl->getNameAsString(), ss.GetData(),
+ ClangUtil::DumpDecl(copied_function_decl));
}
context.AddNamedDecl(copied_function_decl);
return;
} else {
- if (log) {
- LLDB_LOGF(log, " Failed to import the function decl for '%s'",
- src_function_decl->getName().str().c_str());
- }
+ LLDB_LOG(log, " Failed to import the function decl for '{0}'",
+ src_function_decl->getName());
}
}
}
}
if (!function_type) {
- if (log)
- log->PutCString(" Skipped a function because it has no type");
+ LLDB_LOG(log, " Skipped a function because it has no type");
return;
}
function_clang_type = function_type->GetFullCompilerType();
if (!function_clang_type) {
- if (log)
- log->PutCString(" Skipped a function because it has no Clang type");
+ LLDB_LOG(log, " Skipped a function because it has no Clang type");
return;
}
@@ -1858,24 +1799,17 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
function_decl = context.AddFunDecl(copied_function_type, extern_c);
if (!function_decl) {
- if (log) {
- LLDB_LOGF(
- log,
- " Failed to create a function decl for '%s' {0x%8.8" PRIx64 "}",
- function_type->GetName().GetCString(), function_type->GetID());
- }
+ LLDB_LOG(log, " Failed to create a function decl for '{0}' ({1:x})",
+ function_type->GetName(), function_type->GetID());
return;
}
} else {
// We failed to copy the type we found
- if (log) {
- LLDB_LOGF(log,
- " Failed to import the function type '%s' {0x%8.8" PRIx64
- "} into the expression parser AST contenxt",
- function_type->GetName().GetCString(),
- function_type->GetID());
- }
+ LLDB_LOG(log,
+ " Failed to import the function type '{0}' ({1:x})"
+ " into the expression parser AST contenxt",
+ function_type->GetName(), function_type->GetID());
return;
}
@@ -1884,8 +1818,7 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
function_decl = context.AddGenericFunDecl();
is_indirect_function = symbol->IsIndirect();
} else {
- if (log)
- log->PutCString(" AddOneFunction called with no function and no symbol");
+ LLDB_LOG(log, " AddOneFunction called with no function and no symbol");
return;
}
@@ -1931,25 +1864,22 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
Address::DumpStyleResolvedDescription);
LLDB_LOG(log,
- " CEDM::FEVD[{0}] Found {1} function {2} (description {3}), "
+ " CEDM::FEVD Found {1} function {2} (description {3}), "
"returned\n{4}",
- current_id, (function ? "specific" : "generic"), decl_name,
- ss.GetData(), ClangUtil::DumpDecl(function_decl));
+ (function ? "specific" : "generic"), decl_name, ss.GetData(),
+ ClangUtil::DumpDecl(function_decl));
}
}
-void ClangExpressionDeclMap::AddThisType(NameSearchContext &context,
- const TypeFromUser &ut,
- unsigned int current_id) {
+void ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context,
+ const TypeFromUser &ut) {
CompilerType copied_clang_type = GuardedCopyType(ut);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
if (!copied_clang_type) {
- if (log)
- LLDB_LOGF(
- log,
- "ClangExpressionDeclMap::AddThisType - Couldn't import the type");
+ LLDB_LOG(log,
+ "ClangExpressionDeclMap::AddThisType - Couldn't import the type");
return;
}
@@ -2009,16 +1939,14 @@ void ClangExpressionDeclMap::AddThisType(NameSearchContext &context,
}
void ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
- const TypeFromUser &ut,
- unsigned int current_id) {
+ const TypeFromUser &ut) {
CompilerType copied_clang_type = GuardedCopyType(ut);
if (!copied_clang_type) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- LLDB_LOGF(
- log, "ClangExpressionDeclMap::AddOneType - Couldn't import the type");
+ LLDB_LOG(log,
+ "ClangExpressionDeclMap::AddOneType - Couldn't import the type");
return;
}