From 55d77d9a3fb80164b2b251654a3984deb5d4f7a0 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 4 Nov 2002 23:59:41 +0000 Subject: [PATCH] Add a bunch of assertions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4549 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/DSNode.h | 12 ++++++++++-- include/llvm/Analysis/DataStructure/DSNode.h | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/llvm/Analysis/DSNode.h b/include/llvm/Analysis/DSNode.h index 367c377a34a..9ade44437cb 100644 --- a/include/llvm/Analysis/DSNode.h +++ b/include/llvm/Analysis/DSNode.h @@ -126,13 +126,19 @@ public: } DSNodeHandle *getLink(unsigned i) { - if (hasLink(i)) + if (hasLink(i)) { + assert((unsigned)MergeMap[i] < Links.size() && + "MergeMap references Link that doesn't exist!"); return &Links[MergeMap[i]]; + } return 0; } const DSNodeHandle *getLink(unsigned i) const { - if (hasLink(i)) + if (hasLink(i)) { + assert((unsigned)MergeMap[i] < Links.size() && + "MergeMap references Link that doesn't exist!"); return &Links[MergeMap[i]]; + } return 0; } @@ -226,6 +232,8 @@ private: /// void rewriteMergeMap(signed char From, signed char To) { assert(From != To && "Cannot change something into itself!"); + assert(To < (int)Links.size() && + "Changing MergeMap entry to an illegal entry!"); for (unsigned i = 0, e = MergeMap.size(); i != e; ++i) if (MergeMap[i] == From) MergeMap[i] = To; diff --git a/include/llvm/Analysis/DataStructure/DSNode.h b/include/llvm/Analysis/DataStructure/DSNode.h index 367c377a34a..9ade44437cb 100644 --- a/include/llvm/Analysis/DataStructure/DSNode.h +++ b/include/llvm/Analysis/DataStructure/DSNode.h @@ -126,13 +126,19 @@ public: } DSNodeHandle *getLink(unsigned i) { - if (hasLink(i)) + if (hasLink(i)) { + assert((unsigned)MergeMap[i] < Links.size() && + "MergeMap references Link that doesn't exist!"); return &Links[MergeMap[i]]; + } return 0; } const DSNodeHandle *getLink(unsigned i) const { - if (hasLink(i)) + if (hasLink(i)) { + assert((unsigned)MergeMap[i] < Links.size() && + "MergeMap references Link that doesn't exist!"); return &Links[MergeMap[i]]; + } return 0; } @@ -226,6 +232,8 @@ private: /// void rewriteMergeMap(signed char From, signed char To) { assert(From != To && "Cannot change something into itself!"); + assert(To < (int)Links.size() && + "Changing MergeMap entry to an illegal entry!"); for (unsigned i = 0, e = MergeMap.size(); i != e; ++i) if (MergeMap[i] == From) MergeMap[i] = To; -- 2.34.1