diff options
30 files changed, 111 insertions, 169 deletions
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 8d954fb4123..270a401172f 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -499,10 +499,6 @@ public: /// have to specify complete scoping on all expressions, but it also allows /// for exact matching when required. /// - /// @param[in] sc - /// A symbol context that scopes where to extract a type list - /// from. - /// /// @param[in] type_name /// The name of the type we are looking for that is a fully /// or partially qualified type name. @@ -521,8 +517,7 @@ public: /// The number of matches added to \a type_list. //------------------------------------------------------------------ size_t - FindTypes(const SymbolContext &sc, const ConstString &type_name, - bool exact_match, size_t max_matches, + FindTypes(const ConstString &type_name, bool exact_match, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeList &types); @@ -534,10 +529,6 @@ public: /// expression parser when searches need to happen in an exact namespace /// scope. /// - /// @param[in] sc - /// A symbol context that scopes where to extract a type list - /// from. - /// /// @param[in] type_name /// The name of a type within a namespace that should not include /// any qualifying namespaces (just a type basename). @@ -551,8 +542,7 @@ public: /// @return /// The number of matches added to \a type_list. //------------------------------------------------------------------ - size_t FindTypesInNamespace(const SymbolContext &sc, - const ConstString &type_name, + size_t FindTypesInNamespace(const ConstString &type_name, const CompilerDeclContext *parent_decl_ctx, size_t max_matches, TypeList &type_list); @@ -1182,9 +1172,8 @@ private: Module(); // Only used internally by CreateJITModule () size_t FindTypes_Impl( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - size_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index c1c2c78680c..a28d97113d6 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -417,9 +417,9 @@ public: //------------------------------------------------------------------ /// Find types by name. /// - /// @param[in] sc - /// A symbol context that scopes where to extract a type list - /// from. + /// @param[in] search_first + /// If non-null, this module will be searched before any other + /// modules. /// /// @param[in] name /// The name of the type we are looking for. @@ -447,7 +447,7 @@ public: /// @return /// The number of matches added to \a type_list. //------------------------------------------------------------------ - size_t FindTypes(const SymbolContext &sc, const ConstString &name, + size_t FindTypes(Module *search_first, const ConstString &name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeList &types) const; diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index 4fd549b57b0..433c20da99e 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -193,9 +193,8 @@ public: bool include_inlines, bool append, SymbolContextList &sc_list); virtual uint32_t - FindTypes(const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - uint32_t max_matches, + FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); virtual size_t FindTypes(const std::vector<CompilerContext> &context, diff --git a/lldb/include/lldb/Symbol/SymbolVendor.h b/lldb/include/lldb/Symbol/SymbolVendor.h index 67375d36497..d48f646d52c 100644 --- a/lldb/include/lldb/Symbol/SymbolVendor.h +++ b/lldb/include/lldb/Symbol/SymbolVendor.h @@ -99,9 +99,8 @@ public: SymbolContextList &sc_list); virtual size_t - FindTypes(const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - size_t max_matches, + FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 183eae1c2e9..31980793bce 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -440,13 +440,12 @@ lldb::SBTypeList SBModule::FindTypes(const char *type) { ModuleSP module_sp(GetSP()); if (type && module_sp) { - SymbolContext sc; TypeList type_list; const bool exact_match = false; ConstString name(type); llvm::DenseSet<SymbolFile *> searched_symbol_files; const uint32_t num_matches = module_sp->FindTypes( - sc, name, exact_match, UINT32_MAX, searched_symbol_files, type_list); + name, exact_match, UINT32_MAX, searched_symbol_files, type_list); if (num_matches > 0) { for (size_t idx = 0; idx < num_matches; idx++) { diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index e25fa3135fb..98587e7d767 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1850,11 +1850,10 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { ModuleList &images = target_sp->GetImages(); ConstString const_typename(typename_cstr); bool exact_match = false; - SymbolContext sc; TypeList type_list; llvm::DenseSet<SymbolFile *> searched_symbol_files; uint32_t num_matches = - images.FindTypes(sc, const_typename, exact_match, UINT32_MAX, + images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX, searched_symbol_files, type_list); if (num_matches > 0) { diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index e2cde444caf..310bc848b59 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -382,7 +382,6 @@ protected: if (view_as_type_cstr && view_as_type_cstr[0]) { // We are viewing memory as a type - SymbolContext sc; const bool exact_match = false; TypeList type_list; uint32_t reference_count = 0; @@ -467,17 +466,13 @@ protected: llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files; ConstString lookup_type_name(type_str.c_str()); StackFrame *frame = m_exe_ctx.GetFramePtr(); + ModuleSP search_first; if (frame) { - sc = frame->GetSymbolContext(eSymbolContextModule); - if (sc.module_sp) { - sc.module_sp->FindTypes(sc, lookup_type_name, exact_match, 1, - searched_symbol_files, type_list); - } - } - if (type_list.GetSize() == 0) { - target->GetImages().FindTypes(sc, lookup_type_name, exact_match, 1, - searched_symbol_files, type_list); + search_first = frame->GetSymbolContext(eSymbolContextModule).module_sp; } + target->GetImages().FindTypes(search_first.get(), lookup_type_name, + exact_match, 1, searched_symbol_files, + type_list); if (type_list.GetSize() == 0 && lookup_type_name.GetCString() && *lookup_type_name.GetCString() == '$') { diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 4a4d0d2d609..ee55b22c5ea 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -1672,12 +1672,11 @@ static size_t LookupTypeInModule(CommandInterpreter &interpreter, Stream &strm, const uint32_t max_num_matches = UINT32_MAX; size_t num_matches = 0; bool name_is_fully_qualified = false; - SymbolContext sc; ConstString name(name_cstr); llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files; num_matches = - module->FindTypes(sc, name, name_is_fully_qualified, max_num_matches, + module->FindTypes(name, name_is_fully_qualified, max_num_matches, searched_symbol_files, type_list); if (num_matches) { @@ -1715,11 +1714,8 @@ static size_t LookupTypeInModule(CommandInterpreter &interpreter, Stream &strm, } static size_t LookupTypeHere(CommandInterpreter &interpreter, Stream &strm, - const SymbolContext &sym_ctx, - const char *name_cstr, bool name_is_regex) { - if (!sym_ctx.module_sp) - return 0; - + Module &module, const char *name_cstr, + bool name_is_regex) { TypeList type_list; const uint32_t max_num_matches = UINT32_MAX; size_t num_matches = 1; @@ -1727,14 +1723,13 @@ static size_t LookupTypeHere(CommandInterpreter &interpreter, Stream &strm, ConstString name(name_cstr); llvm::DenseSet<SymbolFile *> searched_symbol_files; - num_matches = sym_ctx.module_sp->FindTypes( - sym_ctx, name, name_is_fully_qualified, max_num_matches, - searched_symbol_files, type_list); + num_matches = module.FindTypes(name, name_is_fully_qualified, max_num_matches, + searched_symbol_files, type_list); if (num_matches) { strm.Indent(); strm.PutCString("Best match found in "); - DumpFullpath(strm, &sym_ctx.module_sp->GetFileSpec(), 0); + DumpFullpath(strm, &module.GetFileSpec(), 0); strm.PutCString(":\n"); TypeSP type_sp(type_list.GetTypeAtIndex(0)); @@ -3832,8 +3827,9 @@ public: return false; case eLookupTypeType: if (!m_options.m_str.empty()) { - if (LookupTypeHere(m_interpreter, result.GetOutputStream(), sym_ctx, - m_options.m_str.c_str(), m_options.m_use_regex)) { + if (LookupTypeHere(m_interpreter, result.GetOutputStream(), + *sym_ctx.module_sp, m_options.m_str.c_str(), + m_options.m_use_regex)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; } diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 3e3a1e0c3de..b48d3cca092 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -943,33 +943,33 @@ void Module::FindAddressesForLine(const lldb::TargetSP target_sp, } size_t Module::FindTypes_Impl( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION); - if (!sc.module_sp || sc.module_sp.get() == this) { - SymbolVendor *symbols = GetSymbolVendor(); - if (symbols) - return symbols->FindTypes(sc, name, parent_decl_ctx, append, max_matches, - searched_symbol_files, types); - } + SymbolVendor *symbols = GetSymbolVendor(); + if (symbols) + return symbols->FindTypes(name, parent_decl_ctx, append, max_matches, + searched_symbol_files, types); return 0; } -size_t Module::FindTypesInNamespace(const SymbolContext &sc, - const ConstString &type_name, +size_t Module::FindTypesInNamespace(const ConstString &type_name, const CompilerDeclContext *parent_decl_ctx, size_t max_matches, TypeList &type_list) { const bool append = true; TypeMap types_map; llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files; size_t num_types = - FindTypes_Impl(sc, type_name, parent_decl_ctx, append, max_matches, + FindTypes_Impl(type_name, parent_decl_ctx, append, max_matches, searched_symbol_files, types_map); - if (num_types > 0) + if (num_types > 0) { + SymbolContext sc; + sc.module_sp = shared_from_this(); sc.SortTypeList(types_map, type_list); + } return num_types; } @@ -978,15 +978,14 @@ lldb::TypeSP Module::FindFirstType(const SymbolContext &sc, TypeList type_list; llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files; const size_t num_matches = - FindTypes(sc, name, exact_match, 1, searched_symbol_files, type_list); + FindTypes(name, exact_match, 1, searched_symbol_files, type_list); if (num_matches) return type_list.GetTypeAtIndex(0); return TypeSP(); } size_t Module::FindTypes( - const SymbolContext &sc, const ConstString &name, bool exact_match, - size_t max_matches, + const ConstString &name, bool exact_match, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeList &types) { size_t num_matches = 0; @@ -1006,8 +1005,8 @@ size_t Module::FindTypes( exact_match = type_scope.consume_front("::"); ConstString type_basename_const_str(type_basename); - if (FindTypes_Impl(sc, type_basename_const_str, nullptr, append, - max_matches, searched_symbol_files, typesmap)) { + if (FindTypes_Impl(type_basename_const_str, nullptr, append, max_matches, + searched_symbol_files, typesmap)) { typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class, exact_match); num_matches = typesmap.GetSize(); @@ -1018,13 +1017,13 @@ size_t 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(sc, ConstString(type_basename), nullptr, append, - UINT_MAX, searched_symbol_files, typesmap); + FindTypes_Impl(ConstString(type_basename), nullptr, append, UINT_MAX, + searched_symbol_files, typesmap); typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class, exact_match); num_matches = typesmap.GetSize(); } else { - num_matches = FindTypes_Impl(sc, name, nullptr, append, UINT_MAX, + num_matches = FindTypes_Impl(name, nullptr, append, UINT_MAX, searched_symbol_files, typesmap); if (exact_match) { std::string name_str(name.AsCString("")); @@ -1034,8 +1033,11 @@ size_t Module::FindTypes( } } } - if (num_matches > 0) + if (num_matches > 0) { + SymbolContext sc; + sc.module_sp = shared_from_this(); sc.SortTypeList(typesmap, types); + } return num_matches; } diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 38eb29aa0de..b8de86f4ead 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -542,7 +542,7 @@ ModuleSP ModuleList::FindModule(const UUID &uuid) const { } size_t -ModuleList::FindTypes(const SymbolContext &sc, const ConstString &name, +ModuleList::FindTypes(Module *search_first, const ConstString &name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeList &types) const { @@ -550,14 +550,12 @@ ModuleList::FindTypes(const SymbolContext &sc, const ConstString &name, size_t total_matches = 0; collection::const_iterator pos, end = m_modules.end(); - if (sc.module_sp) { - // The symbol context "sc" contains a module so we want to search that one - // first if it is in our list... + if (search_first) { for (pos = m_modules.begin(); pos != end; ++pos) { - if (sc.module_sp.get() == (*pos).get()) { + if (search_first == pos->get()) { total_matches += - (*pos)->FindTypes(sc, name, name_is_fully_qualified, max_matches, - searched_symbol_files, types); + search_first->FindTypes(name, name_is_fully_qualified, max_matches, + searched_symbol_files, types); if (total_matches >= max_matches) break; @@ -566,15 +564,14 @@ ModuleList::FindTypes(const SymbolContext &sc, const ConstString &name, } if (total_matches < max_matches) { - SymbolContext world_sc; for (pos = m_modules.begin(); pos != end; ++pos) { // Search the module if the module is not equal to the one in the symbol // context "sc". If "sc" contains a empty module shared pointer, then the // comparison will always be true (valid_module_ptr != nullptr). - if (sc.module_sp.get() != (*pos).get()) + if (search_first != pos->get()) total_matches += - (*pos)->FindTypes(world_sc, name, name_is_fully_qualified, - max_matches, searched_symbol_files, types); + (*pos)->FindTypes(name, name_is_fully_qualified, max_matches, + searched_symbol_files, types); if (total_matches >= max_matches) break; diff --git a/lldb/source/DataFormatters/TypeFormat.cpp b/lldb/source/DataFormatters/TypeFormat.cpp index 1e8bc716204..a7520300647 100644 --- a/lldb/source/DataFormatters/TypeFormat.cpp +++ b/lldb/source/DataFormatters/TypeFormat.cpp @@ -159,11 +159,10 @@ bool TypeFormatImpl_EnumType::FormatObject(ValueObject *valobj, if (!target_sp) return false; const ModuleList &images(target_sp->GetImages()); - SymbolContext sc; TypeList types; llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files; - images.FindTypes(sc, m_enum_type, false, UINT32_MAX, searched_symbol_files, - types); + images.FindTypes(nullptr, m_enum_type, false, UINT32_MAX, + searched_symbol_files, types); if (types.GetSize() == 0) return false; for (lldb::TypeSP type_sp : types.Types()) { diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index 087798bea9a..84771e59531 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -332,11 +332,9 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) { TypeList types; - SymbolContext null_sc; ConstString name(tag_decl->getName().str().c_str()); - i->first->FindTypesInNamespace(null_sc, 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); @@ -366,7 +364,6 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) { } else { TypeList types; - SymbolContext null_sc; ConstString name(tag_decl->getName().str().c_str()); CompilerDeclContext namespace_decl; @@ -374,7 +371,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) { bool exact_match = false; llvm::DenseSet<SymbolFile *> searched_symbol_files; - module_list.FindTypes(null_sc, name, exact_match, UINT32_MAX, + module_list.FindTypes(nullptr, name, exact_match, UINT32_MAX, searched_symbol_files, types); for (uint32_t ti = 0, te = types.GetSize(); ti != te && !found; ++ti) { @@ -854,15 +851,12 @@ void ClangASTSource::FindExternalVisibleDecls( break; TypeList types; - SymbolContext null_sc; const bool exact_match = true; llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files; if (module_sp && namespace_decl) - module_sp->FindTypesInNamespace(null_sc, name, &namespace_decl, 1, types); + module_sp->FindTypesInNamespace(name, &namespace_decl, 1, types); else { - SymbolContext sc; - sc.module_sp = module_sp; - m_target->GetImages().FindTypes(sc, name, exact_match, 1, + m_target->GetImages().FindTypes(module_sp.get(), name, exact_match, 1, searched_symbol_files, types); } diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp index 128eb30ebda..49a3d40d7b3 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -101,7 +101,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress( llvm::DenseSet<SymbolFile *> searched_symbol_files; if (sc.module_sp) { num_matches = sc.module_sp->FindTypes( - sc, ConstString(lookup_name), exact_match, 1, + ConstString(lookup_name), exact_match, 1, searched_symbol_files, class_types); } @@ -109,7 +109,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress( // list in the target and get as many unique matches as possible if (num_matches == 0) { num_matches = target.GetImages().FindTypes( - sc, ConstString(lookup_name), exact_match, UINT32_MAX, + nullptr, ConstString(lookup_name), exact_match, UINT32_MAX, searched_symbol_files, class_types); } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp index 105c088b9e9..4fc340b23c2 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp @@ -558,7 +558,7 @@ AppleObjCDeclVendor::FindDecls(const ConstString &name, bool append, LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel? if (log) - log->Printf("AppleObjCDeclVendor::FindTypes [%u] ('%s', %s, %u, )", + log->Printf("AppleObjCDeclVendor::FindDecls [%u] ('%s', %s, %u, )", current_id, (const char *)name.AsCString(), append ? "true" : "false", max_matches); diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp index 237bcf8dc37..2cca7a66b01 100644 --- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp +++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp @@ -153,10 +153,9 @@ uint32_t SymbolFileBreakpad::FindFunctions(const RegularExpression ®ex, } uint32_t SymbolFileBreakpad::FindTypes( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files, - TypeMap &types) { + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, + llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeMap &types) { if (!append) types.Clear(); return types.GetSize(); diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h index 1a71f22a39f..68e8d11c7dd 100644 --- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h +++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h @@ -113,7 +113,7 @@ public: uint32_t FindFunctions(const RegularExpression ®ex, bool include_inlines, bool append, SymbolContextList &sc_list) override; - uint32_t FindTypes(const SymbolContext &sc, const ConstString &name, + uint32_t FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index b39ab888290..2a0a89f0b25 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -2437,9 +2437,8 @@ void SymbolFileDWARF::GetMangledNamesForFunction( } uint32_t SymbolFileDWARF::FindTypes( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - uint32_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types) { // If we aren't appending the results to this list, then clear the list @@ -2528,8 +2527,8 @@ uint32_t SymbolFileDWARF::FindTypes( SymbolVendor *sym_vendor = external_module_sp->GetSymbolVendor(); if (sym_vendor) { const uint32_t num_external_matches = - sym_vendor->FindTypes(sc, name, parent_decl_ctx, append, - max_matches, searched_symbol_files, types); + sym_vendor->FindTypes(name, parent_decl_ctx, append, max_matches, + searched_symbol_files, types); if (num_external_matches) return num_external_matches; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 664cda046f1..d351289f8b5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -193,8 +193,7 @@ public: std::vector<lldb_private::ConstString> &mangled_names) override; uint32_t - FindTypes(const lldb_private::SymbolContext &sc, - const lldb_private::ConstString &name, + FindTypes(const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 2e9b6c012eb..45350ae348d 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1180,9 +1180,8 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE( } uint32_t SymbolFileDWARFDebugMap::FindTypes( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - uint32_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types) { if (!append) @@ -1191,18 +1190,11 @@ uint32_t SymbolFileDWARFDebugMap::FindTypes( const uint32_t initial_types_size = types.GetSize(); SymbolFileDWARF *oso_dwarf; - if (sc.comp_unit) { - oso_dwarf = GetSymbolFile(sc); - if (oso_dwarf) - return oso_dwarf->FindTypes(sc, name, parent_decl_ctx, append, - max_matches, searched_symbol_files, types); - } else { - ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { - oso_dwarf->FindTypes(sc, name, parent_decl_ctx, append, max_matches, - searched_symbol_files, types); - return types.GetSize() >= max_matches; - }); - } + ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { + oso_dwarf->FindTypes(name, parent_decl_ctx, append, max_matches, + searched_symbol_files, types); + return types.GetSize() >= max_matches; + }); return types.GetSize() - initial_types_size; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 04cc70d02b7..176eadeeca7 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -116,8 +116,7 @@ public: bool include_inlines, bool append, lldb_private::SymbolContextList &sc_list) override; uint32_t - FindTypes(const lldb_private::SymbolContext &sc, - const lldb_private::ConstString &name, + FindTypes(const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index fa839d57a35..7e97e2b3772 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -1219,10 +1219,9 @@ uint32_t SymbolFileNativePDB::FindFunctions(const RegularExpression ®ex, } uint32_t SymbolFileNativePDB::FindTypes( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files, - TypeMap &types) { + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, + llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeMap &types) { if (!append) types.Clear(); if (!name) diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h index 6c3410ec498..dcf3fe365ef 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h @@ -139,7 +139,7 @@ public: uint32_t FindFunctions(const RegularExpression ®ex, bool include_inlines, bool append, SymbolContextList &sc_list) override; - uint32_t FindTypes(const SymbolContext &sc, const ConstString &name, + uint32_t FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files, diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index c5658d5bb5b..ad25842f4d0 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -1376,7 +1376,6 @@ void SymbolFilePDB::AddSymbols(lldb_private::Symtab &symtab) { } uint32_t SymbolFilePDB::FindTypes( - const lldb_private::SymbolContext &sc, const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h index 0eb48620f06..81288093b7d 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h @@ -137,8 +137,7 @@ public: void AddSymbols(lldb_private::Symtab &symtab) override; uint32_t - FindTypes(const lldb_private::SymbolContext &sc, - const lldb_private::ConstString &name, + FindTypes(const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp index d4408780b42..6087374969f 100644 --- a/lldb/source/Symbol/SymbolFile.cpp +++ b/lldb/source/Symbol/SymbolFile.cpp @@ -140,9 +140,8 @@ void SymbolFile::GetMangledNamesForFunction( } uint32_t SymbolFile::FindTypes( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - uint32_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types) { if (!append) diff --git a/lldb/source/Symbol/SymbolVendor.cpp b/lldb/source/Symbol/SymbolVendor.cpp index 26420f09f3e..a9badc15a5d 100644 --- a/lldb/source/Symbol/SymbolVendor.cpp +++ b/lldb/source/Symbol/SymbolVendor.cpp @@ -310,15 +310,15 @@ size_t SymbolVendor::FindFunctions(const RegularExpression ®ex, } size_t SymbolVendor::FindTypes( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->FindTypes(sc, name, parent_decl_ctx, append, + return m_sym_file_ap->FindTypes(name, parent_decl_ctx, append, max_matches, searched_symbol_files, types); } diff --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp index 599b4422274..5c7a4097dd6 100644 --- a/lldb/source/Target/Language.cpp +++ b/lldb/source/Target/Language.cpp @@ -385,11 +385,10 @@ bool Language::ImageListTypeScavenger::Find_Impl( Target *target = exe_scope->CalculateTarget().get(); if (target) { const auto &images(target->GetImages()); - SymbolContext null_sc; ConstString cs_key(key); llvm::DenseSet<SymbolFile *> searched_sym_files; TypeList matches; - images.FindTypes(null_sc, cs_key, false, UINT32_MAX, searched_sym_files, + images.FindTypes(nullptr, cs_key, false, UINT32_MAX, searched_sym_files, matches); for (const auto &match : matches.Types()) { if (match.get()) { diff --git a/lldb/source/Target/ObjCLanguageRuntime.cpp b/lldb/source/Target/ObjCLanguageRuntime.cpp index b1fcee6db63..8627da938ea 100644 --- a/lldb/source/Target/ObjCLanguageRuntime.cpp +++ b/lldb/source/Target/ObjCLanguageRuntime.cpp @@ -108,14 +108,13 @@ ObjCLanguageRuntime::LookupInCompleteClassCache(ConstString &name) { if (!module_sp) return TypeSP(); - const SymbolContext null_sc; const bool exact_match = true; const uint32_t max_matches = UINT32_MAX; TypeList types; llvm::DenseSet<SymbolFile *> searched_symbol_files; const uint32_t num_types = module_sp->FindTypes( - null_sc, name, exact_match, max_matches, searched_symbol_files, types); + name, exact_match, max_matches, searched_symbol_files, types); if (num_types) { uint32_t i; diff --git a/lldb/tools/lldb-test/lldb-test.cpp b/lldb/tools/lldb-test/lldb-test.cpp index 92c178098a1..f7bfc487c0c 100644 --- a/lldb/tools/lldb-test/lldb-test.cpp +++ b/lldb/tools/lldb-test/lldb-test.cpp @@ -459,10 +459,9 @@ Error opts::symbols::findTypes(lldb_private::Module &Module) { CompilerDeclContext *ContextPtr = ContextOr->IsValid() ? &*ContextOr : nullptr; - SymbolContext SC; DenseSet<SymbolFile *> SearchedFiles; TypeMap Map; - Vendor.FindTypes(SC, ConstString(Name), ContextPtr, true, UINT32_MAX, + Vendor.FindTypes(ConstString(Name), ContextPtr, true, UINT32_MAX, SearchedFiles, Map); outs() << formatv("Found {0} types:\n", Map.GetSize()); diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp index 15c55611cf5..33b520e792e 100644 --- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp +++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp @@ -366,10 +366,9 @@ TEST_F(SymbolFilePDBTests, TestSimpleClassTypes) { SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile()); llvm::pdb::IPDBSession &session = symfile->GetPDBSession(); - SymbolContext sc; llvm::DenseSet<SymbolFile *> searched_files; TypeMap results; - EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("Class"), nullptr, false, 0, + EXPECT_EQ(1u, symfile->FindTypes(ConstString("Class"), nullptr, false, 0, searched_files, results)); EXPECT_EQ(1u, results.GetSize()); lldb::TypeSP udt_type = results.GetTypeAtIndex(0); @@ -389,7 +388,6 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) { SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile()); llvm::pdb::IPDBSession &session = symfile->GetPDBSession(); - SymbolContext sc; llvm::DenseSet<SymbolFile *> searched_files; TypeMap results; @@ -397,7 +395,7 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) { symfile->GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus)); EXPECT_NE(nullptr, clang_ast_ctx); - EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("Class"), nullptr, false, 0, + EXPECT_EQ(1u, symfile->FindTypes(ConstString("Class"), nullptr, false, 0, searched_files, results)); EXPECT_EQ(1u, results.GetSize()); @@ -416,7 +414,7 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) { // compiler type for both, but `FindTypes` may return more than one type // (with the same compiler type) because the symbols have different IDs. auto ClassCompilerDeclCtx = CompilerDeclContext(clang_ast_ctx, ClassDeclCtx); - EXPECT_LE(1u, symfile->FindTypes(sc, ConstString("NestedClass"), + EXPECT_LE(1u, symfile->FindTypes(ConstString("NestedClass"), &ClassCompilerDeclCtx, false, 0, searched_files, results)); EXPECT_LE(1u, results.GetSize()); @@ -459,9 +457,8 @@ TEST_F(SymbolFilePDBTests, TestClassInNamespace) { auto ns_namespace = symfile->FindNamespace(ConstString("NS"), nullptr); EXPECT_TRUE(ns_namespace.IsValid()); - SymbolContext sc; - EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("NSClass"), &ns_namespace, - false, 0, searched_files, results)); + EXPECT_EQ(1u, symfile->FindTypes(ConstString("NSClass"), &ns_namespace, false, + 0, searched_files, results)); EXPECT_EQ(1u, results.GetSize()); lldb::TypeSP udt_type = results.GetTypeAtIndex(0); @@ -483,12 +480,11 @@ TEST_F(SymbolFilePDBTests, TestEnumTypes) { SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile()); llvm::pdb::IPDBSession &session = symfile->GetPDBSession(); - SymbolContext sc; llvm::DenseSet<SymbolFile *> searched_files; const char *EnumsToCheck[] = {"Enum", "ShortEnum"}; for (auto Enum : EnumsToCheck) { TypeMap results; - EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString(Enum), nullptr, false, 0, + EXPECT_EQ(1u, symfile->FindTypes(ConstString(Enum), nullptr, false, 0, searched_files, results)); EXPECT_EQ(1u, results.GetSize()); lldb::TypeSP enum_type = results.GetTypeAtIndex(0); @@ -530,7 +526,6 @@ TEST_F(SymbolFilePDBTests, TestTypedefs) { SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile()); llvm::pdb::IPDBSession &session = symfile->GetPDBSession(); - SymbolContext sc; llvm::DenseSet<SymbolFile *> searched_files; TypeMap results; @@ -539,8 +534,8 @@ TEST_F(SymbolFilePDBTests, TestTypedefs) { "VariadicFuncPointerTypedef"}; for (auto Typedef : TypedefsToCheck) { TypeMap results; - EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString(Typedef), nullptr, false, - 0, searched_files, results)); + EXPECT_EQ(1u, symfile->FindTypes(ConstString(Typedef), nullptr, false, 0, + searched_files, results)); EXPECT_EQ(1u, results.GetSize()); lldb::TypeSP typedef_type = results.GetTypeAtIndex(0); EXPECT_EQ(ConstString(Typedef), typedef_type->GetName()); @@ -584,12 +579,11 @@ TEST_F(SymbolFilePDBTests, TestMaxMatches) { SymbolVendor *plugin = module->GetSymbolVendor(); SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile()); - SymbolContext sc; llvm::DenseSet<SymbolFile *> searched_files; TypeMap results; const ConstString name("ClassTypedef"); uint32_t num_results = - symfile->FindTypes(sc, name, nullptr, false, 0, searched_files, results); + symfile->FindTypes(name, nullptr, false, 0, searched_files, results); // Try to limit ourselves from 1 to 10 results, otherwise we could be doing // this thousands of times. // The idea is just to make sure that for a variety of values, the number of @@ -597,8 +591,8 @@ TEST_F(SymbolFilePDBTests, TestMaxMatches) { // comes out to the number we are expecting. uint32_t iterations = std::min(num_results, 10u); for (uint32_t i = 1; i <= iterations; ++i) { - uint32_t num_limited_results = symfile->FindTypes( - sc, name, nullptr, false, i, searched_files, results); + uint32_t num_limited_results = + symfile->FindTypes(name, nullptr, false, i, searched_files, results); EXPECT_EQ(i, num_limited_results); EXPECT_EQ(num_limited_results, results.GetSize()); } @@ -612,11 +606,10 @@ TEST_F(SymbolFilePDBTests, TestNullName) { SymbolVendor *plugin = module->GetSymbolVendor(); SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile()); - SymbolContext sc; llvm::DenseSet<SymbolFile *> searched_files; TypeMap results; - uint32_t num_results = symfile->FindTypes(sc, ConstString(), nullptr, false, - 0, searched_files, results); + uint32_t num_results = symfile->FindTypes(ConstString(), nullptr, false, 0, + searched_files, results); EXPECT_EQ(0u, num_results); EXPECT_EQ(0u, results.GetSize()); } |