aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Analysis/DSNode.h15
-rw-r--r--include/llvm/Analysis/DataStructure/DSNode.h15
2 files changed, 30 insertions, 0 deletions
diff --git a/include/llvm/Analysis/DSNode.h b/include/llvm/Analysis/DSNode.h
index 7726d72f37..64748d85b6 100644
--- a/include/llvm/Analysis/DSNode.h
+++ b/include/llvm/Analysis/DSNode.h
@@ -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
diff --git a/include/llvm/Analysis/DataStructure/DSNode.h b/include/llvm/Analysis/DataStructure/DSNode.h
index 7726d72f37..64748d85b6 100644
--- a/include/llvm/Analysis/DataStructure/DSNode.h
+++ b/include/llvm/Analysis/DataStructure/DSNode.h
@@ -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