llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

<details>
<summary>Changes</summary>

Continuation of https://github.com/llvm/llvm-project/pull/151489

---
Full diff: https://github.com/llvm/llvm-project/pull/151992.diff


9 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp (+11-7) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h (+6-4) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp (+11-10) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h (+16-14) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
(+22-18) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h 
(+10-8) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp (+8-5) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h (+6-4) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+12-6) 


``````````diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index b5c4667332f24..86de1b5c7859f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -217,15 +217,16 @@ void AppleDWARFIndex::GetCompleteObjCClass(
 }
 
 void AppleDWARFIndex::GetTypes(
-    ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+    ConstString name,
+    llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
   if (!m_apple_types_up)
     return;
-  SearchFor(*m_apple_types_up, name, callback);
+  SearchFor(*m_apple_types_up, name, IterationActionAdaptor(callback));
 }
 
 void AppleDWARFIndex::GetTypes(
     const DWARFDeclContext &context,
-    llvm::function_ref<bool(DWARFDIE die)> callback) {
+    llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
   if (!m_apple_types_up)
     return;
 
@@ -243,14 +244,16 @@ void AppleDWARFIndex::GetTypes(
         llvm::djbHash(context.GetQualifiedName());
     if (log)
       m_module.LogMessage(log, "FindByNameAndTagAndQualifiedNameHash()");
-    SearchFor(*m_apple_types_up, expected_name, callback, expected_tag,
-               expected_qualname_hash);
+    SearchFor(*m_apple_types_up, expected_name,
+              IterationActionAdaptor(callback), expected_tag,
+              expected_qualname_hash);
     return;
   }
 
   // Historically, if there are no tags, we also ignore qual_hash (why?)
   if (!entries_have_tag) {
-    SearchFor(*m_apple_names_up, expected_name, callback);
+    SearchFor(*m_apple_names_up, expected_name,
+              IterationActionAdaptor(callback));
     return;
   }
 
@@ -269,7 +272,8 @@ void AppleDWARFIndex::GetTypes(
   if (log)
     m_module.LogMessage(log, "FindByNameAndTag()");
   const dw_tag_t expected_tag = context[0].tag;
-  SearchFor(*m_apple_types_up, expected_name, callback, expected_tag);
+  SearchFor(*m_apple_types_up, expected_name, IterationActionAdaptor(callback),
+            expected_tag);
 }
 
 void AppleDWARFIndex::GetNamespaces(
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
index 33ac61b510fff..a8ccb6f93d1ca 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
@@ -57,10 +57,12 @@ class AppleDWARFIndex : public DWARFIndex {
   void GetCompleteObjCClass(
       ConstString class_name, bool must_be_implementation,
       llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
-  void GetTypes(ConstString name,
-                llvm::function_ref<bool(DWARFDIE die)> callback) override;
-  void GetTypes(const DWARFDeclContext &context,
-                llvm::function_ref<bool(DWARFDIE die)> callback) override;
+  void
+  GetTypes(ConstString name,
+           llvm::function_ref<IterationAction(DWARFDIE die)> callback) 
override;
+  void
+  GetTypes(const DWARFDeclContext &context,
+           llvm::function_ref<IterationAction(DWARFDIE die)> callback) 
override;
   void GetNamespaces(
       ConstString name,
       llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index 579103046644d..acbbaeb52bc69 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -113,42 +113,43 @@ void DWARFIndex::ReportInvalidDIERef(DIERef ref, 
llvm::StringRef name) const {
 
 void DWARFIndex::GetFullyQualifiedType(
     const DWARFDeclContext &context,
-    llvm::function_ref<bool(DWARFDIE die)> callback) {
+    llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
   GetTypes(context, [&](DWARFDIE die) {
     return GetFullyQualifiedTypeImpl(context, die, callback);
   });
 }
 
-bool DWARFIndex::GetFullyQualifiedTypeImpl(
+IterationAction DWARFIndex::GetFullyQualifiedTypeImpl(
     const DWARFDeclContext &context, DWARFDIE die,
-    llvm::function_ref<bool(DWARFDIE die)> callback) {
+    llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
   DWARFDeclContext dwarf_decl_ctx = die.GetDWARFDeclContext();
   if (dwarf_decl_ctx == context)
     return callback(die);
-  return true;
+  return IterationAction::Continue;
 }
 
 void DWARFIndex::GetTypesWithQuery(
-    TypeQuery &query, llvm::function_ref<bool(DWARFDIE die)> callback) {
+    TypeQuery &query,
+    llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
   GetTypes(query.GetTypeBasename(), [&](DWARFDIE die) {
     return ProcessTypeDIEMatchQuery(query, die, callback);
   });
 }
 
-bool DWARFIndex::ProcessTypeDIEMatchQuery(
+IterationAction DWARFIndex::ProcessTypeDIEMatchQuery(
     TypeQuery &query, DWARFDIE die,
-    llvm::function_ref<bool(DWARFDIE die)> callback) {
+    llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
   // Check the language, but only if we have a language filter.
   if (query.HasLanguage() &&
       !query.LanguageMatches(SymbolFileDWARF::GetLanguageFamily(*die.GetCU())))
-    return true; // Keep iterating over index types, language mismatch.
+    return IterationAction::Continue;
 
   // Since mangled names are unique, we only need to check if the names are
   // the same.
   if (query.GetSearchByMangledName()) {
     if (die.GetMangledName(/*substitute_name_allowed=*/false) !=
         query.GetTypeBasename().GetStringRef())
-      return true; // Keep iterating over index types, mangled name mismatch.
+      return IterationAction::Continue;
     return callback(die);
   }
 
@@ -159,7 +160,7 @@ bool DWARFIndex::ProcessTypeDIEMatchQuery(
     die_context = die.GetTypeLookupContext();
 
   if (!query.ContextMatches(die_context))
-    return true;
+    return IterationAction::Continue;
   return callback(die);
 }
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index 84749341ea57a..710bb4e826882 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -50,18 +50,20 @@ class DWARFIndex {
   virtual void GetCompleteObjCClass(
       ConstString class_name, bool must_be_implementation,
       llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
-  virtual void GetTypes(ConstString name,
-                        llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
-  virtual void GetTypes(const DWARFDeclContext &context,
-                        llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+  virtual void
+  GetTypes(ConstString name,
+           llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
+  virtual void
+  GetTypes(const DWARFDeclContext &context,
+           llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
 
   /// Finds all DIEs whose fully qualified name matches `context`. A base
   /// implementation is provided, and it uses the entire CU to check the DIE
   /// parent hierarchy. Specializations should override this if they are able
   /// to provide a faster implementation.
-  virtual void
-  GetFullyQualifiedType(const DWARFDeclContext &context,
-                        llvm::function_ref<bool(DWARFDIE die)> callback);
+  virtual void GetFullyQualifiedType(
+      const DWARFDeclContext &context,
+      llvm::function_ref<IterationAction(DWARFDIE die)> callback);
   virtual void
   GetNamespaces(ConstString name,
                 llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 
0;
@@ -71,7 +73,7 @@ class DWARFIndex {
   /// implementation.
   virtual void
   GetTypesWithQuery(TypeQuery &query,
-                    llvm::function_ref<bool(DWARFDIE die)> callback);
+                    llvm::function_ref<IterationAction(DWARFDIE die)> 
callback);
   /// Get namespace DIEs whose base name match \param name with \param
   /// parent_decl_ctx in its decl parent chain.  A base implementation
   /// is provided. Specializations should override this if they are able to
@@ -130,14 +132,14 @@ class DWARFIndex {
 
   /// Implementation of `GetFullyQualifiedType` to check a single entry,
   /// shareable with derived classes.
-  bool
-  GetFullyQualifiedTypeImpl(const DWARFDeclContext &context, DWARFDIE die,
-                            llvm::function_ref<bool(DWARFDIE die)> callback);
+  IterationAction GetFullyQualifiedTypeImpl(
+      const DWARFDeclContext &context, DWARFDIE die,
+      llvm::function_ref<IterationAction(DWARFDIE die)> callback);
 
   /// Check if the type \a die can meet the requirements of \a query.
-  bool
-  ProcessTypeDIEMatchQuery(TypeQuery &query, DWARFDIE die,
-                           llvm::function_ref<bool(DWARFDIE die)> callback);
+  IterationAction ProcessTypeDIEMatchQuery(
+      TypeQuery &query, DWARFDIE die,
+      llvm::function_ref<IterationAction(DWARFDIE die)> callback);
   IterationAction ProcessNamespaceDieMatchParents(
       const CompilerDeclContext &parent_decl_ctx, DWARFDIE die,
       llvm::function_ref<IterationAction(DWARFDIE die)> callback);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 2ec876dd552c0..9fe03dc5ba1a7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -329,7 +329,7 @@ getParentChain(Entry entry,
 
 void DebugNamesDWARFIndex::GetFullyQualifiedType(
     const DWARFDeclContext &context,
-    llvm::function_ref<bool(DWARFDIE die)> callback) {
+    llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
   if (context.GetSize() == 0)
     return;
 
@@ -358,15 +358,16 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType(
 
     if (!parent_chain) {
       // Fallback: use the base class implementation.
-      if (!ProcessEntry(entry, [&](DWARFDIE die) {
-            return GetFullyQualifiedTypeImpl(context, die, callback);
-          }))
+      if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
+                          return GetFullyQualifiedTypeImpl(context, die,
+                                                           callback);
+                        })))
         return;
       continue;
     }
 
     if (SameParentChain(parent_names, *parent_chain)) {
-      if (!ProcessEntry(entry, callback))
+      if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
         return;
     }
   }
@@ -456,11 +457,12 @@ bool DebugNamesDWARFIndex::WithinParentChain(
 }
 
 void DebugNamesDWARFIndex::GetTypes(
-    ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+    ConstString name,
+    llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
   for (const DebugNames::Entry &entry :
        m_debug_names_up->equal_range(name.GetStringRef())) {
     if (isType(entry.tag())) {
-      if (!ProcessEntry(entry, callback))
+      if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
         return;
     }
   }
@@ -470,11 +472,11 @@ void DebugNamesDWARFIndex::GetTypes(
 
 void DebugNamesDWARFIndex::GetTypes(
     const DWARFDeclContext &context,
-    llvm::function_ref<bool(DWARFDIE die)> callback) {
+    llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
   auto name = context[0].name;
   for (const DebugNames::Entry &entry : m_debug_names_up->equal_range(name)) {
     if (entry.tag() == context[0].tag) {
-      if (!ProcessEntry(entry, callback))
+      if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
         return;
     }
   }
@@ -521,7 +523,8 @@ DebugNamesDWARFIndex::GetTypeQueryParentContexts(TypeQuery 
&query) {
 }
 
 void DebugNamesDWARFIndex::GetTypesWithQuery(
-    TypeQuery &query, llvm::function_ref<bool(DWARFDIE die)> callback) {
+    TypeQuery &query,
+    llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
   ConstString name = query.GetTypeBasename();
   std::vector<lldb_private::CompilerContext> query_context =
       query.GetContextRef();
@@ -546,19 +549,20 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
         getParentChain(entry);
     if (!parent_chain) {
       // Fallback: use the base class implementation.
-      if (!ProcessEntry(entry, [&](DWARFDIE die) {
-            return ProcessTypeDIEMatchQuery(query, die, callback);
-          }))
+      if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
+                          return ProcessTypeDIEMatchQuery(query, die, 
callback);
+                        })))
         return;
       continue;
     }
 
     if (WithinParentChain(parent_contexts, *parent_chain)) {
-      if (!ProcessEntry(entry, [&](DWARFDIE die) {
-            // After .debug_names filtering still sending to base class for
-            // further filtering before calling the callback.
-            return ProcessTypeDIEMatchQuery(query, die, callback);
-          }))
+      if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
+                          // After .debug_names filtering still sending to base
+                          // class for further filtering before calling the
+                          // callback.
+                          return ProcessTypeDIEMatchQuery(query, die, 
callback);
+                        })))
         // If the callback returns false, we're done.
         return;
     }
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
index 0340cb4a16fc7..0587f0401f718 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
@@ -46,17 +46,19 @@ class DebugNamesDWARFIndex : public DWARFIndex {
   /// Uses DWARF5's IDX_parent fields, when available, to speed up this query.
   void GetFullyQualifiedType(
       const DWARFDeclContext &context,
-      llvm::function_ref<bool(DWARFDIE die)> callback) override;
-  void GetTypes(ConstString name,
-                llvm::function_ref<bool(DWARFDIE die)> callback) override;
-  void GetTypes(const DWARFDeclContext &context,
-                llvm::function_ref<bool(DWARFDIE die)> callback) override;
+      llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
+  void
+  GetTypes(ConstString name,
+           llvm::function_ref<IterationAction(DWARFDIE die)> callback) 
override;
+  void
+  GetTypes(const DWARFDeclContext &context,
+           llvm::function_ref<IterationAction(DWARFDIE die)> callback) 
override;
   void GetNamespaces(
       ConstString name,
       llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
-  void
-  GetTypesWithQuery(TypeQuery &query,
-                    llvm::function_ref<bool(DWARFDIE die)> callback) override;
+  void GetTypesWithQuery(
+      TypeQuery &query,
+      llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
   void GetNamespacesWithParents(
       ConstString name, const CompilerDeclContext &parent_decl_ctx,
       llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 004c9dd35ec08..94bdd795cb12b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -455,18 +455,21 @@ void ManualDWARFIndex::GetCompleteObjCClass(
 }
 
 void ManualDWARFIndex::GetTypes(
-    ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+    ConstString name,
+    llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
   Index();
-  m_set.types.Find(name, DIERefCallback(callback, name.GetStringRef()));
+  m_set.types.Find(name, DIERefCallback(IterationActionAdaptor(callback),
+                                        name.GetStringRef()));
 }
 
 void ManualDWARFIndex::GetTypes(
     const DWARFDeclContext &context,
-    llvm::function_ref<bool(DWARFDIE die)> callback) {
+    llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
   Index();
   auto name = context[0].name;
-  m_set.types.Find(ConstString(name),
-                   DIERefCallback(callback, llvm::StringRef(name)));
+  m_set.types.Find(
+      ConstString(name),
+      DIERefCallback(IterationActionAdaptor(callback), llvm::StringRef(name)));
 }
 
 void ManualDWARFIndex::GetNamespaces(
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
index 6a71068d5aa20..0b5b2f3e84309 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -46,10 +46,12 @@ class ManualDWARFIndex : public DWARFIndex {
   void GetCompleteObjCClass(
       ConstString class_name, bool must_be_implementation,
       llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
-  void GetTypes(ConstString name,
-                llvm::function_ref<bool(DWARFDIE die)> callback) override;
-  void GetTypes(const DWARFDeclContext &context,
-                llvm::function_ref<bool(DWARFDIE die)> callback) override;
+  void
+  GetTypes(ConstString name,
+           llvm::function_ref<IterationAction(DWARFDIE die)> callback) 
override;
+  void
+  GetTypes(const DWARFDeclContext &context,
+           llvm::function_ref<IterationAction(DWARFDIE die)> callback) 
override;
   void GetNamespaces(
       ConstString name,
       llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 170631d4ed365..84b3da37367c4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2760,12 +2760,15 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
         auto CompilerTypeBasename =
             matching_type->GetForwardCompilerType().GetTypeName(true);
         if (CompilerTypeBasename != query.GetTypeBasename())
-          return true; // Keep iterating over index types, basename mismatch.
+          return IterationAction::Continue;
       }
       have_index_match = true;
       results.InsertUnique(matching_type->shared_from_this());
     }
-    return !results.Done(query); // Keep iterating if we aren't done.
+    if (!results.Done(query))
+      return IterationAction::Continue;
+
+    return IterationAction::Stop;
   });
 
   if (results.Done(query)) {
@@ -2801,7 +2804,10 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
         if (query.ContextMatches(qualified_context))
           if (Type *matching_type = ResolveType(die, true, true))
             results.InsertUnique(matching_type->shared_from_this());
-        return !results.Done(query); // Keep iterating if we aren't done.
+        if (!results.Done(query))
+          return IterationAction::Continue;
+
+        return IterationAction::Stop;
       });
       if (results.Done(query)) {
         if (log) {
@@ -3108,7 +3114,7 @@ SymbolFileDWARF::FindDefinitionDIE(const DWARFDIE &die) {
     // are looking for a "Foo" type for C, C++, ObjC, or ObjC++.
     if (type_system &&
         !type_system->SupportsLanguage(GetLanguage(*type_die.GetCU())))
-      return true;
+      return IterationAction::Continue;
 
     if (!die_matches(type_die)) {
       if (log) {
@@ -3119,7 +3125,7 @@ SymbolFileDWARF::FindDefinitionDIE(const DWARFDIE &die) {
             DW_TAG_value_to_name(tag), tag, name, type_die.GetOffset(),
             type_die.GetName());
       }
-      return true;
+      return IterationAction::Continue;
     }
 
     if (log) {
@@ -3133,7 +3139,7 @@ SymbolFileDWARF::FindDefinitionDIE(const DWARFDIE &die) {
     }
 
     result = type_die;
-    return false;
+    return IterationAction::Stop;
   });
   return result;
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/151992
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to