Skip to content

Commit ef29a79

Browse files
[lldb] Use llvm::find_if (NFC) (#141385)
1 parent c4cfc95 commit ef29a79

File tree

8 files changed

+43
-49
lines changed

8 files changed

+43
-49
lines changed

lldb/include/lldb/Breakpoint/StopPointSiteList.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,8 @@ template <typename StopPointSite> class StopPointSiteList {
278278
[site_id](const std::pair<lldb::addr_t, StopPointSiteSP> s) {
279279
return site_id == s.second->GetID();
280280
};
281-
return std::find_if(m_site_list.begin(),
282-
m_site_list.end(), // Search full range
283-
id_matches);
281+
return llvm::find_if(m_site_list, // Search full range
282+
id_matches);
284283
}
285284

286285
typename collection::const_iterator
@@ -290,9 +289,8 @@ template <typename StopPointSite> class StopPointSiteList {
290289
[site_id](const std::pair<lldb::addr_t, StopPointSiteSP> s) {
291290
return site_id == s.second->GetID();
292291
};
293-
return std::find_if(m_site_list.begin(),
294-
m_site_list.end(), // Search full range
295-
id_matches);
292+
return llvm::find_if(m_site_list, // Search full range
293+
id_matches);
296294
}
297295

298296
mutable std::recursive_mutex m_mutex;

lldb/source/Breakpoint/BreakpointList.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ break_id_t BreakpointList::Add(BreakpointSP &bp_sp, bool notify) {
4747
bool BreakpointList::Remove(break_id_t break_id, bool notify) {
4848
std::lock_guard<std::recursive_mutex> guard(m_mutex);
4949

50-
auto it = std::find_if(
51-
m_breakpoints.begin(), m_breakpoints.end(),
52-
[&](const BreakpointSP &bp) { return bp->GetID() == break_id; });
50+
auto it = llvm::find_if(m_breakpoints, [&](const BreakpointSP &bp) {
51+
return bp->GetID() == break_id;
52+
});
5353

5454
if (it == m_breakpoints.end())
5555
return false;
@@ -109,16 +109,16 @@ void BreakpointList::RemoveAllowed(bool notify) {
109109

110110
BreakpointList::bp_collection::iterator
111111
BreakpointList::GetBreakpointIDIterator(break_id_t break_id) {
112-
return std::find_if(
113-
m_breakpoints.begin(), m_breakpoints.end(),
114-
[&](const BreakpointSP &bp) { return bp->GetID() == break_id; });
112+
return llvm::find_if(m_breakpoints, [&](const BreakpointSP &bp) {
113+
return bp->GetID() == break_id;
114+
});
115115
}
116116

117117
BreakpointList::bp_collection::const_iterator
118118
BreakpointList::GetBreakpointIDConstIterator(break_id_t break_id) const {
119-
return std::find_if(
120-
m_breakpoints.begin(), m_breakpoints.end(),
121-
[&](const BreakpointSP &bp) { return bp->GetID() == break_id; });
119+
return llvm::find_if(m_breakpoints, [&](const BreakpointSP &bp) {
120+
return bp->GetID() == break_id;
121+
});
122122
}
123123

124124
BreakpointSP BreakpointList::FindBreakpointByID(break_id_t break_id) const {

lldb/source/Breakpoint/BreakpointLocationCollection.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,16 @@ class BreakpointIDPairMatches {
6060
BreakpointLocationCollection::collection::iterator
6161
BreakpointLocationCollection::GetIDPairIterator(lldb::break_id_t break_id,
6262
lldb::break_id_t break_loc_id) {
63-
return std::find_if(
64-
m_break_loc_collection.begin(),
65-
m_break_loc_collection.end(), // Search full range
63+
return llvm::find_if(
64+
m_break_loc_collection, // Search full range
6665
BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
6766
}
6867

6968
BreakpointLocationCollection::collection::const_iterator
7069
BreakpointLocationCollection::GetIDPairConstIterator(
7170
lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const {
72-
return std::find_if(
73-
m_break_loc_collection.begin(),
74-
m_break_loc_collection.end(), // Search full range
71+
return llvm::find_if(
72+
m_break_loc_collection, // Search full range
7573
BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
7674
}
7775

lldb/source/Breakpoint/WatchpointList.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,14 @@ class WatchpointIDMatches {
9898

9999
WatchpointList::wp_collection::iterator
100100
WatchpointList::GetIDIterator(lldb::watch_id_t watch_id) {
101-
return std::find_if(m_watchpoints.begin(),
102-
m_watchpoints.end(), // Search full range
103-
WatchpointIDMatches(watch_id)); // Predicate
101+
return llvm::find_if(m_watchpoints, // Search full range
102+
WatchpointIDMatches(watch_id)); // Predicate
104103
}
105104

106105
WatchpointList::wp_collection::const_iterator
107106
WatchpointList::GetIDConstIterator(lldb::watch_id_t watch_id) const {
108-
return std::find_if(m_watchpoints.begin(),
109-
m_watchpoints.end(), // Search full range
110-
WatchpointIDMatches(watch_id)); // Predicate
107+
return llvm::find_if(m_watchpoints, // Search full range
108+
WatchpointIDMatches(watch_id)); // Predicate
111109
}
112110

113111
WatchpointSP WatchpointList::FindByID(lldb::watch_id_t watch_id) const {

lldb/source/Core/Debugger.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2225,9 +2225,9 @@ void Debugger::HandleProgressEvent(const lldb::EventSP &event_sp) {
22252225
// progress reports.
22262226
{
22272227
std::lock_guard<std::mutex> guard(m_progress_reports_mutex);
2228-
auto it = std::find_if(
2229-
m_progress_reports.begin(), m_progress_reports.end(),
2230-
[&](const auto &report) { return report.id == progress_report.id; });
2228+
auto it = llvm::find_if(m_progress_reports, [&](const auto &report) {
2229+
return report.id == progress_report.id;
2230+
});
22312231
if (it != m_progress_reports.end()) {
22322232
const bool complete = data->GetCompleted() == data->GetTotal();
22332233
if (complete)

lldb/source/Core/PluginManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,9 @@ template <typename Instance> class PluginInstances {
315315
}
316316

317317
bool SetInstanceEnabled(llvm::StringRef name, bool enable) {
318-
auto it = std::find_if(
319-
m_instances.begin(), m_instances.end(),
320-
[&](const Instance &instance) { return instance.name == name; });
318+
auto it = llvm::find_if(m_instances, [&](const Instance &instance) {
319+
return instance.name == name;
320+
});
321321

322322
if (it == m_instances.end())
323323
return false;

lldb/source/DataFormatters/TypeCategoryMap.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ void TypeCategoryMap::EnableAllCategories() {
112112
continue;
113113
auto pos = iter->second->GetLastEnabledPosition();
114114
if (pos >= sorted_categories.size()) {
115-
auto iter = std::find_if(
116-
sorted_categories.begin(), sorted_categories.end(),
117-
[](const TypeCategoryImplSP &sp) -> bool { return sp.get() == nullptr; });
115+
auto iter = llvm::find_if(sorted_categories,
116+
[](const TypeCategoryImplSP &sp) -> bool {
117+
return sp.get() == nullptr;
118+
});
118119
pos = std::distance(sorted_categories.begin(), iter);
119120
}
120121
sorted_categories.at(pos) = iter->second;

lldb/source/Target/TargetList.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ bool TargetList::DeleteTarget(TargetSP &target_sp) {
382382
TargetSP TargetList::FindTargetWithExecutableAndArchitecture(
383383
const FileSpec &exe_file_spec, const ArchSpec *exe_arch_ptr) const {
384384
std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
385-
auto it = std::find_if(m_target_list.begin(), m_target_list.end(),
386-
[&exe_file_spec, exe_arch_ptr](const TargetSP &item) {
385+
auto it = llvm::find_if(
386+
m_target_list, [&exe_file_spec, exe_arch_ptr](const TargetSP &item) {
387387
Module *exe_module = item->GetExecutableModulePointer();
388388
if (!exe_module ||
389389
!FileSpec::Match(exe_file_spec, exe_module->GetFileSpec()))
@@ -401,11 +401,10 @@ TargetSP TargetList::FindTargetWithExecutableAndArchitecture(
401401

402402
TargetSP TargetList::FindTargetWithProcessID(lldb::pid_t pid) const {
403403
std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
404-
auto it = std::find_if(m_target_list.begin(), m_target_list.end(),
405-
[pid](const TargetSP &item) {
406-
auto *process_ptr = item->GetProcessSP().get();
407-
return process_ptr && (process_ptr->GetID() == pid);
408-
});
404+
auto it = llvm::find_if(m_target_list, [pid](const TargetSP &item) {
405+
auto *process_ptr = item->GetProcessSP().get();
406+
return process_ptr && (process_ptr->GetID() == pid);
407+
});
409408

410409
if (it != m_target_list.end())
411410
return *it;
@@ -419,10 +418,9 @@ TargetSP TargetList::FindTargetWithProcess(Process *process) const {
419418
return target_sp;
420419

421420
std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
422-
auto it = std::find_if(m_target_list.begin(), m_target_list.end(),
423-
[process](const TargetSP &item) {
424-
return item->GetProcessSP().get() == process;
425-
});
421+
auto it = llvm::find_if(m_target_list, [process](const TargetSP &item) {
422+
return item->GetProcessSP().get() == process;
423+
});
426424

427425
if (it != m_target_list.end())
428426
target_sp = *it;
@@ -436,8 +434,9 @@ TargetSP TargetList::GetTargetSP(Target *target) const {
436434
return target_sp;
437435

438436
std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
439-
auto it = std::find_if(m_target_list.begin(), m_target_list.end(),
440-
[target](const TargetSP &item) { return item.get() == target; });
437+
auto it = llvm::find_if(m_target_list, [target](const TargetSP &item) {
438+
return item.get() == target;
439+
});
441440
if (it != m_target_list.end())
442441
target_sp = *it;
443442

0 commit comments

Comments
 (0)