Author: Raphael Isemann Date: 2020-02-25T10:27:47+01:00 New Revision: 05d174d30159579ae19e90899736d98e2544c0e3
URL: https://github.com/llvm/llvm-project/commit/05d174d30159579ae19e90899736d98e2544c0e3 DIFF: https://github.com/llvm/llvm-project/commit/05d174d30159579ae19e90899736d98e2544c0e3.diff LOG: [lldb][NFC] Move namespace lookup in ClangASTSource to own function. Beside being cleaner we can probably reuse that logic elsewhere. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h Removed: ################################################################################ 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<ClangASTImporter::NamespaceMap>(); - if (const NamespaceDecl *namespace_context = - dyn_cast<NamespaceDecl>(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<NamespaceDecl>(context.m_decl_context)) { + LookupInNamespace(context); } else if (isa<ObjCInterfaceDecl>(context.m_decl_context)) { FindObjCPropertyAndIvarDecls(context); } else if (!isa<TranslationUnitDecl>(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<NamespaceDecl>(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<const FieldDecl *, uint64_t> FieldOffsetMap; typedef llvm::DenseMap<const CXXRecordDecl *, CharUnits> 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 @@ class ClangASTSource : public clang::ExternalASTSource, /// 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. /// _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits