This revision was automatically updated to reflect the committed changes.
Closed by commit rG4cf9d1e4492f: [lldb][NFC] Modernize for-loops in ModuleList 
(authored by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112379/new/

https://reviews.llvm.org/D112379

Files:
  lldb/include/lldb/Core/ModuleList.h
  lldb/source/Core/ModuleList.cpp

Index: lldb/source/Core/ModuleList.cpp
===================================================================
--- lldb/source/Core/ModuleList.cpp
+++ lldb/source/Core/ModuleList.cpp
@@ -200,16 +200,15 @@
   }
 }
 
-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 @@
     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 @@
       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 @@
     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 @@
       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 @@
                                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 @@
                                      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 &regex, 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 @@
 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 @@
                                       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 @@
 
 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 @@
 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 @@
     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();
Index: lldb/include/lldb/Core/ModuleList.h
===================================================================
--- lldb/include/lldb/Core/ModuleList.h
+++ lldb/include/lldb/Core/ModuleList.h
@@ -159,7 +159,7 @@
   ///     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);
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to