[lldb][NFC] Move namespace lookup in ClangASTSource to own function.

Beside being cleaner we can probably reuse that logic elsewhere.
This commit is contained in:
Raphael Isemann 2020-02-25 08:47:41 +01:00
parent 27c89ced81
commit 05d174d301
2 changed files with 34 additions and 20 deletions

View File

@ -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;

View File

@ -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.
///