Use the multi-lockable form of std::lock for operator=
For = operators for lists that have mutexes, we were either
just taking the locks sequentially or hand-rolling a trick
to try to avoid lock inversion. Use the std::lock mechanism
for this instead.
Differential Revision: https://reviews.llvm.org/D59957
llvm-svn: 357276
diff --git a/lldb/source/Target/SectionLoadList.cpp b/lldb/source/Target/SectionLoadList.cpp
index 45b6b52..598f49c 100644
--- a/lldb/source/Target/SectionLoadList.cpp
+++ b/lldb/source/Target/SectionLoadList.cpp
@@ -27,8 +27,9 @@
}
void SectionLoadList::operator=(const SectionLoadList &rhs) {
- std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
+ std::lock(m_mutex, rhs.m_mutex);
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex, std::adopt_lock);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex, std::adopt_lock);
m_addr_to_sect = rhs.m_addr_to_sect;
m_sect_to_addr = rhs.m_sect_to_addr;
}