Author: Kazu Hirata
Date: 2025-05-25T08:21:30-07:00
New Revision: ef29a79adf8f3a5b80e0ef10b84de54f7eacefa4

URL: 
https://github.com/llvm/llvm-project/commit/ef29a79adf8f3a5b80e0ef10b84de54f7eacefa4
DIFF: 
https://github.com/llvm/llvm-project/commit/ef29a79adf8f3a5b80e0ef10b84de54f7eacefa4.diff

LOG: [lldb] Use llvm::find_if (NFC) (#141385)

Added: 
    

Modified: 
    lldb/include/lldb/Breakpoint/StopPointSiteList.h
    lldb/source/Breakpoint/BreakpointList.cpp
    lldb/source/Breakpoint/BreakpointLocationCollection.cpp
    lldb/source/Breakpoint/WatchpointList.cpp
    lldb/source/Core/Debugger.cpp
    lldb/source/Core/PluginManager.cpp
    lldb/source/DataFormatters/TypeCategoryMap.cpp
    lldb/source/Target/TargetList.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Breakpoint/StopPointSiteList.h 
b/lldb/include/lldb/Breakpoint/StopPointSiteList.h
index b929c37a12f09..7ed53e952dc8d 100644
--- a/lldb/include/lldb/Breakpoint/StopPointSiteList.h
+++ b/lldb/include/lldb/Breakpoint/StopPointSiteList.h
@@ -278,9 +278,8 @@ template <typename StopPointSite> class StopPointSiteList {
         [site_id](const std::pair<lldb::addr_t, StopPointSiteSP> s) {
           return site_id == s.second->GetID();
         };
-    return std::find_if(m_site_list.begin(),
-                        m_site_list.end(), // Search full range
-                        id_matches);
+    return llvm::find_if(m_site_list, // Search full range
+                         id_matches);
   }
 
   typename collection::const_iterator
@@ -290,9 +289,8 @@ template <typename StopPointSite> class StopPointSiteList {
         [site_id](const std::pair<lldb::addr_t, StopPointSiteSP> s) {
           return site_id == s.second->GetID();
         };
-    return std::find_if(m_site_list.begin(),
-                        m_site_list.end(), // Search full range
-                        id_matches);
+    return llvm::find_if(m_site_list, // Search full range
+                         id_matches);
   }
 
   mutable std::recursive_mutex m_mutex;

diff  --git a/lldb/source/Breakpoint/BreakpointList.cpp 
b/lldb/source/Breakpoint/BreakpointList.cpp
index 2c47b3b1263c6..779490ae0316a 100644
--- a/lldb/source/Breakpoint/BreakpointList.cpp
+++ b/lldb/source/Breakpoint/BreakpointList.cpp
@@ -47,9 +47,9 @@ break_id_t BreakpointList::Add(BreakpointSP &bp_sp, bool 
notify) {
 bool BreakpointList::Remove(break_id_t break_id, bool notify) {
   std::lock_guard<std::recursive_mutex> guard(m_mutex);
 
-  auto it = std::find_if(
-      m_breakpoints.begin(), m_breakpoints.end(),
-      [&](const BreakpointSP &bp) { return bp->GetID() == break_id; });
+  auto it = llvm::find_if(m_breakpoints, [&](const BreakpointSP &bp) {
+    return bp->GetID() == break_id;
+  });
 
   if (it == m_breakpoints.end())
     return false;
@@ -109,16 +109,16 @@ void BreakpointList::RemoveAllowed(bool notify) {
 
 BreakpointList::bp_collection::iterator
 BreakpointList::GetBreakpointIDIterator(break_id_t break_id) {
-  return std::find_if(
-      m_breakpoints.begin(), m_breakpoints.end(),
-      [&](const BreakpointSP &bp) { return bp->GetID() == break_id; });
+  return llvm::find_if(m_breakpoints, [&](const BreakpointSP &bp) {
+    return bp->GetID() == break_id;
+  });
 }
 
 BreakpointList::bp_collection::const_iterator
 BreakpointList::GetBreakpointIDConstIterator(break_id_t break_id) const {
-  return std::find_if(
-      m_breakpoints.begin(), m_breakpoints.end(),
-      [&](const BreakpointSP &bp) { return bp->GetID() == break_id; });
+  return llvm::find_if(m_breakpoints, [&](const BreakpointSP &bp) {
+    return bp->GetID() == break_id;
+  });
 }
 
 BreakpointSP BreakpointList::FindBreakpointByID(break_id_t break_id) const {

diff  --git a/lldb/source/Breakpoint/BreakpointLocationCollection.cpp 
b/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
index d649e889c3f76..28a3639e95bb6 100644
--- a/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
@@ -60,18 +60,16 @@ class BreakpointIDPairMatches {
 BreakpointLocationCollection::collection::iterator
 BreakpointLocationCollection::GetIDPairIterator(lldb::break_id_t break_id,
                                                 lldb::break_id_t break_loc_id) 
{
-  return std::find_if(
-      m_break_loc_collection.begin(),
-      m_break_loc_collection.end(),                     // Search full range
+  return llvm::find_if(
+      m_break_loc_collection,                           // Search full range
       BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
 }
 
 BreakpointLocationCollection::collection::const_iterator
 BreakpointLocationCollection::GetIDPairConstIterator(
     lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const {
-  return std::find_if(
-      m_break_loc_collection.begin(),
-      m_break_loc_collection.end(),                     // Search full range
+  return llvm::find_if(
+      m_break_loc_collection,                           // Search full range
       BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
 }
 

diff  --git a/lldb/source/Breakpoint/WatchpointList.cpp 
b/lldb/source/Breakpoint/WatchpointList.cpp
index 57369b76c03af..2542be88f4dc4 100644
--- a/lldb/source/Breakpoint/WatchpointList.cpp
+++ b/lldb/source/Breakpoint/WatchpointList.cpp
@@ -98,16 +98,14 @@ class WatchpointIDMatches {
 
 WatchpointList::wp_collection::iterator
 WatchpointList::GetIDIterator(lldb::watch_id_t watch_id) {
-  return std::find_if(m_watchpoints.begin(),
-                      m_watchpoints.end(),            // Search full range
-                      WatchpointIDMatches(watch_id)); // Predicate
+  return llvm::find_if(m_watchpoints,                  // Search full range
+                       WatchpointIDMatches(watch_id)); // Predicate
 }
 
 WatchpointList::wp_collection::const_iterator
 WatchpointList::GetIDConstIterator(lldb::watch_id_t watch_id) const {
-  return std::find_if(m_watchpoints.begin(),
-                      m_watchpoints.end(),            // Search full range
-                      WatchpointIDMatches(watch_id)); // Predicate
+  return llvm::find_if(m_watchpoints,                  // Search full range
+                       WatchpointIDMatches(watch_id)); // Predicate
 }
 
 WatchpointSP WatchpointList::FindByID(lldb::watch_id_t watch_id) const {

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 89018da8c685d..519a2528ca7e0 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -2225,9 +2225,9 @@ void Debugger::HandleProgressEvent(const lldb::EventSP 
&event_sp) {
   // progress reports.
   {
     std::lock_guard<std::mutex> guard(m_progress_reports_mutex);
-    auto it = std::find_if(
-        m_progress_reports.begin(), m_progress_reports.end(),
-        [&](const auto &report) { return report.id == progress_report.id; });
+    auto it = llvm::find_if(m_progress_reports, [&](const auto &report) {
+      return report.id == progress_report.id;
+    });
     if (it != m_progress_reports.end()) {
       const bool complete = data->GetCompleted() == data->GetTotal();
       if (complete)

diff  --git a/lldb/source/Core/PluginManager.cpp 
b/lldb/source/Core/PluginManager.cpp
index 32c2a00a861a7..de815e6308838 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -315,9 +315,9 @@ template <typename Instance> class PluginInstances {
   }
 
   bool SetInstanceEnabled(llvm::StringRef name, bool enable) {
-    auto it = std::find_if(
-        m_instances.begin(), m_instances.end(),
-        [&](const Instance &instance) { return instance.name == name; });
+    auto it = llvm::find_if(m_instances, [&](const Instance &instance) {
+      return instance.name == name;
+    });
 
     if (it == m_instances.end())
       return false;

diff  --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp 
b/lldb/source/DataFormatters/TypeCategoryMap.cpp
index ce2cf369b5be5..980d3c7baafa2 100644
--- a/lldb/source/DataFormatters/TypeCategoryMap.cpp
+++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp
@@ -112,9 +112,10 @@ void TypeCategoryMap::EnableAllCategories() {
       continue;
     auto pos = iter->second->GetLastEnabledPosition();
     if (pos >= sorted_categories.size()) {
-      auto iter = std::find_if(
-          sorted_categories.begin(), sorted_categories.end(),
-          [](const TypeCategoryImplSP &sp) -> bool { return sp.get() == 
nullptr; });
+      auto iter = llvm::find_if(sorted_categories,
+                                [](const TypeCategoryImplSP &sp) -> bool {
+                                  return sp.get() == nullptr;
+                                });
       pos = std::distance(sorted_categories.begin(), iter);
     }
     sorted_categories.at(pos) = iter->second;

diff  --git a/lldb/source/Target/TargetList.cpp 
b/lldb/source/Target/TargetList.cpp
index 7f29bd7a07ab8..7037dc2bea3cc 100644
--- a/lldb/source/Target/TargetList.cpp
+++ b/lldb/source/Target/TargetList.cpp
@@ -382,8 +382,8 @@ bool TargetList::DeleteTarget(TargetSP &target_sp) {
 TargetSP TargetList::FindTargetWithExecutableAndArchitecture(
     const FileSpec &exe_file_spec, const ArchSpec *exe_arch_ptr) const {
   std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-  auto it = std::find_if(m_target_list.begin(), m_target_list.end(),
-      [&exe_file_spec, exe_arch_ptr](const TargetSP &item) {
+  auto it = llvm::find_if(
+      m_target_list, [&exe_file_spec, exe_arch_ptr](const TargetSP &item) {
         Module *exe_module = item->GetExecutableModulePointer();
         if (!exe_module ||
             !FileSpec::Match(exe_file_spec, exe_module->GetFileSpec()))
@@ -401,11 +401,10 @@ TargetSP 
TargetList::FindTargetWithExecutableAndArchitecture(
 
 TargetSP TargetList::FindTargetWithProcessID(lldb::pid_t pid) const {
   std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-  auto it = std::find_if(m_target_list.begin(), m_target_list.end(),
-      [pid](const TargetSP &item) {
-        auto *process_ptr = item->GetProcessSP().get();
-        return process_ptr && (process_ptr->GetID() == pid);
-      });
+  auto it = llvm::find_if(m_target_list, [pid](const TargetSP &item) {
+    auto *process_ptr = item->GetProcessSP().get();
+    return process_ptr && (process_ptr->GetID() == pid);
+  });
 
   if (it != m_target_list.end())
     return *it;
@@ -419,10 +418,9 @@ TargetSP TargetList::FindTargetWithProcess(Process 
*process) const {
     return target_sp;
 
   std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-  auto it = std::find_if(m_target_list.begin(), m_target_list.end(),
-      [process](const TargetSP &item) {
-        return item->GetProcessSP().get() == process;
-      });
+  auto it = llvm::find_if(m_target_list, [process](const TargetSP &item) {
+    return item->GetProcessSP().get() == process;
+  });
 
   if (it != m_target_list.end())
     target_sp = *it;
@@ -436,8 +434,9 @@ TargetSP TargetList::GetTargetSP(Target *target) const {
     return target_sp;
 
   std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-  auto it = std::find_if(m_target_list.begin(), m_target_list.end(),
-      [target](const TargetSP &item) { return item.get() == target; });
+  auto it = llvm::find_if(m_target_list, [target](const TargetSP &item) {
+    return item.get() == target;
+  });
   if (it != m_target_list.end())
     target_sp = *it;
 


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to