From 780af51505a1fedb4e3ced8e0b5832c4d4952a27 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Fri, 6 Apr 2012 18:09:43 +0000 Subject: Fixed ModuleList::FindTypes() so that when a symbol context is supplied that contains a valid module, it will search that module first, then if we are still looking for matches (we have found less that "max_matches"), search in all of the other modules as well. llvm-svn: 154186 --- lldb/source/Core/ModuleList.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'lldb/source/Core/ModuleList.cpp') diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 21f192e80bc..69245fb1a95 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -358,14 +358,37 @@ ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool na uint32_t total_matches = 0; collection::const_iterator pos, end = m_modules.end(); - for (pos = m_modules.begin(); pos != end; ++pos) + if (sc.module_sp) { - if (sc.module_sp.get() == NULL || sc.module_sp.get() == (*pos).get()) - total_matches += (*pos)->FindTypes (sc, name, name_is_fully_qualified, max_matches, types); + // The symbol context "sc" contains a module so we want to search that + // one first if it is in our list... + for (pos = m_modules.begin(); pos != end; ++pos) + { + if (sc.module_sp.get() == (*pos).get()) + { + total_matches += (*pos)->FindTypes (sc, name, name_is_fully_qualified, max_matches, types); - if (total_matches >= max_matches) - break; + if (total_matches >= max_matches) + break; + } + } } + + if (total_matches < max_matches) + { + 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 comparisong will always be true (valid_module_ptr != NULL). + if (sc.module_sp.get() != (*pos).get()) + total_matches += (*pos)->FindTypes (sc, name, name_is_fully_qualified, max_matches, types); + + if (total_matches >= max_matches) + break; + } + } + return total_matches; } -- cgit v1.2.3