[llvm] Guard against self-assignment in the DominatorTreeBase move assignment operator. (PR #116464)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 15 21:48:12 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: Tom Honermann (tahonermann)
<details>
<summary>Changes</summary>
The `DominatorTreeBase` move assignment operator was not self-assignment safe because the last thing it does before returning is to release all resources held by the source object. This issue was reported by a static analysis tool; no self-assignment is known to occur in practice.
---
Full diff: https://github.com/llvm/llvm-project/pull/116464.diff
1 Files Affected:
- (modified) llvm/include/llvm/Support/GenericDomTree.h (+2)
``````````diff
diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h
index 45ef38b965b752..d0eec2070b4d7e 100644
--- a/llvm/include/llvm/Support/GenericDomTree.h
+++ b/llvm/include/llvm/Support/GenericDomTree.h
@@ -287,6 +287,8 @@ class DominatorTreeBase {
}
DominatorTreeBase &operator=(DominatorTreeBase &&RHS) {
+ if (this == &RHS)
+ return *this;
Roots = std::move(RHS.Roots);
DomTreeNodes = std::move(RHS.DomTreeNodes);
NodeNumberMap = std::move(RHS.NodeNumberMap);
``````````
</details>
https://github.com/llvm/llvm-project/pull/116464
More information about the llvm-commits
mailing list