[Lldb-commits] [lldb] b22ea2d - [lldb] Use SmallVector::erase correctly
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Fri Jun 28 01:40:30 PDT 2024
Author: Pavel Labath
Date: 2024-06-28T10:40:13+02:00
New Revision: b22ea2dc1e065f14a88df44e22a62427965a9b05
URL: https://github.com/llvm/llvm-project/commit/b22ea2dc1e065f14a88df44e22a62427965a9b05
DIFF: https://github.com/llvm/llvm-project/commit/b22ea2dc1e065f14a88df44e22a62427965a9b05.diff
LOG: [lldb] Use SmallVector::erase correctly
erase() invalidates the iterator, we must use the returned iterator to
continue iterating.
This does not actually make a difference with the current implementation
of SmallVector (erase will effectively return the same pointer), but it
avoids future confusion.
Added:
Modified:
lldb/source/Utility/Broadcaster.cpp
Removed:
################################################################################
diff --git a/lldb/source/Utility/Broadcaster.cpp b/lldb/source/Utility/Broadcaster.cpp
index bd65ffd86a1d0..b6d8ae39325d3 100644
--- a/lldb/source/Utility/Broadcaster.cpp
+++ b/lldb/source/Utility/Broadcaster.cpp
@@ -202,7 +202,7 @@ bool Broadcaster::BroadcasterImpl::RemoveListener(
if (!curr_listener_sp) {
// The weak pointer for this listener didn't resolve, lets' prune it
// as we go.
- m_listeners.erase(it);
+ it = m_listeners.erase(it);
continue;
}
@@ -213,8 +213,8 @@ bool Broadcaster::BroadcasterImpl::RemoveListener(
if (!it->second)
m_listeners.erase(it);
return true;
- } else
- it++;
+ }
+ it++;
}
return false;
}
More information about the lldb-commits
mailing list