[lldb][NFC] Make all CompilerDeclContext parameters references instead of pointers

Summary:
All of our lookup APIs either use `CompilerDeclContext &` or `CompilerDeclContext *` semi-randomly it seems.
This leads to us constantly converting between those two types (and doing nullptr checks when going from
pointer to reference). It also leads to the confusing situation where we have two possible ways to express
that we don't have a CompilerDeclContex: either a nullptr or an invalid CompilerDeclContext (aka a default
constructed CompilerDeclContext).

This moves all APIs to use references and gets rid of all the nullptr checks and conversions.

Reviewers: labath, mib, shafik

Reviewed By: labath, shafik

Subscribers: shafik, arphaman, abidh, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74607
This commit is contained in:
Raphael Isemann 2020-02-17 19:25:52 +01:00
parent d4a4a32cd9
commit f9568a9549
29 changed files with 138 additions and 139 deletions

View File

@ -302,7 +302,7 @@ public:
/// A symbol context list that gets filled in with all of the
/// matches.
void FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask, bool symbols_ok,
bool inlines_ok, SymbolContextList &sc_list);
@ -365,7 +365,7 @@ public:
/// A list of variables that gets the matches appended to.
///
void FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
size_t max_matches, VariableList &variable_list);
/// Find global and static variables by regular expression.
@ -444,7 +444,7 @@ public:
/// \param[out] type_list
/// A type list gets populated with any matches.
void FindTypesInNamespace(ConstString type_name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
size_t max_matches, TypeList &type_list);
/// Get const accessor for the module architecture.
@ -1037,7 +1037,7 @@ private:
Module(); // Only used internally by CreateJITModule ()
void FindTypes_Impl(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);

View File

