[llvm] 3f6a1d1 - Guard against self-assignment in the DominatorTreeBase move assignment operator. (#116464)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 16 13:39:34 PST 2024
Author: Tom Honermann
Date: 2024-11-16T16:39:30-05:00
New Revision: 3f6a1d179305f266835242ac7d1e55249c50c074
URL: https://github.com/llvm/llvm-project/commit/3f6a1d179305f266835242ac7d1e55249c50c074
DIFF: https://github.com/llvm/llvm-project/commit/3f6a1d179305f266835242ac7d1e55249c50c074.diff
LOG: Guard against self-assignment in the DominatorTreeBase move assignment operator. (#116464)
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.
Added:
Modified:
llvm/include/llvm/Support/GenericDomTree.h
Removed:
################################################################################
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);
More information about the llvm-commits
mailing list