[Lldb-commits] [lldb] Improve namespace lookup using .debug_names parent chain (PR #110062)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 10 02:09:14 PDT 2024


================
@@ -565,6 +565,48 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
   m_fallback.GetTypesWithQuery(query, callback);
 }
 
+void DebugNamesDWARFIndex::GetNamespacesWithParents(
+    ConstString name, const CompilerDeclContext &parent_decl_ctx,
+    llvm::function_ref<bool(DWARFDIE die)> callback) {
+  std::vector<lldb_private::CompilerContext> parent_contexts =
+      parent_decl_ctx.GetCompilerContext();
+  if (parent_contexts.empty())
+    return GetNamespaces(name, callback);
+
+  llvm::SmallVector<CompilerContext> parent_named_contexts;
+  std::copy_if(parent_contexts.rbegin(), parent_contexts.rend(),
+               std::back_inserter(parent_named_contexts),
+               [](const CompilerContext &ctx) { return !ctx.name.IsEmpty(); });
----------------
labath wrote:

If you wanted to be really fancy, you could try something like this:
```suggestion
  llvm::SmallVector<CompilerContext> parent_named_contexts(llvm::make_filter_range(llvm::reverse(parent_contexts),
               [](const CompilerContext &ctx) { return !ctx.name.IsEmpty(); }));
```
:P

https://github.com/llvm/llvm-project/pull/110062


More information about the lldb-commits mailing list