[Lldb-commits] [lldb] Improve type and namespace lookup using parent chain (PR #108907)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 19 11:27:24 PDT 2024
================
@@ -126,3 +126,62 @@ bool DWARFIndex::GetFullyQualifiedTypeImpl(
return callback(die);
return true;
}
+
+void DWARFIndex::GetNamespacesWithParents(
+ ConstString name, llvm::ArrayRef<llvm::StringRef> parent_names,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
+ GetNamespaces(name, [&](DWARFDIE die) {
+ return ProcessDieMatchParentNames(name, parent_names, die, callback);
+ });
+}
+
+void DWARFIndex::GetTypesWithParents(
+ ConstString name, llvm::ArrayRef<llvm::StringRef> parent_names,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
+ GetTypes(name, [&](DWARFDIE die) {
+ return ProcessDieMatchParentNames(name, parent_names, die, callback);
+ });
+}
+
+bool DWARFIndex::ProcessDieMatchParentNames(
+ ConstString name, llvm::ArrayRef<llvm::StringRef> query_parent_names,
+ DWARFDIE die, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ std::vector<lldb_private::CompilerContext> type_context =
+ die.GetTypeLookupContext();
+ if (type_context.empty()) {
+ // If both type_context and query_parent_names and empty we have a match.
+ // Otherwise, this one does not match and we keep on searching.
+ if (query_parent_names.empty())
+ return callback(die);
+ return true;
+ }
+
+ // Type lookup context includes the current DIE as the last element.
+ // so revert it for easy matching.
+ std::reverse(type_context.begin(), type_context.end());
+
+ // type_context includes the name of the current DIE while query_parent_names
----------------
Michael137 wrote:
This feels very similar to what we're doing in `TypeQuery::ContextMatches`. Any chance one can unify them? Or re-use some of the logic? Haven't compared them in-depth to be sure it's a good idea though
https://github.com/llvm/llvm-project/pull/108907
More information about the lldb-commits
mailing list