Implement swapping
authorChris Lattner <sabre@nondot.org>
Sun, 10 Nov 2002 06:48:24 +0000 (06:48 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 10 Nov 2002 06:48:24 +0000 (06:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4674 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/DSNode.h
include/llvm/Analysis/DataStructure/DSNode.h

index 7726d72f378604adde99035895cb985ca53fe211..64748d85b6f965261c293e98794c8fc0e45c9aaa 100644 (file)
@@ -271,4 +271,19 @@ inline void DSNodeHandle::mergeWith(const DSNodeHandle &Node) {
     *this = Node;
 }
 
+inline void DSNodeHandle::swap(DSNodeHandle &NH) {
+  std::swap(Offset, NH.Offset);
+  if (N != NH.N) {
+    if (N) {
+      N->removeReferrer(this);
+      N->addReferrer(&NH);
+    }
+    if (NH.N) {
+      N->removeReferrer(&NH);
+      N->addReferrer(this);
+    }
+    std::swap(N, NH.N);
+  }
+}
+
 #endif
index 7726d72f378604adde99035895cb985ca53fe211..64748d85b6f965261c293e98794c8fc0e45c9aaa 100644 (file)
@@ -271,4 +271,19 @@ inline void DSNodeHandle::mergeWith(const DSNodeHandle &Node) {
     *this = Node;
 }
 
+inline void DSNodeHandle::swap(DSNodeHandle &NH) {
+  std::swap(Offset, NH.Offset);
+  if (N != NH.N) {
+    if (N) {
+      N->removeReferrer(this);
+      N->addReferrer(&NH);
+    }
+    if (NH.N) {
+      N->removeReferrer(&NH);
+      N->addReferrer(this);
+    }
+    std::swap(N, NH.N);
+  }
+}
+
 #endif