@ -208,21 +208,21 @@ public:
SymbolContextList &sc_list);
virtual void DumpClangAST(Stream &s) {}
virtual void
FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, VariableList &variables);
virtual void FindGlobalVariables(ConstString name,
const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
VariableList &variables);
virtual void FindGlobalVariables(const RegularExpression &regex,
uint32_t max_matches,
VariableList &variables);
virtual void FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, SymbolContextList &sc_list);
virtual void FindFunctions(const RegularExpression &regex,
bool include_inlines, SymbolContextList &sc_list);
virtual void
FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
FindTypes(ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);
@ -251,8 +251,7 @@ public:
GetTypeSystemForLanguage(lldb::LanguageType language);
virtual CompilerDeclContext
FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) {
FindNamespace(ConstString name, const CompilerDeclContext &parent_decl_ctx) {
return CompilerDeclContext();
}

View File

@ -401,8 +401,8 @@ lldb::SBSymbolContextList SBModule::FindFunctions(const char *name,
const bool symbols_ok = true;
const bool inlines_ok = true;
FunctionNameType type = static_cast<FunctionNameType>(name_type_mask);
module_sp->FindFunctions(ConstString(name), nullptr, type, symbols_ok,
inlines_ok, *sb_sc_list);
module_sp->FindFunctions(ConstString(name), CompilerDeclContext(), type,
symbols_ok, inlines_ok, *sb_sc_list);
}
return LLDB_RECORD_RESULT(sb_sc_list);
}
@ -417,8 +417,8 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name,
ModuleSP module_sp(GetSP());
if (name && module_sp) {
VariableList variable_list;
module_sp->FindGlobalVariables(ConstString(name), nullptr, max_matches,
variable_list);
module_sp->FindGlobalVariables(ConstString(name), CompilerDeclContext(),
max_matches, variable_list);
for (const VariableSP &var_sp : variable_list) {
lldb::ValueObjectSP valobj_sp;
TargetSP target_sp(target.GetSP());

View File

@ -278,8 +278,9 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter,
for (const auto &lookup : m_lookups) {
const size_t start_func_idx = func_list.GetSize();
context.module_sp->FindFunctions(
lookup.GetLookupName(), nullptr, lookup.GetNameTypeMask(),
include_symbols, include_inlines, func_list);
lookup.GetLookupName(), CompilerDeclContext(),
lookup.GetNameTypeMask(), include_symbols, include_inlines,
func_list);
const size_t end_func_idx = func_list.GetSize();

View File

@ -1599,8 +1599,9 @@ static size_t LookupFunctionInModule(CommandInterpreter &interpreter,
include_inlines, sc_list);
} else {
ConstString function_name(name);
module->FindFunctions(function_name, nullptr, eFunctionNameTypeAuto,
include_symbols, include_inlines, sc_list);
module->FindFunctions(function_name, CompilerDeclContext(),
eFunctionNameTypeAuto, include_symbols,
include_inlines, sc_list);
}
num_matches = sc_list.GetSize();
if (num_matches) {

View File

@ -91,7 +91,7 @@ AddressResolverName::SearchCallback(SearchFilter &filter,
if (context.module_sp) {
context.module_sp->FindSymbolsWithNameAndType(m_func_name,
eSymbolTypeCode, sym_list);
context.module_sp->FindFunctions(m_func_name, nullptr,
context.module_sp->FindFunctions(m_func_name, CompilerDeclContext(),
eFunctionNameTypeAuto, include_symbols,
include_inlines, func_list);
}

View File

@ -173,8 +173,8 @@ bool Disassembler::Disassemble(
// Find functions matching the given name.
SymbolContextList sc_list;
if (module) {
module->FindFunctions(name, nullptr, eFunctionNameTypeAuto, include_symbols,
include_inlines, sc_list);
module->FindFunctions(name, CompilerDeclContext(), eFunctionNameTypeAuto,
include_symbols, include_inlines, sc_list);
} else if (exe_ctx.GetTargetPtr()) {
exe_ctx.GetTargetPtr()->GetImages().FindFunctions(
name, eFunctionNameTypeAuto, include_symbols, include_inlines, sc_list);

View File

@ -595,7 +595,7 @@ uint32_t Module::ResolveSymbolContextsForFileSpec(
}
void Module::FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
size_t max_matches, VariableList &variables) {
if (SymbolFile *symbols = GetSymbolFile())
symbols->FindGlobalVariables(name, parent_decl_ctx, max_matches, variables);
@ -783,7 +783,7 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
}
void Module::FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask,
bool include_symbols, bool include_inlines,
SymbolContextList &sc_list) {
@ -920,7 +920,7 @@ void Module::FindAddressesForLine(const lldb::TargetSP target_sp,
}
void Module::FindTypes_Impl(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
@ -932,7 +932,7 @@ void Module::FindTypes_Impl(
}
void Module::FindTypesInNamespace(ConstString type_name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
size_t max_matches, TypeList &type_list) {
TypeMap types_map;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
@ -974,7 +974,7 @@ void Module::FindTypes(
exact_match = type_scope.consume_front("::");
ConstString type_basename_const_str(type_basename);
FindTypes_Impl(type_basename_const_str, nullptr, max_matches,
FindTypes_Impl(type_basename_const_str, CompilerDeclContext(), max_matches,
searched_symbol_files, typesmap);
if (typesmap.GetSize())
typesmap.RemoveMismatchedTypes(std::string(type_scope),
@ -986,13 +986,14 @@ void Module::FindTypes(
if (type_class != eTypeClassAny && !type_basename.empty()) {
// The "type_name_cstr" will have been modified if we have a valid type
// class prefix (like "struct", "class", "union", "typedef" etc).
FindTypes_Impl(ConstString(type_basename), nullptr, UINT_MAX,
searched_symbol_files, typesmap);
FindTypes_Impl(ConstString(type_basename), CompilerDeclContext(),
UINT_MAX, searched_symbol_files, typesmap);
typesmap.RemoveMismatchedTypes(std::string(type_scope),
std::string(type_basename), type_class,
exact_match);
} else {
FindTypes_Impl(name, nullptr, UINT_MAX, searched_symbol_files, typesmap);
FindTypes_Impl(name, CompilerDeclContext(), UINT_MAX,
searched_symbol_files, typesmap);
if (exact_match) {
std::string name_str(name.AsCString(""));
typesmap.RemoveMismatchedTypes(std::string(type_scope), name_str,

View File

@ -363,7 +363,7 @@ void ModuleList::FindFunctions(ConstString name,
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindFunctions(lookup_info.GetLookupName(), nullptr,
(*pos)->FindFunctions(lookup_info.GetLookupName(), CompilerDeclContext(),
lookup_info.GetNameTypeMask(), include_symbols,
include_inlines, sc_list);
}
@ -376,8 +376,8 @@ void ModuleList::FindFunctions(ConstString name,
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindFunctions(name, nullptr, name_type_mask, include_symbols,
include_inlines, sc_list);
(*pos)->FindFunctions(name, CompilerDeclContext(), name_type_mask,
include_symbols, include_inlines, sc_list);
}
}
}
@ -434,7 +434,8 @@ void ModuleList::FindGlobalVariables(ConstString name, size_t max_matches,
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindGlobalVariables(name, nullptr, max_matches, variable_list);
(*pos)->FindGlobalVariables(name, CompilerDeclContext(), max_matches,
variable_list);
}
}

View File

@ -325,7 +325,7 @@ bool SourceManager::GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line) {
ConstString main_name("main");
bool symbols_okay = false; // Force it to be a debug symbol.
bool inlines_okay = true;
executable_ptr->FindFunctions(main_name, nullptr,
executable_ptr->FindFunctions(main_name, CompilerDeclContext(),
lldb::eFunctionNameTypeBase, inlines_okay,
symbols_okay, sc_list);
size_t num_matches = sc_list.GetSize();

View File

@ -843,7 +843,7 @@ lldb::addr_t IRExecutionUnit::FindInSymbols(
};
if (sc.module_sp) {
sc.module_sp->FindFunctions(spec.name, nullptr, spec.mask,
sc.module_sp->FindFunctions(spec.name, CompilerDeclContext(), spec.mask,
true, // include_symbols
false, // include_inlines
sc_list);

View File

@ -252,7 +252,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
ConstString name(tag_decl->getName().str().c_str());
i->first->FindTypesInNamespace(name, &i->second, UINT32_MAX, types);
i->first->FindTypesInNamespace(name, i->second, UINT32_MAX, types);
for (uint32_t ti = 0, te = types.GetSize(); ti != te && !found; ++ti) {
lldb::TypeSP type = types.GetTypeAtIndex(ti);
@ -664,7 +664,7 @@ void ClangASTSource::FindExternalVisibleDecls(
CompilerDeclContext found_namespace_decl;
if (SymbolFile *symbol_file = module_sp->GetSymbolFile()) {
found_namespace_decl = symbol_file->FindNamespace(name, &namespace_decl);
found_namespace_decl = symbol_file->FindNamespace(name, namespace_decl);
if (found_namespace_decl) {
context.m_namespace_map->push_back(
@ -692,7 +692,7 @@ void ClangASTSource::FindExternalVisibleDecls(
if (!symbol_file)
continue;
found_namespace_decl = symbol_file->FindNamespace(name, &namespace_decl);
found_namespace_decl = symbol_file->FindNamespace(name, namespace_decl);
if (found_namespace_decl) {
context.m_namespace_map->push_back(
@ -713,7 +713,7 @@ void ClangASTSource::FindExternalVisibleDecls(
const bool exact_match = true;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
if (module_sp && namespace_decl)
module_sp->FindTypesInNamespace(name, &namespace_decl, 1, types);
module_sp->FindTypesInNamespace(name, namespace_decl, 1, types);
else {
m_target->GetImages().FindTypes(module_sp.get(), name, exact_match, 1,
searched_symbol_files, types);
@ -1696,7 +1696,7 @@ void ClangASTSource::CompleteNamespaceMap(
continue;
found_namespace_decl =
symbol_file->FindNamespace(name, &module_parent_namespace_decl);
symbol_file->FindNamespace(name, module_parent_namespace_decl);
if (!found_namespace_decl)
continue;
@ -1727,7 +1727,7 @@ void ClangASTSource::CompleteNamespaceMap(
continue;
found_namespace_decl =
symbol_file->FindNamespace(name, &null_namespace_decl);
symbol_file->FindNamespace(name, null_namespace_decl);
if (!found_namespace_decl)
continue;

View File

@ -597,7 +597,7 @@ lldb::VariableSP ClangExpressionDeclMap::FindGlobalVariable(
VariableList vars;
if (module && namespace_decl)
module->FindGlobalVariables(name, namespace_decl, -1, vars);
module->FindGlobalVariables(name, *namespace_decl, -1, vars);
else
target.GetImages().FindGlobalVariables(name, -1, vars);
@ -1237,7 +1237,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;

View File

@ -573,7 +573,7 @@ static void GetSymbolDeclarationFromAddress(ProcessSP process_sp, addr_t addr,
return;
VariableList var_list;
module->FindGlobalVariables(sym_name, nullptr, 1U, var_list);
module->FindGlobalVariables(sym_name, CompilerDeclContext(), 1U, var_list);
if (var_list.GetSize() < 1)
return;

View File

@ -3943,7 +3943,8 @@ void RSModuleDescriptor::Dump(Stream &strm) const {
void RSGlobalDescriptor::Dump(Stream &strm) const {
strm.Indent(m_name.GetStringRef());
VariableList var_list;
m_module->m_module->FindGlobalVariables(m_name, nullptr, 1U, var_list);
m_module->m_module->FindGlobalVariables(m_name, CompilerDeclContext(), 1U,
var_list);
if (var_list.GetSize() == 1) {
auto var = var_list.GetVariableAtIndex(0);
auto type = var->GetType();

View File

@ -294,7 +294,7 @@ uint32_t SymbolFileBreakpad::ResolveSymbolContext(
}
void SymbolFileBreakpad::FindFunctions(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines,
SymbolContextList &sc_list) {
// TODO
@ -307,7 +307,7 @@ void SymbolFileBreakpad::FindFunctions(const RegularExpression &regex,
}
void SymbolFileBreakpad::FindTypes(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) {}

View File

@ -82,7 +82,7 @@ public:
size_t ParseBlocksRecursive(Function &func) override { return 0; }
void FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
VariableList &variables) override {}
@ -110,14 +110,14 @@ public:
TypeList &type_list) override {}
void FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, SymbolContextList &sc_list) override;
void FindFunctions(const RegularExpression &regex, bool include_inlines,
SymbolContextList &sc_list) override;
void FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
void FindTypes(ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) override;
@ -135,7 +135,7 @@ public:
CompilerDeclContext
FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) override {
const CompilerDeclContext &parent_decl_ctx) override {
return CompilerDeclContext();
}

View File

@ -36,7 +36,7 @@ void DWARFIndex::ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
// Otherwise, we need to also check that the context matches. If it does not
// match, we do nothing.
if (!SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
if (!SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx, die))
return;
// In case of a full match, we just insert everything we find.

View File

@ -406,7 +406,7 @@ void ManualDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
DWARFDIE die = dwarf.GetDIE(die_ref);
if (!die)
continue;
if (SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
if (SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx, die))
dies.push_back(die);
}
}
@ -417,7 +417,7 @@ void ManualDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
DWARFDIE die = dwarf.GetDIE(die_ref);
if (!die)
continue;
if (SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
if (SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx, die))
dies.push_back(die);
}
offsets.clear();

View File

@ -2004,15 +2004,15 @@ std::recursive_mutex &SymbolFileDWARF::GetModuleMutex() const {
}
bool SymbolFileDWARF::DeclContextMatchesThisSymbolFile(
const lldb_private::CompilerDeclContext *decl_ctx) {
if (decl_ctx == nullptr || !decl_ctx->IsValid()) {
const lldb_private::CompilerDeclContext &decl_ctx) {
if (!decl_ctx.IsValid()) {
// Invalid namespace decl which means we aren't matching only things in
// this symbol file, so return true to indicate it matches this symbol
// file.
return true;
}
TypeSystem *decl_ctx_type_system = decl_ctx->GetTypeSystem();
TypeSystem *decl_ctx_type_system = decl_ctx.GetTypeSystem();
auto type_system_or_err = GetTypeSystemForLanguage(
decl_ctx_type_system->GetMinimumLanguage(nullptr));
if (auto err = type_system_or_err.takeError()) {
@ -2036,7 +2036,7 @@ bool SymbolFileDWARF::DeclContextMatchesThisSymbolFile(
}
void SymbolFileDWARF::FindGlobalVariables(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
@ -2046,7 +2046,7 @@ void SymbolFileDWARF::FindGlobalVariables(
log,
"SymbolFileDWARF::FindGlobalVariables (name=\"%s\", "
"parent_decl_ctx=%p, max_matches=%u, variables)",
name.GetCString(), static_cast<const void *>(parent_decl_ctx),
name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
max_matches);
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
@ -2104,7 +2104,7 @@ void SymbolFileDWARF::FindGlobalVariables(
CompilerDeclContext actual_parent_decl_ctx =
dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
if (!actual_parent_decl_ctx ||
actual_parent_decl_ctx != *parent_decl_ctx)
actual_parent_decl_ctx != parent_decl_ctx)
continue;
}
}
@ -2137,7 +2137,7 @@ void SymbolFileDWARF::FindGlobalVariables(
log,
"SymbolFileDWARF::FindGlobalVariables (name=\"%s\", "
"parent_decl_ctx=%p, max_matches=%u, variables) => %u",
name.GetCString(), static_cast<const void *>(parent_decl_ctx),
name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
max_matches, num_matches);
}
}
@ -2249,26 +2249,26 @@ bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die,
return false;
}
bool SymbolFileDWARF::DIEInDeclContext(const CompilerDeclContext *decl_ctx,
bool SymbolFileDWARF::DIEInDeclContext(const CompilerDeclContext &decl_ctx,
const DWARFDIE &die) {
// If we have no parent decl context to match this DIE matches, and if the
// parent decl context isn't valid, we aren't trying to look for any
// particular decl context so any die matches.
if (decl_ctx == nullptr || !decl_ctx->IsValid())
if (!decl_ctx.IsValid())
return true;
if (die) {
if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
if (CompilerDeclContext actual_decl_ctx =
dwarf_ast->GetDeclContextContainingUIDFromDWARF(die))
return decl_ctx->IsContainedInLookup(actual_decl_ctx);
return decl_ctx.IsContainedInLookup(actual_decl_ctx);
}
}
return false;
}
void SymbolFileDWARF::FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask,
bool include_inlines,
SymbolContextList &sc_list) {
@ -2304,12 +2304,9 @@ void SymbolFileDWARF::FindFunctions(ConstString name,
llvm::DenseSet<const DWARFDebugInfoEntry *> resolved_dies;
DIEArray offsets;
CompilerDeclContext empty_decl_ctx;
if (!parent_decl_ctx)
parent_decl_ctx = &empty_decl_ctx;
std::vector<DWARFDIE> dies;
m_index->GetFunctions(name, *this, *parent_decl_ctx, name_type_mask, dies);
m_index->GetFunctions(name, *this, parent_decl_ctx, name_type_mask, dies);
for (const DWARFDIE &die : dies) {
if (resolved_dies.insert(die.GetDIE()).second)
ResolveFunction(die, include_inlines, sc_list);
@ -2389,7 +2386,7 @@ void SymbolFileDWARF::GetMangledNamesForFunction(
}
void SymbolFileDWARF::FindTypes(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
@ -2410,8 +2407,8 @@ void SymbolFileDWARF::FindTypes(
log,
"SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = "
"%p (\"%s\"), max_matches=%u, type_list)",
name.GetCString(), static_cast<const void *>(parent_decl_ctx),
parent_decl_ctx->GetName().AsCString("<NULL>"), max_matches);
name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
parent_decl_ctx.GetName().AsCString("<NULL>"), max_matches);
else
GetObjectFile()->GetModule()->LogMessage(
log,
@ -2466,8 +2463,8 @@ void SymbolFileDWARF::FindTypes(
log,
"SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx "
"= %p (\"%s\"), max_matches=%u, type_list) => %u",
name.GetCString(), static_cast<const void *>(parent_decl_ctx),
parent_decl_ctx->GetName().AsCString("<NULL>"), max_matches,
name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
parent_decl_ctx.GetName().AsCString("<NULL>"), max_matches,
types.GetSize());
} else {
GetObjectFile()->GetModule()->LogMessage(
@ -2535,7 +2532,7 @@ void SymbolFileDWARF::FindTypes(
CompilerDeclContext
SymbolFileDWARF::FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) {
const CompilerDeclContext &parent_decl_ctx) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));

View File

@ -166,7 +166,7 @@ public:
void
FindGlobalVariables(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
@ -175,7 +175,7 @@ public:
lldb_private::VariableList &variables) override;
void FindFunctions(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
@ -190,7 +190,7 @@ public:
void
FindTypes(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
lldb_private::TypeMap &types) override;
@ -209,7 +209,7 @@ public:
lldb_private::CompilerDeclContext FindNamespace(
lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
const lldb_private::CompilerDeclContext &parent_decl_ctx) override;
void PreloadSymbols() override;
@ -280,7 +280,7 @@ public:
llvm::Optional<uint64_t> GetDWOId();
static bool
DIEInDeclContext(const lldb_private::CompilerDeclContext *parent_decl_ctx,
DIEInDeclContext(const lldb_private::CompilerDeclContext &parent_decl_ctx,
const DWARFDIE &die);
std::vector<std::unique_ptr<lldb_private::CallEdge>>
@ -331,7 +331,7 @@ protected:
lldb_private::DWARFDataExtractor &data);
bool DeclContextMatchesThisSymbolFile(
const lldb_private::CompilerDeclContext *decl_ctx);
const lldb_private::CompilerDeclContext &decl_ctx);
uint32_t CalculateNumCompileUnits() override;

View File

@ -824,7 +824,7 @@ uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext(
}
void SymbolFileDWARFDebugMap::PrivateFindGlobalVariables(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
const std::vector<uint32_t>
&indexes, // Indexes into the symbol table that match "name"
uint32_t max_matches, VariableList &variables) {
@ -846,7 +846,7 @@ void SymbolFileDWARFDebugMap::PrivateFindGlobalVariables(
}
void SymbolFileDWARFDebugMap::FindGlobalVariables(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
uint32_t total_matches = 0;
@ -1000,7 +1000,7 @@ static void RemoveFunctionsWithModuleNotEqualTo(const ModuleSP &module_sp,
}
void SymbolFileDWARFDebugMap::FindFunctions(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines,
SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@ -1170,7 +1170,7 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
}
void SymbolFileDWARFDebugMap::FindTypes(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
@ -1207,7 +1207,7 @@ void SymbolFileDWARFDebugMap::FindTypes(
CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
lldb_private::ConstString name,
const CompilerDeclContext *parent_decl_ctx) {
const CompilerDeclContext &parent_decl_ctx) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
CompilerDeclContext matching_namespace;

View File

@ -105,14 +105,14 @@ public:
lldb_private::SymbolContextList &sc_list) override;
void
FindGlobalVariables(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
void FindGlobalVariables(const lldb_private::RegularExpression &regex,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
void FindFunctions(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
@ -121,7 +121,7 @@ public:
lldb_private::SymbolContextList &sc_list) override;
void
FindTypes(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
lldb_private::TypeMap &types) override;
@ -132,7 +132,7 @@ public:
lldb_private::TypeMap &types) override;
lldb_private::CompilerDeclContext FindNamespace(
lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
const lldb_private::CompilerDeclContext &parent_decl_ctx) override;
void GetTypes(lldb_private::SymbolContextScope *sc_scope,
lldb::TypeClass type_mask,
lldb_private::TypeList &type_list) override;
@ -254,7 +254,7 @@ protected:
void PrivateFindGlobalVariables(
lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
const std::vector<uint32_t> &name_symbol_indexes, uint32_t max_matches,
lldb_private::VariableList &variables);

View File

@ -1171,7 +1171,7 @@ size_t SymbolFileNativePDB::ParseBlocksRecursive(Function &func) {
void SymbolFileNativePDB::DumpClangAST(Stream &s) { m_ast->Dump(s); }
void SymbolFileNativePDB::FindGlobalVariables(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
@ -1198,7 +1198,7 @@ void SymbolFileNativePDB::FindGlobalVariables(
}
void SymbolFileNativePDB::FindFunctions(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines,
SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@ -1236,7 +1236,7 @@ void SymbolFileNativePDB::FindFunctions(const RegularExpression &regex,
SymbolContextList &sc_list) {}
void SymbolFileNativePDB::FindTypes(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@ -1563,7 +1563,7 @@ void SymbolFileNativePDB::GetTypes(lldb_private::SymbolContextScope *sc_scope,
CompilerDeclContext
SymbolFileNativePDB::FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) {
const CompilerDeclContext &parent_decl_ctx) {
return {};
}

View File

@ -100,7 +100,7 @@ public:
size_t ParseBlocksRecursive(Function &func) override;
void FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
VariableList &variables) override;
@ -129,14 +129,14 @@ public:
TypeList &type_list) override;
void FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, SymbolContextList &sc_list) override;
void FindFunctions(const RegularExpression &regex, bool include_inlines,
SymbolContextList &sc_list) override;
void FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
void FindTypes(ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) override;
@ -150,7 +150,7 @@ public:
CompilerDeclContext
FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) override;
const CompilerDeclContext &parent_decl_ctx) override;
ConstString GetPluginName() override;

View File

@ -1098,8 +1098,7 @@ SymbolFilePDB::ParseVariables(const lldb_private::SymbolContext &sc,
}
void SymbolFilePDB::FindGlobalVariables(
lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
lldb_private::ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, lldb_private::VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
@ -1131,8 +1130,8 @@ void SymbolFilePDB::FindGlobalVariables(
if (sc.comp_unit == nullptr)
continue;
if (parent_decl_ctx && GetDeclContextContainingUID(
result->getSymIndexId()) != *parent_decl_ctx)
if (parent_decl_ctx.IsValid() &&
GetDeclContextContainingUID(result->getSymIndexId()) != parent_decl_ctx)
continue;
ParseVariables(sc, *pdb_data, &variables);
@ -1296,7 +1295,7 @@ void SymbolFilePDB::CacheFunctionNames() {
void SymbolFilePDB::FindFunctions(
lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines,
lldb_private::SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@ -1325,8 +1324,8 @@ void SymbolFilePDB::FindFunctions(
if (resolved_ids.find(id) != resolved_ids.end())
continue;
if (parent_decl_ctx &&
GetDeclContextContainingUID(id) != *parent_decl_ctx)
if (parent_decl_ctx.IsValid() &&
GetDeclContextContainingUID(id) != parent_decl_ctx)
continue;
if (ResolveFunction(id, include_inlines, sc_list))
@ -1424,8 +1423,7 @@ void SymbolFilePDB::AddSymbols(lldb_private::Symtab &symtab) {
}
void SymbolFilePDB::FindTypes(
lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
lldb_private::ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
lldb_private::TypeMap &types) {
@ -1515,7 +1513,7 @@ void SymbolFilePDB::FindTypesByRegex(
void SymbolFilePDB::FindTypesByName(
llvm::StringRef name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, lldb_private::TypeMap &types) {
std::unique_ptr<IPDBEnumSymbols> results;
if (name.empty())
@ -1550,8 +1548,8 @@ void SymbolFilePDB::FindTypesByName(
if (!ResolveTypeUID(result->getSymIndexId()))
continue;
if (parent_decl_ctx && GetDeclContextContainingUID(
result->getSymIndexId()) != *parent_decl_ctx)
if (parent_decl_ctx.IsValid() &&
GetDeclContextContainingUID(result->getSymIndexId()) != parent_decl_ctx)
continue;
auto iter = m_types.find(result->getSymIndexId());
@ -1672,10 +1670,9 @@ PDBASTParser *SymbolFilePDB::GetPDBAstParser() {
return clang_type_system->GetPDBParser();
}
lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace(
lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx) {
lldb_private::CompilerDeclContext
SymbolFilePDB::FindNamespace(lldb_private::ConstString name,
const CompilerDeclContext &parent_decl_ctx) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
auto type_system_or_err =
GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
@ -1698,7 +1695,7 @@ lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace(
clang::DeclContext *decl_context = nullptr;
if (parent_decl_ctx)
decl_context = static_cast<clang::DeclContext *>(
parent_decl_ctx->GetOpaqueDeclContext());
parent_decl_ctx.GetOpaqueDeclContext());
auto namespace_decl =
pdb->FindNamespaceDecl(decl_context, name.GetStringRef());
@ -1972,11 +1969,11 @@ SymbolFilePDB::GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func) {
}
bool SymbolFilePDB::DeclContextMatchesThisSymbolFile(
const lldb_private::CompilerDeclContext *decl_ctx) {
if (decl_ctx == nullptr || !decl_ctx->IsValid())
const lldb_private::CompilerDeclContext &decl_ctx) {
if (!decl_ctx.IsValid())
return true;
TypeSystem *decl_ctx_type_system = decl_ctx->GetTypeSystem();
TypeSystem *decl_ctx_type_system = decl_ctx.GetTypeSystem();
if (!decl_ctx_type_system)
return false;
auto type_system_or_err = GetTypeSystemForLanguage(

View File

@ -112,7 +112,7 @@ public:
void
FindGlobalVariables(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
@ -121,7 +121,7 @@ public:
lldb_private::VariableList &variables) override;
void FindFunctions(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
@ -138,7 +138,7 @@ public:
void
FindTypes(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
lldb_private::TypeMap &types) override;
@ -160,7 +160,7 @@ public:
lldb_private::CompilerDeclContext FindNamespace(
lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
const lldb_private::CompilerDeclContext &parent_decl_ctx) override;
lldb_private::ConstString GetPluginName() override;
@ -195,7 +195,7 @@ private:
llvm::DenseMap<uint32_t, uint32_t> &index_map) const;
void FindTypesByName(llvm::StringRef name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, lldb_private::TypeMap &types);
std::string GetMangledForPDBData(const llvm::pdb::PDBSymbolData &pdb_data);
@ -242,7 +242,7 @@ private:
void CacheFunctionNames();
bool DeclContextMatchesThisSymbolFile(
const lldb_private::CompilerDeclContext *decl_ctx);
const lldb_private::CompilerDeclContext &decl_ctx);
uint32_t GetCompilandId(const llvm::pdb::PDBSymbolData &data);

View File

@ -105,7 +105,7 @@ uint32_t SymbolFile::ResolveSymbolContext(const FileSpec &file_spec,
}
void SymbolFile::FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
VariableList &variables) {}
@ -114,7 +114,7 @@ void SymbolFile::FindGlobalVariables(const RegularExpression &regex,
VariableList &variables) {}
void SymbolFile::FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
const CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines,
SymbolContextList &sc_list) {}
@ -130,7 +130,7 @@ void SymbolFile::GetMangledNamesForFunction(
}
void SymbolFile::FindTypes(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {}

View File

@ -395,7 +395,8 @@ opts::symbols::getDeclContext(SymbolFile &Symfile) {
if (Context.empty())
return CompilerDeclContext();
VariableList List;
Symfile.FindGlobalVariables(ConstString(Context), nullptr, UINT32_MAX, List);
Symfile.FindGlobalVariables(ConstString(Context), CompilerDeclContext(),
UINT32_MAX, List);
if (List.Empty())
return make_string_error("Context search didn't find a match.");
if (List.GetSize() > 1)
@ -442,8 +443,8 @@ Error opts::symbols::findFunctions(lldb_private::Module &Module) {
Expected<CompilerDeclContext> ContextOr = getDeclContext(Symfile);
if (!ContextOr)
return ContextOr.takeError();
CompilerDeclContext *ContextPtr =
ContextOr->IsValid() ? &*ContextOr : nullptr;
const CompilerDeclContext &ContextPtr =
ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
List.Clear();
Symfile.FindFunctions(ConstString(Name), ContextPtr, getFunctionNameFlags(),
@ -498,8 +499,8 @@ Error opts::symbols::findNamespaces(lldb_private::Module &Module) {
Expected<CompilerDeclContext> ContextOr = getDeclContext(Symfile);
if (!ContextOr)
return ContextOr.takeError();
CompilerDeclContext *ContextPtr =
ContextOr->IsValid() ? &*ContextOr : nullptr;
const CompilerDeclContext &ContextPtr =
ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
CompilerDeclContext Result =
Symfile.FindNamespace(ConstString(Name), ContextPtr);
@ -516,8 +517,8 @@ Error opts::symbols::findTypes(lldb_private::Module &Module) {
Expected<CompilerDeclContext> ContextOr = getDeclContext(Symfile);
if (!ContextOr)
return ContextOr.takeError();
CompilerDeclContext *ContextPtr =
ContextOr->IsValid() ? &*ContextOr : nullptr;
const CompilerDeclContext &ContextPtr =
ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
LanguageSet languages;
if (!Language.empty())
@ -566,8 +567,8 @@ Error opts::symbols::findVariables(lldb_private::Module &Module) {
Expected<CompilerDeclContext> ContextOr = getDeclContext(Symfile);
if (!ContextOr)
return ContextOr.takeError();
CompilerDeclContext *ContextPtr =
ContextOr->IsValid() ? &*ContextOr : nullptr;
const CompilerDeclContext &ContextPtr =
ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
Symfile.FindGlobalVariables(ConstString(Name), ContextPtr, UINT32_MAX, List);
}