[llvm] [ADT] Add a missing call to a unique_function destructor after move (PR #98747)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 13 07:49:28 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-adt
Author: Dmitry Yanovsky (kerambyte)
<details>
<summary>Changes</summary>
Right now immediately after moving the captured state, we `disarm` the moved-from object's destructor by resetting the `RHS.CallbackAndInlineFlag`. This means that we never properly destroy the RHS object's captured state.
---
Full diff: https://github.com/llvm/llvm-project/pull/98747.diff
1 Files Affected:
- (modified) llvm/include/llvm/ADT/FunctionExtras.h (+1)
``````````diff
diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index 49e0e8ab0db40..38a3829fb5137 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -312,6 +312,7 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
// Non-trivial move, so dispatch to a type-erased implementation.
getNonTrivialCallbacks()->MovePtr(getInlineStorage(),
RHS.getInlineStorage());
+ getNonTrivialCallbacks()->DestroyPtr(RHS.getInlineStorage());
}
// Clear the old callback and inline flag to get back to as-if-null.
``````````
</details>
https://github.com/llvm/llvm-project/pull/98747
More information about the llvm-commits
mailing list