[Lldb-commits] [lldb] [lldb] Implement PluginInfo move constructor (PR #185137)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 6 15:50:07 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Jonas Devlieghere (JDevlieghere)
<details>
<summary>Changes</summary>
The default move constructor wasn't nulling out the callbacks. Combined with the fact that llvm::sys::DynamicLibrary has no explicit move constructor and hence library.isValid() still returned true after having moved-from, we would end up calling plugin_term_callback() when destroying the moved-from PluginInfo, calling it prematurely.
---
Full diff: https://github.com/llvm/llvm-project/pull/185137.diff
1 Files Affected:
- (modified) lldb/source/Core/PluginManager.cpp (+13-2)
``````````diff
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index 430c9131ee6be..91dd2dac0dcaa 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -46,8 +46,19 @@ struct PluginInfo {
PluginInfo(const PluginInfo &) = delete;
PluginInfo &operator=(const PluginInfo &) = delete;
- PluginInfo(PluginInfo &&) = default;
- PluginInfo &operator=(PluginInfo &&) = default;
+ PluginInfo(PluginInfo &&other)
+ : library(std::move(other.library)),
+ plugin_init_callback(
+ std::exchange(other.plugin_init_callback, nullptr)),
+ plugin_term_callback(
+ std::exchange(other.plugin_term_callback, nullptr)) {}
+
+ PluginInfo &operator=(PluginInfo &&other) {
+ library = std::move(other.library);
+ plugin_init_callback = std::exchange(other.plugin_init_callback, nullptr);
+ plugin_term_callback = std::exchange(other.plugin_term_callback, nullptr);
+ return *this;
+ }
~PluginInfo() {
if (!library.isValid())
``````````
</details>
https://github.com/llvm/llvm-project/pull/185137
More information about the lldb-commits
mailing list