[Lldb-commits] [lldb] 4cf9d1e - [lldb][NFC] Modernize for-loops in ModuleList
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Sat Oct 30 04:41:32 PDT 2021
Author: Raphael Isemann
Date: 2021-10-30T13:40:58+02:00
New Revision: 4cf9d1e4492fe70768d13fba5fbb61d9d93adf5c
URL: https://github.com/llvm/llvm-project/commit/4cf9d1e4492fe70768d13fba5fbb61d9d93adf5c
DIFF: https://github.com/llvm/llvm-project/commit/4cf9d1e4492fe70768d13fba5fbb61d9d93adf5c.diff
LOG: [lldb][NFC] Modernize for-loops in ModuleList
Reviewed By: mib
Differential Revision: https://reviews.llvm.org/D112379
Added:
Modified:
lldb/include/lldb/Core/ModuleList.h
lldb/source/Core/ModuleList.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h
index 39d4a63dbf464..6ca5813d9662a 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -159,7 +159,7 @@ class ModuleList {
/// ModulesDidLoad may be deferred when adding multiple Modules
/// to the Target, but it must be called at the end,
/// before resuming execution.
- bool AppendIfNeeded(const lldb::ModuleSP &module_sp, bool notify = true);
+ bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify = true);
void Append(const ModuleList &module_list);
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 44afed7fcf0de..629c075cbc00a 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -200,16 +200,15 @@ void ModuleList::ReplaceEquivalent(
}
}
-bool ModuleList::AppendIfNeeded(const ModuleSP &module_sp, bool notify) {
- if (module_sp) {
+bool ModuleList::AppendIfNeeded(const ModuleSP &new_module, bool notify) {
+ if (new_module) {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- if (pos->get() == module_sp.get())
+ for (const ModuleSP &module_sp : m_modules) {
+ if (module_sp.get() == new_module.get())
return false; // Already in the list
}
// Only push module_sp on the list if it wasn't already in there.
- Append(module_sp, notify);
+ Append(new_module, notify);
return true;
}
return false;
@@ -372,10 +371,10 @@ void ModuleList::FindFunctions(ConstString name,
Module::LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindFunctions(lookup_info.GetLookupName(), CompilerDeclContext(),
- lookup_info.GetNameTypeMask(), options, sc_list);
+ for (const ModuleSP &module_sp : m_modules) {
+ module_sp->FindFunctions(lookup_info.GetLookupName(),
+ CompilerDeclContext(),
+ lookup_info.GetNameTypeMask(), options, sc_list);
}
const size_t new_size = sc_list.GetSize();
@@ -384,10 +383,9 @@ void ModuleList::FindFunctions(ConstString name,
lookup_info.Prune(sc_list, old_size);
} else {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindFunctions(name, CompilerDeclContext(), name_type_mask,
- options, sc_list);
+ for (const ModuleSP &module_sp : m_modules) {
+ module_sp->FindFunctions(name, CompilerDeclContext(), name_type_mask,
+ options, sc_list);
}
}
}
@@ -401,10 +399,9 @@ void ModuleList::FindFunctionSymbols(ConstString name,
Module::LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindFunctionSymbols(lookup_info.GetLookupName(),
- lookup_info.GetNameTypeMask(), sc_list);
+ for (const ModuleSP &module_sp : m_modules) {
+ module_sp->FindFunctionSymbols(lookup_info.GetLookupName(),
+ lookup_info.GetNameTypeMask(), sc_list);
}
const size_t new_size = sc_list.GetSize();
@@ -413,9 +410,8 @@ void ModuleList::FindFunctionSymbols(ConstString name,
lookup_info.Prune(sc_list, old_size);
} else {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindFunctionSymbols(name, name_type_mask, sc_list);
+ for (const ModuleSP &module_sp : m_modules) {
+ module_sp->FindFunctionSymbols(name, name_type_mask, sc_list);
}
}
}
@@ -424,28 +420,23 @@ void ModuleList::FindFunctions(const RegularExpression &name,
const ModuleFunctionSearchOptions &options,
SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindFunctions(name, options, sc_list);
- }
+ for (const ModuleSP &module_sp : m_modules)
+ module_sp->FindFunctions(name, options, sc_list);
}
void ModuleList::FindCompileUnits(const FileSpec &path,
SymbolContextList &sc_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindCompileUnits(path, sc_list);
- }
+ for (const ModuleSP &module_sp : m_modules)
+ module_sp->FindCompileUnits(path, sc_list);
}
void ModuleList::FindGlobalVariables(ConstString name, size_t max_matches,
VariableList &variable_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindGlobalVariables(name, CompilerDeclContext(), max_matches,
- variable_list);
+ for (const ModuleSP &module_sp : m_modules) {
+ module_sp->FindGlobalVariables(name, CompilerDeclContext(), max_matches,
+ variable_list);
}
}
@@ -453,36 +444,30 @@ void ModuleList::FindGlobalVariables(const RegularExpression ®ex,
size_t max_matches,
VariableList &variable_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindGlobalVariables(regex, max_matches, variable_list);
- }
+ for (const ModuleSP &module_sp : m_modules)
+ module_sp->FindGlobalVariables(regex, max_matches, variable_list);
}
void ModuleList::FindSymbolsWithNameAndType(ConstString name,
SymbolType symbol_type,
SymbolContextList &sc_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos)
- (*pos)->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
+ for (const ModuleSP &module_sp : m_modules)
+ module_sp->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
}
void ModuleList::FindSymbolsMatchingRegExAndType(
const RegularExpression ®ex, lldb::SymbolType symbol_type,
SymbolContextList &sc_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos)
- (*pos)->FindSymbolsMatchingRegExAndType(regex, symbol_type, sc_list);
+ for (const ModuleSP &module_sp : m_modules)
+ module_sp->FindSymbolsMatchingRegExAndType(regex, symbol_type, sc_list);
}
void ModuleList::FindModules(const ModuleSpec &module_spec,
ModuleList &matching_module_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- ModuleSP module_sp(*pos);
+ for (const ModuleSP &module_sp : m_modules) {
if (module_sp->MatchesModuleSpec(module_spec))
matching_module_list.Append(module_sp);
}
@@ -558,9 +543,8 @@ void ModuleList::FindTypes(Module *search_first, ConstString name,
bool ModuleList::FindSourceFile(const FileSpec &orig_spec,
FileSpec &new_spec) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- if ((*pos)->FindSourceFile(orig_spec, new_spec))
+ for (const ModuleSP &module_sp : m_modules) {
+ if (module_sp->FindSourceFile(orig_spec, new_spec))
return true;
}
return false;
@@ -572,10 +556,9 @@ void ModuleList::FindAddressesForLine(const lldb::TargetSP target_sp,
std::vector<Address> &output_local,
std::vector<Address> &output_extern) {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindAddressesForLine(target_sp, file, line, function, output_local,
- output_extern);
+ for (const ModuleSP &module_sp : m_modules) {
+ module_sp->FindAddressesForLine(target_sp, file, line, function,
+ output_local, output_extern);
}
}
@@ -602,10 +585,8 @@ size_t ModuleList::GetSize() const {
void ModuleList::Dump(Stream *s) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->Dump(s);
- }
+ for (const ModuleSP &module_sp : m_modules)
+ module_sp->Dump(s);
}
void ModuleList::LogUUIDAndPaths(Log *log, const char *prefix_cstr) {
@@ -628,9 +609,8 @@ void ModuleList::LogUUIDAndPaths(Log *log, const char *prefix_cstr) {
bool ModuleList::ResolveFileAddress(lldb::addr_t vm_addr,
Address &so_addr) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- if ((*pos)->ResolveFileAddress(vm_addr, so_addr))
+ for (const ModuleSP &module_sp : m_modules) {
+ if (module_sp->ResolveFileAddress(vm_addr, so_addr))
return true;
}
@@ -673,10 +653,9 @@ uint32_t ModuleList::ResolveSymbolContextsForFileSpec(
const FileSpec &file_spec, uint32_t line, bool check_inlines,
SymbolContextItem resolve_scope, SymbolContextList &sc_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- collection::const_iterator pos, end = m_modules.end();
- for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
- resolve_scope, sc_list);
+ for (const ModuleSP &module_sp : m_modules) {
+ module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
+ resolve_scope, sc_list);
}
return sc_list.GetSize();
More information about the lldb-commits
mailing list