Skip to content

[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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions lldb/include/lldb/Breakpoint/StopPointSiteList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions lldb/source/Breakpoint/BreakpointList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 4 additions & 6 deletions lldb/source/Breakpoint/BreakpointLocationCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 4 additions & 6 deletions lldb/source/Breakpoint/WatchpointList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Core/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Core/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions lldb/source/DataFormatters/TypeCategoryMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 12 additions & 13 deletions lldb/source/Target/TargetList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand Down
Loading