From 5c533ae837a2101e620a4e2f06acaa35f16e5fa7 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 10 Nov 2002 06:48:24 +0000 Subject: [PATCH] Implement swapping git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4674 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/DSNode.h | 15 +++++++++++++++ include/llvm/Analysis/DataStructure/DSNode.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/llvm/Analysis/DSNode.h b/include/llvm/Analysis/DSNode.h index 7726d72f378..64748d85b6f 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 7726d72f378..64748d85b6f 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