Index: lldb/include/lldb/Core/Module.h =================================================================== --- lldb/include/lldb/Core/Module.h +++ lldb/include/lldb/Core/Module.h @@ -302,7 +302,7 @@ /// 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 @@ /// 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 @@ /// \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 @@ 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 &searched_symbol_files, TypeMap &types); Index: lldb/include/lldb/Symbol/SymbolFile.h =================================================================== --- lldb/include/lldb/Symbol/SymbolFile.h +++ lldb/include/lldb/Symbol/SymbolFile.h @@ -208,21 +208,21 @@ 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 ®ex, 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 ®ex, 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 &searched_symbol_files, TypeMap &types); @@ -251,8 +251,7 @@ GetTypeSystemForLanguage(lldb::LanguageType language); virtual CompilerDeclContext - FindNamespace(ConstString name, - const CompilerDeclContext *parent_decl_ctx) { + FindNamespace(ConstString name, const CompilerDeclContext &parent_decl_ctx) { return CompilerDeclContext(); } Index: lldb/source/API/SBModule.cpp =================================================================== --- lldb/source/API/SBModule.cpp +++ lldb/source/API/SBModule.cpp @@ -401,8 +401,8 @@ const bool symbols_ok = true; const bool inlines_ok = true; FunctionNameType type = static_cast(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 @@ 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()); Index: lldb/source/Breakpoint/BreakpointResolverName.cpp =================================================================== --- lldb/source/Breakpoint/BreakpointResolverName.cpp +++ lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -278,8 +278,9 @@ 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(); Index: lldb/source/Commands/CommandObjectTarget.cpp =================================================================== --- lldb/source/Commands/CommandObjectTarget.cpp +++ lldb/source/Commands/CommandObjectTarget.cpp @@ -1599,8 +1599,9 @@ 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) { Index: lldb/source/Core/AddressResolverName.cpp =================================================================== --- lldb/source/Core/AddressResolverName.cpp +++ lldb/source/Core/AddressResolverName.cpp @@ -91,7 +91,7 @@ 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); } Index: lldb/source/Core/Disassembler.cpp =================================================================== --- lldb/source/Core/Disassembler.cpp +++ lldb/source/Core/Disassembler.cpp @@ -173,8 +173,8 @@ // 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); Index: lldb/source/Core/Module.cpp =================================================================== --- lldb/source/Core/Module.cpp +++ lldb/source/Core/Module.cpp @@ -595,7 +595,7 @@ } 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::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::FindTypes_Impl( - ConstString name, const CompilerDeclContext *parent_decl_ctx, + ConstString name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { @@ -932,7 +932,7 @@ } 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 searched_symbol_files; @@ -974,7 +974,7 @@ 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 @@ 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, Index: lldb/source/Core/ModuleList.cpp =================================================================== --- lldb/source/Core/ModuleList.cpp +++ lldb/source/Core/ModuleList.cpp @@ -363,7 +363,7 @@ std::lock_guard 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 @@ std::lock_guard 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 @@ std::lock_guard 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); } } Index: lldb/source/Core/SourceManager.cpp =================================================================== --- lldb/source/Core/SourceManager.cpp +++ lldb/source/Core/SourceManager.cpp @@ -325,7 +325,7 @@ 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(); Index: lldb/source/Expression/IRExecutionUnit.cpp =================================================================== --- lldb/source/Expression/IRExecutionUnit.cpp +++ lldb/source/Expression/IRExecutionUnit.cpp @@ -843,7 +843,7 @@ }; 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); Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -252,7 +252,7 @@ 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 @@ 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 @@ 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 @@ const bool exact_match = true; llvm::DenseSet 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 @@ 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 @@ continue; found_namespace_decl = - symbol_file->FindNamespace(name, &null_namespace_decl); + symbol_file->FindNamespace(name, null_namespace_decl); if (!found_namespace_decl) continue; Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -597,7 +597,7 @@ 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 @@ 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; Index: lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp =================================================================== --- lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp +++ lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp @@ -573,7 +573,7 @@ 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; Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp =================================================================== --- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -3943,7 +3943,8 @@ 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(); Index: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h =================================================================== --- lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h +++ lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h @@ -82,7 +82,7 @@ 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 @@ 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 ®ex, 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 &searched_symbol_files, TypeMap &types) override; @@ -135,7 +135,7 @@ CompilerDeclContext FindNamespace(ConstString name, - const CompilerDeclContext *parent_decl_ctx) override { + const CompilerDeclContext &parent_decl_ctx) override { return CompilerDeclContext(); } Index: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp +++ lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp @@ -294,7 +294,7 @@ } 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::FindTypes( - ConstString name, const CompilerDeclContext *parent_decl_ctx, + ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) {} Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp @@ -36,7 +36,7 @@ // 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. Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -406,7 +406,7 @@ 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 @@ 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(); Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -166,7 +166,7 @@ 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 @@ 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 @@ 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 &searched_symbol_files, lldb_private::TypeMap &types) override; @@ -209,7 +209,7 @@ 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 @@ llvm::Optional GetDWOId(); static bool - DIEInDeclContext(const lldb_private::CompilerDeclContext *parent_decl_ctx, + DIEInDeclContext(const lldb_private::CompilerDeclContext &parent_decl_ctx, const DWARFDIE &die); std::vector> @@ -331,7 +331,7 @@ lldb_private::DWARFDataExtractor &data); bool DeclContextMatchesThisSymbolFile( - const lldb_private::CompilerDeclContext *decl_ctx); + const lldb_private::CompilerDeclContext &decl_ctx); uint32_t CalculateNumCompileUnits() override; Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -2008,15 +2008,15 @@ } 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()) { @@ -2040,7 +2040,7 @@ } 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 guard(GetModuleMutex()); Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); @@ -2050,7 +2050,7 @@ log, "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", " "parent_decl_ctx=%p, max_matches=%u, variables)", - name.GetCString(), static_cast(parent_decl_ctx), + name.GetCString(), static_cast(&parent_decl_ctx), max_matches); if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) @@ -2108,7 +2108,7 @@ 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; } } @@ -2141,7 +2141,7 @@ log, "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", " "parent_decl_ctx=%p, max_matches=%u, variables) => %u", - name.GetCString(), static_cast(parent_decl_ctx), + name.GetCString(), static_cast(&parent_decl_ctx), max_matches, num_matches); } } @@ -2253,26 +2253,26 @@ 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) { @@ -2308,12 +2308,9 @@ llvm::DenseSet resolved_dies; DIEArray offsets; - CompilerDeclContext empty_decl_ctx; - if (!parent_decl_ctx) - parent_decl_ctx = &empty_decl_ctx; std::vector 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); @@ -2393,7 +2390,7 @@ } void SymbolFileDWARF::FindTypes( - ConstString name, const CompilerDeclContext *parent_decl_ctx, + ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { @@ -2414,8 +2411,8 @@ log, "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = " "%p (\"%s\"), max_matches=%u, type_list)", - name.GetCString(), static_cast(parent_decl_ctx), - parent_decl_ctx->GetName().AsCString(""), max_matches); + name.GetCString(), static_cast(&parent_decl_ctx), + parent_decl_ctx.GetName().AsCString(""), max_matches); else GetObjectFile()->GetModule()->LogMessage( log, @@ -2470,8 +2467,8 @@ log, "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx " "= %p (\"%s\"), max_matches=%u, type_list) => %u", - name.GetCString(), static_cast(parent_decl_ctx), - parent_decl_ctx->GetName().AsCString(""), max_matches, + name.GetCString(), static_cast(&parent_decl_ctx), + parent_decl_ctx.GetName().AsCString(""), max_matches, types.GetSize()); } else { GetObjectFile()->GetModule()->LogMessage( @@ -2539,7 +2536,7 @@ CompilerDeclContext SymbolFileDWARF::FindNamespace(ConstString name, - const CompilerDeclContext *parent_decl_ctx) { + const CompilerDeclContext &parent_decl_ctx) { std::lock_guard guard(GetModuleMutex()); Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -105,14 +105,14 @@ 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 ®ex, 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 @@ 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 &searched_symbol_files, lldb_private::TypeMap &types) override; @@ -132,7 +132,7 @@ 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 @@ void PrivateFindGlobalVariables( lldb_private::ConstString name, - const lldb_private::CompilerDeclContext *parent_decl_ctx, + const lldb_private::CompilerDeclContext &parent_decl_ctx, const std::vector &name_symbol_indexes, uint32_t max_matches, lldb_private::VariableList &variables); Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -824,7 +824,7 @@ } void SymbolFileDWARFDebugMap::PrivateFindGlobalVariables( - ConstString name, const CompilerDeclContext *parent_decl_ctx, + ConstString name, const CompilerDeclContext &parent_decl_ctx, const std::vector &indexes, // Indexes into the symbol table that match "name" uint32_t max_matches, VariableList &variables) { @@ -846,7 +846,7 @@ } 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 guard(GetModuleMutex()); uint32_t total_matches = 0; @@ -1000,7 +1000,7 @@ } 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 guard(GetModuleMutex()); @@ -1170,7 +1170,7 @@ } void SymbolFileDWARFDebugMap::FindTypes( - ConstString name, const CompilerDeclContext *parent_decl_ctx, + ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { @@ -1207,7 +1207,7 @@ CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace( lldb_private::ConstString name, - const CompilerDeclContext *parent_decl_ctx) { + const CompilerDeclContext &parent_decl_ctx) { std::lock_guard guard(GetModuleMutex()); CompilerDeclContext matching_namespace; Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h =================================================================== --- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h +++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h @@ -100,7 +100,7 @@ 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 @@ 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 ®ex, 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 &searched_symbol_files, TypeMap &types) override; @@ -150,7 +150,7 @@ CompilerDeclContext FindNamespace(ConstString name, - const CompilerDeclContext *parent_decl_ctx) override; + const CompilerDeclContext &parent_decl_ctx) override; ConstString GetPluginName() override; Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -1171,7 +1171,7 @@ 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 guard(GetModuleMutex()); using SymbolAndOffset = std::pair; @@ -1198,7 +1198,7 @@ } 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 guard(GetModuleMutex()); @@ -1236,7 +1236,7 @@ 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 &searched_symbol_files, TypeMap &types) { std::lock_guard guard(GetModuleMutex()); @@ -1563,7 +1563,7 @@ CompilerDeclContext SymbolFileNativePDB::FindNamespace(ConstString name, - const CompilerDeclContext *parent_decl_ctx) { + const CompilerDeclContext &parent_decl_ctx) { return {}; } Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h =================================================================== --- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h +++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h @@ -112,7 +112,7 @@ 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 @@ 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 @@ 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 &searched_symbol_files, lldb_private::TypeMap &types) override; @@ -160,7 +160,7 @@ 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 @@ llvm::DenseMap &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 @@ void CacheFunctionNames(); bool DeclContextMatchesThisSymbolFile( - const lldb_private::CompilerDeclContext *decl_ctx); + const lldb_private::CompilerDeclContext &decl_ctx); uint32_t GetCompilandId(const llvm::pdb::PDBSymbolData &data); Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -1098,8 +1098,7 @@ } 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 guard(GetModuleMutex()); if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) @@ -1131,8 +1130,8 @@ 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::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 guard(GetModuleMutex()); @@ -1325,8 +1324,8 @@ 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::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 &searched_symbol_files, lldb_private::TypeMap &types) { @@ -1515,7 +1513,7 @@ 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 results; if (name.empty()) @@ -1550,8 +1548,8 @@ 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 @@ 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 guard(GetModuleMutex()); auto type_system_or_err = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); @@ -1698,7 +1695,7 @@ clang::DeclContext *decl_context = nullptr; if (parent_decl_ctx) decl_context = static_cast( - parent_decl_ctx->GetOpaqueDeclContext()); + parent_decl_ctx.GetOpaqueDeclContext()); auto namespace_decl = pdb->FindNamespaceDecl(decl_context, name.GetStringRef()); @@ -1972,11 +1969,11 @@ } 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( Index: lldb/source/Symbol/SymbolFile.cpp =================================================================== --- lldb/source/Symbol/SymbolFile.cpp +++ lldb/source/Symbol/SymbolFile.cpp @@ -105,7 +105,7 @@ } 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 @@ 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::FindTypes( - ConstString name, const CompilerDeclContext *parent_decl_ctx, + ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) {} Index: lldb/tools/lldb-test/lldb-test.cpp =================================================================== --- lldb/tools/lldb-test/lldb-test.cpp +++ lldb/tools/lldb-test/lldb-test.cpp @@ -395,7 +395,8 @@ 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 @@ Expected 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 @@ Expected 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 @@ Expected 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 @@ Expected 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); }