Skip to content

Commit 05d174d

Browse files
committed
[lldb][NFC] Move namespace lookup in ClangASTSource to own function.
Beside being cleaner we can probably reuse that logic elsewhere.
1 parent 27c89ce commit 05d174d

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -556,26 +556,8 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
556556

557557
context.m_namespace_map = std::make_shared<ClangASTImporter::NamespaceMap>();
558558

559-
if (const NamespaceDecl *namespace_context =
560-
dyn_cast<NamespaceDecl>(context.m_decl_context)) {
561-
ClangASTImporter::NamespaceMapSP namespace_map =
562-
m_ast_importer_sp->GetNamespaceMap(namespace_context);
563-
564-
if (log && log->GetVerbose())
565-
LLDB_LOG(log, " CAS::FEVD Inspecting namespace map {1} ({2} entries)",
566-
namespace_map.get(), namespace_map->size());
567-
568-
if (!namespace_map)
569-
return;
570-
571-
for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
572-
e = namespace_map->end();
573-
i != e; ++i) {
574-
LLDB_LOG(log, " CAS::FEVD Searching namespace {1} in module {2}",
575-
i->second.GetName(), i->first->GetFileSpec().GetFilename());
576-
577-
FindExternalVisibleDecls(context, i->first, i->second);
578-
}
559+
if (isa<NamespaceDecl>(context.m_decl_context)) {
560+
LookupInNamespace(context);
579561
} else if (isa<ObjCInterfaceDecl>(context.m_decl_context)) {
580562
FindObjCPropertyAndIvarDecls(context);
581563
} else if (!isa<TranslationUnitDecl>(context.m_decl_context)) {
@@ -1417,6 +1399,32 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
14171399
} while (false);
14181400
}
14191401

1402+
void ClangASTSource::LookupInNamespace(NameSearchContext &context) {
1403+
const NamespaceDecl *namespace_context =
1404+
dyn_cast<NamespaceDecl>(context.m_decl_context);
1405+
1406+
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
1407+
1408+
ClangASTImporter::NamespaceMapSP namespace_map =
1409+
m_ast_importer_sp->GetNamespaceMap(namespace_context);
1410+
1411+
if (log && log->GetVerbose())
1412+
LLDB_LOG(log, " CAS::FEVD Inspecting namespace map {1} ({2} entries)",
1413+
namespace_map.get(), namespace_map->size());
1414+
1415+
if (!namespace_map)
1416+
return;
1417+
1418+
for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
1419+
e = namespace_map->end();
1420+
i != e; ++i) {
1421+
LLDB_LOG(log, " CAS::FEVD Searching namespace {1} in module {2}",
1422+
i->second.GetName(), i->first->GetFileSpec().GetFilename());
1423+
1424+
FindExternalVisibleDecls(context, i->first, i->second);
1425+
}
1426+
}
1427+
14201428
typedef llvm::DenseMap<const FieldDecl *, uint64_t> FieldOffsetMap;
14211429
typedef llvm::DenseMap<const CXXRecordDecl *, CharUnits> BaseOffsetMap;
14221430

lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ class ClangASTSource : public clang::ExternalASTSource,
302302
/// is the containing object.
303303
void FindObjCPropertyAndIvarDecls(NameSearchContext &context);
304304

305+
/// Performs lookup into a namespace.
306+
///
307+
/// \param context
308+
/// The NameSearchContext for a lookup inside a namespace.
309+
void LookupInNamespace(NameSearchContext &context);
310+
305311
/// A wrapper for TypeSystemClang::CopyType that sets a flag that
306312
/// indicates that we should not respond to queries during import.
307313
///

0 commit comments

Comments
 (0)