-
Notifications
You must be signed in to change notification settings - Fork 14k
[lldb] Use llvm::find_if (NFC) #141385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20250524_llvm_find_if_lldb
May 25, 2025
Merged
[lldb] Use llvm::find_if (NFC) #141385
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20250524_llvm_find_if_lldb
May 25, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-lldb Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/141385.diff 8 Files Affected:
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;
|
tgymnich
approved these changes
May 25, 2025
sivan-shani
pushed a commit
to sivan-shani/llvm-project
that referenced
this pull request
Jun 3, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.