[Lldb-commits] [PATCH] D139083: [lldb][Module][NFC] Add ModuleList::AnyOf

Michael Buch via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 1 01:31:34 PST 2022


Michael137 created this revision.
Michael137 added a reviewer: aprantl.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139083

Files:
  lldb/include/lldb/Core/ModuleList.h
  lldb/source/Core/ModuleList.cpp


Index: lldb/source/Core/ModuleList.cpp
===================================================================
--- lldb/source/Core/ModuleList.cpp
+++ lldb/source/Core/ModuleList.cpp
@@ -1074,3 +1074,15 @@
       break;
   }
 }
+
+bool ModuleList::AnyOf(
+    std::function<bool(const ModuleSP &module_sp)> const &callback) const {
+  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
+  for (const auto &module_sp : m_modules) {
+    assert(module_sp != nullptr);
+    if (callback(module_sp))
+      return true;
+  }
+
+  return false;
+}
Index: lldb/include/lldb/Core/ModuleList.h
===================================================================
--- lldb/include/lldb/Core/ModuleList.h
+++ lldb/include/lldb/Core/ModuleList.h
@@ -473,6 +473,13 @@
   void ForEach(std::function<bool(const lldb::ModuleSP &module_sp)> const
                    &callback) const;
 
+  /// Returns true if 'callback' returns true for one of the modules
+  /// in this ModuleList.
+  ///
+  /// This function is thread-safe.
+  bool AnyOf(std::function<bool(const lldb::ModuleSP &module_sp)> const
+                 &callback) const;
+
 protected:
   // Class typedefs.
   typedef std::vector<lldb::ModuleSP>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139083.479194.patch
Type: text/x-patch
Size: 1202 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221201/fc29d028/attachment.bin>


More information about the lldb-commits mailing list