Skip to content

Commit 3f6a1d1

Browse files
authored
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.
1 parent 4a6f59a commit 3f6a1d1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

llvm/include/llvm/Support/GenericDomTree.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ class DominatorTreeBase {
287287
}
288288

289289
DominatorTreeBase &operator=(DominatorTreeBase &&RHS) {
290+
if (this == &RHS)
291+
return *this;
290292
Roots = std::move(RHS.Roots);
291293
DomTreeNodes = std::move(RHS.DomTreeNodes);
292294
NodeNumberMap = std::move(RHS.NodeNumberMap);

0 commit comments

Comments
 (0)