diff options
author | Adrian Prantl <aprantl@apple.com> | 2019-10-01 15:40:41 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2019-10-01 15:40:41 +0000 |
commit | bf9d84c0149b4944d58a00024c8abd98eefc9589 (patch) | |
tree | f9d2d3252890e476cbccc4870157536bae355f1c /lldb/source/Plugins/SymbolFile/DWARF | |
parent | 3c912c4abe2bb962c7bddcf52fab6c65bc5899d5 (diff) | |
download | bcm5719-llvm-bf9d84c0149b4944d58a00024c8abd98eefc9589.tar.gz bcm5719-llvm-bf9d84c0149b4944d58a00024c8abd98eefc9589.zip |
Remove size_t return parameter from FindTypes
In r368345 I accidentally introduced a regression that would
over-report the number of matches found by FindTypes if the
DeclContext Filter was hit.
This patch simply removes the size_t return parameter altogether —
it's not that useful.
rdar://problem/55500457
Differential Revision: https://reviews.llvm.org/D68169
llvm-svn: 373344
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/DWARF')
5 files changed, 51 insertions, 68 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 1a15abcf20f..e80bf594e4a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -151,8 +151,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWO(const DWARFDIE &die, Log *log) { // The type in the Clang module must have the same langage as the current CU. LanguageSet languages; languages.Insert(die.GetCU()->GetLanguageType()); - if (!dwo_module_sp->GetSymbolFile()->FindTypes(decl_context, languages, - dwo_types)) { + dwo_module_sp->GetSymbolFile()->FindTypes(decl_context, languages, dwo_types); + if (dwo_types.GetSize()) { if (!IsClangModuleFwdDecl(die)) return TypeSP(); @@ -162,8 +162,9 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWO(const DWARFDIE &die, Log *log) { for (const auto &name_module : sym_file.getExternalTypeModules()) { if (!name_module.second) continue; - if (name_module.second->GetSymbolFile()->FindTypes(decl_context, - languages, dwo_types)) + name_module.second->GetSymbolFile()->FindTypes(decl_context, + languages, dwo_types); + if (dwo_types.GetSize()) break; } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index e805999da59..1db516387c6 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -335,8 +335,8 @@ void SymbolFileDWARF::GetTypes(const DWARFDIE &die, dw_offset_t min_die_offset, } } -size_t SymbolFileDWARF::GetTypes(SymbolContextScope *sc_scope, - TypeClass type_mask, TypeList &type_list) +void SymbolFileDWARF::GetTypes(SymbolContextScope *sc_scope, + TypeClass type_mask, TypeList &type_list) { std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); @@ -349,8 +349,8 @@ size_t SymbolFileDWARF::GetTypes(SymbolContextScope *sc_scope, if (comp_unit) { dwarf_cu = GetDWARFCompileUnit(comp_unit); - if (dwarf_cu == nullptr) - return 0; + if (!dwarf_cu) + return; GetTypes(dwarf_cu->DIE(), dwarf_cu->GetOffset(), dwarf_cu->GetNextUnitOffset(), type_mask, type_set); } else { @@ -367,16 +367,13 @@ size_t SymbolFileDWARF::GetTypes(SymbolContextScope *sc_scope, } std::set<CompilerType> compiler_type_set; - size_t num_types_added = 0; for (Type *type : type_set) { CompilerType compiler_type = type->GetForwardCompilerType(); if (compiler_type_set.find(compiler_type) == compiler_type_set.end()) { compiler_type_set.insert(compiler_type); type_list.Insert(type->shared_from_this()); - ++num_types_added; } } - return num_types_added; } // Gets the first parent that is a lexical block, function or inlined @@ -2383,7 +2380,7 @@ void SymbolFileDWARF::GetMangledNamesForFunction( } } -uint32_t SymbolFileDWARF::FindTypes( +void SymbolFileDWARF::FindTypes( ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, @@ -2391,13 +2388,13 @@ uint32_t SymbolFileDWARF::FindTypes( std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); // Make sure we haven't already searched this SymbolFile before... if (searched_symbol_files.count(this)) - return 0; - else - searched_symbol_files.insert(this); + return; + + searched_symbol_files.insert(this); DWARFDebugInfo *info = DebugInfo(); - if (info == nullptr) - return 0; + if (!info) + return; Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); @@ -2418,12 +2415,11 @@ uint32_t SymbolFileDWARF::FindTypes( } if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) - return 0; + return; DIEArray die_offsets; m_index->GetTypes(name, die_offsets); const size_t num_die_matches = die_offsets.size(); - const uint32_t initial_types_size = types.GetSize(); for (size_t i = 0; i < num_die_matches; ++i) { const DIERef &die_ref = die_offsets[i]; @@ -2458,8 +2454,7 @@ uint32_t SymbolFileDWARF::FindTypes( searched_symbol_files, types); } - uint32_t num_matches = types.GetSize() - initial_types_size; - if (log && num_matches) { + if (log && types.GetSize()) { if (parent_decl_ctx) { GetObjectFile()->GetModule()->LogMessage( log, @@ -2467,60 +2462,53 @@ uint32_t SymbolFileDWARF::FindTypes( "= %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, - num_matches); + types.GetSize()); } else { GetObjectFile()->GetModule()->LogMessage( log, "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx " "= NULL, max_matches=%u, type_list) => %u", - name.GetCString(), max_matches, num_matches); + name.GetCString(), max_matches, types.GetSize()); } } - - return num_matches; } -size_t SymbolFileDWARF::FindTypes(llvm::ArrayRef<CompilerContext> pattern, +void SymbolFileDWARF::FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages, TypeMap &types) { std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); if (pattern.empty()) - return 0; + return; ConstString name = pattern.back().name; if (!name) - return 0; + return; DIEArray die_offsets; m_index->GetTypes(name, die_offsets); const size_t num_die_matches = die_offsets.size(); - size_t num_matches = 0; for (size_t i = 0; i < num_die_matches; ++i) { const DIERef &die_ref = die_offsets[i]; DWARFDIE die = GetDIE(die_ref); - if (die) { - if (!languages[die.GetCU()->GetLanguageType()]) - continue; - - llvm::SmallVector<CompilerContext, 4> die_context; - die.GetDeclContext(die_context); - if (!contextMatches(die_context, pattern)) - continue; - - Type *matching_type = ResolveType(die, true, true); - if (matching_type) { - // We found a type pointer, now find the shared pointer form our type - // list - types.InsertUnique(matching_type->shared_from_this()); - ++num_matches; - } - } else { + if (!die) { m_index->ReportInvalidDIERef(die_ref, name.GetStringRef()); + continue; } + if (!languages[die.GetCU()->GetLanguageType()]) + continue; + + llvm::SmallVector<CompilerContext, 4> die_context; + die.GetDeclContext(die_context); + if (!contextMatches(die_context, pattern)) + continue; + + if (Type *matching_type = ResolveType(die, true, true)) + // We found a type pointer, now find the shared pointer form our type + // list. + types.InsertUnique(matching_type->shared_from_this()); } - return num_matches; } CompilerDeclContext diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index d7b82cf0711..4f04d416eac 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -181,20 +181,20 @@ public: const std::string &scope_qualified_name, std::vector<lldb_private::ConstString> &mangled_names) override; - uint32_t + void FindTypes(lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, lldb_private::TypeMap &types) override; - size_t FindTypes(llvm::ArrayRef<lldb_private::CompilerContext> pattern, - lldb_private::LanguageSet languages, - lldb_private::TypeMap &types) override; + void FindTypes(llvm::ArrayRef<lldb_private::CompilerContext> pattern, + lldb_private::LanguageSet languages, + lldb_private::TypeMap &types) override; - size_t GetTypes(lldb_private::SymbolContextScope *sc_scope, - lldb::TypeClass type_mask, - lldb_private::TypeList &type_list) override; + void GetTypes(lldb_private::SymbolContextScope *sc_scope, + lldb::TypeClass type_mask, + lldb_private::TypeList &type_list) override; llvm::Expected<lldb_private::TypeSystem &> GetTypeSystemForLanguage(lldb::LanguageType language) override; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 003e0d31ae9..c286dc90e5d 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1070,16 +1070,15 @@ uint32_t SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression ®ex, return sc_list.GetSize() - initial_size; } -size_t SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope, - lldb::TypeClass type_mask, - TypeList &type_list) { +void SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope, + lldb::TypeClass type_mask, + TypeList &type_list) { std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARFDebugMap::GetTypes (type_mask = 0x%8.8x)", type_mask); - uint32_t initial_size = type_list.GetSize(); SymbolFileDWARF *oso_dwarf = nullptr; if (sc_scope) { SymbolContext sc; @@ -1097,7 +1096,6 @@ size_t SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope, return false; }); } - return type_list.GetSize() - initial_size; } std::vector<lldb_private::CallEdge> @@ -1199,21 +1197,17 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE( return TypeSP(); } -uint32_t SymbolFileDWARFDebugMap::FindTypes( +void SymbolFileDWARFDebugMap::FindTypes( ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types) { std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); - const uint32_t initial_types_size = types.GetSize(); - ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { oso_dwarf->FindTypes(name, parent_decl_ctx, 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 5f0bdb04b53..0643e6d24e6 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -108,7 +108,7 @@ public: uint32_t FindFunctions(const lldb_private::RegularExpression ®ex, bool include_inlines, bool append, lldb_private::SymbolContextList &sc_list) override; - uint32_t + void FindTypes(lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, @@ -117,9 +117,9 @@ public: lldb_private::CompilerDeclContext FindNamespace( lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx) override; - size_t GetTypes(lldb_private::SymbolContextScope *sc_scope, - lldb::TypeClass type_mask, - lldb_private::TypeList &type_list) override; + void GetTypes(lldb_private::SymbolContextScope *sc_scope, + lldb::TypeClass type_mask, + lldb_private::TypeList &type_list) override; std::vector<lldb_private::CallEdge> ParseCallEdgesInFunction(lldb_private::UserID func_id) override; |