This revision was automatically updated to reflect the committed changes. Closed by commit rG83599000e1f4: [lldb][Module] Document ModuleList::ForEach and assert nullness (authored by Michael137).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139082/new/ https://reviews.llvm.org/D139082 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 @@ -1067,9 +1067,10 @@ void ModuleList::ForEach( std::function<bool(const ModuleSP &module_sp)> const &callback) const { std::lock_guard<std::recursive_mutex> guard(m_modules_mutex); - for (const auto &module : m_modules) { + for (const auto &module_sp : m_modules) { + assert(module_sp != nullptr); // If the callback returns false, then stop iterating and break out - if (!callback(module)) + if (!callback(module_sp)) break; } } Index: lldb/include/lldb/Core/ModuleList.h =================================================================== --- lldb/include/lldb/Core/ModuleList.h +++ lldb/include/lldb/Core/ModuleList.h @@ -464,6 +464,12 @@ static bool RemoveSharedModuleIfOrphaned(const Module *module_ptr); + /// Applies 'callback' to each module in this ModuleList. + /// If 'callback' returns false, iteration terminates. + /// The 'module_sp' passed to 'callback' is guaranteed to + /// be non-null. + /// + /// This function is thread-safe. void ForEach(std::function<bool(const lldb::ModuleSP &module_sp)> const &callback) const;
Index: lldb/source/Core/ModuleList.cpp =================================================================== --- lldb/source/Core/ModuleList.cpp +++ lldb/source/Core/ModuleList.cpp @@ -1067,9 +1067,10 @@ void ModuleList::ForEach( std::function<bool(const ModuleSP &module_sp)> const &callback) const { std::lock_guard<std::recursive_mutex> guard(m_modules_mutex); - for (const auto &module : m_modules) { + for (const auto &module_sp : m_modules) { + assert(module_sp != nullptr); // If the callback returns false, then stop iterating and break out - if (!callback(module)) + if (!callback(module_sp)) break; } } Index: lldb/include/lldb/Core/ModuleList.h =================================================================== --- lldb/include/lldb/Core/ModuleList.h +++ lldb/include/lldb/Core/ModuleList.h @@ -464,6 +464,12 @@ static bool RemoveSharedModuleIfOrphaned(const Module *module_ptr); + /// Applies 'callback' to each module in this ModuleList. + /// If 'callback' returns false, iteration terminates. + /// The 'module_sp' passed to 'callback' is guaranteed to + /// be non-null. + /// + /// This function is thread-safe. void ForEach(std::function<bool(const lldb::ModuleSP &module_sp)> const &callback) const;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits