diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index a17d1de4841e..b01b221ea760 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -556,26 +556,8 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) { context.m_namespace_map = std::make_shared(); - if (const NamespaceDecl *namespace_context = - dyn_cast(context.m_decl_context)) { - ClangASTImporter::NamespaceMapSP namespace_map = - m_ast_importer_sp->GetNamespaceMap(namespace_context); - - if (log && log->GetVerbose()) - LLDB_LOG(log, " CAS::FEVD Inspecting namespace map {1} ({2} entries)", - namespace_map.get(), namespace_map->size()); - - if (!namespace_map) - return; - - for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(), - e = namespace_map->end(); - i != e; ++i) { - LLDB_LOG(log, " CAS::FEVD Searching namespace {1} in module {2}", - i->second.GetName(), i->first->GetFileSpec().GetFilename()); - - FindExternalVisibleDecls(context, i->first, i->second); - } + if (isa(context.m_decl_context)) { + LookupInNamespace(context); } else if (isa(context.m_decl_context)) { FindObjCPropertyAndIvarDecls(context); } else if (!isa(context.m_decl_context)) { @@ -1417,6 +1399,32 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) { } while (false); } +void ClangASTSource::LookupInNamespace(NameSearchContext &context) { + const NamespaceDecl *namespace_context = + dyn_cast(context.m_decl_context); + + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); + + ClangASTImporter::NamespaceMapSP namespace_map = + m_ast_importer_sp->GetNamespaceMap(namespace_context); + + if (log && log->GetVerbose()) + LLDB_LOG(log, " CAS::FEVD Inspecting namespace map {1} ({2} entries)", + namespace_map.get(), namespace_map->size()); + + if (!namespace_map) + return; + + for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(), + e = namespace_map->end(); + i != e; ++i) { + LLDB_LOG(log, " CAS::FEVD Searching namespace {1} in module {2}", + i->second.GetName(), i->first->GetFileSpec().GetFilename()); + + FindExternalVisibleDecls(context, i->first, i->second); + } +} + typedef llvm::DenseMap FieldOffsetMap; typedef llvm::DenseMap BaseOffsetMap; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h index 6219a870e2e7..1d9b36a803d4 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h @@ -302,6 +302,12 @@ protected: /// is the containing object. void FindObjCPropertyAndIvarDecls(NameSearchContext &context); + /// Performs lookup into a namespace. + /// + /// \param context + /// The NameSearchContext for a lookup inside a namespace. + void LookupInNamespace(NameSearchContext &context); + /// A wrapper for TypeSystemClang::CopyType that sets a flag that /// indicates that we should not respond to queries during import. ///