Tidy up assertion syntax. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94117 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2010-01-21 23:42:57 +00:00
parent edd7966809
commit 8767d32e75

View File

@ -190,23 +190,22 @@ public:
unsigned HL = getLeft() ? getLeft()->verify() : 0; unsigned HL = getLeft() ? getLeft()->verify() : 0;
unsigned HR = getRight() ? getRight()->verify() : 0; unsigned HR = getRight() ? getRight()->verify() : 0;
assert (getHeight() == ( HL > HR ? HL : HR ) + 1 assert(getHeight() == ( HL > HR ? HL : HR ) + 1
&& "Height calculation wrong."); && "Height calculation wrong");
assert ((HL > HR ? HL-HR : HR-HL) <= 2 assert((HL > HR ? HL-HR : HR-HL) <= 2
&& "Balancing invariant violated."); && "Balancing invariant violated");
assert(!getLeft()
assert (!getLeft()
|| ImutInfo::isLess(ImutInfo::KeyOfValue(getLeft()->getValue()), || ImutInfo::isLess(ImutInfo::KeyOfValue(getLeft()->getValue()),
ImutInfo::KeyOfValue(getValue())) ImutInfo::KeyOfValue(getValue()))
&& "Value in left child is not less that current value."); && "Value in left child is not less that current value");
assert (!getRight() assert(!getRight()
|| ImutInfo::isLess(ImutInfo::KeyOfValue(getValue()), || ImutInfo::isLess(ImutInfo::KeyOfValue(getValue()),
ImutInfo::KeyOfValue(getRight()->getValue())) ImutInfo::KeyOfValue(getRight()->getValue()))
&& "Current value is not less that value of right child."); && "Current value is not less that value of right child");
return getHeight(); return getHeight();
} }
@ -439,7 +438,7 @@ private:
} }
TreeTy* CreateNode(TreeTy* L, TreeTy* OldTree, TreeTy* R) { TreeTy* CreateNode(TreeTy* L, TreeTy* OldTree, TreeTy* R) {
assert (!isEmpty(OldTree)); assert(!isEmpty(OldTree));
if (OldTree->isMutable()) { if (OldTree->isMutable()) {
OldTree->setLeft(L); OldTree->setLeft(L);
@ -459,8 +458,7 @@ private:
unsigned hr = Height(R); unsigned hr = Height(R);
if (hl > hr + 2) { if (hl > hr + 2) {
assert (!isEmpty(L) && assert(!isEmpty(L) && "Left tree cannot be empty to have a height >= 2");
"Left tree cannot be empty to have a height >= 2.");
TreeTy* LL = Left(L); TreeTy* LL = Left(L);
TreeTy* LR = Right(L); TreeTy* LR = Right(L);
@ -468,8 +466,7 @@ private:
if (Height(LL) >= Height(LR)) if (Height(LL) >= Height(LR))
return CreateNode(LL, L, CreateNode(LR,V,R)); return CreateNode(LL, L, CreateNode(LR,V,R));
assert (!isEmpty(LR) && assert(!isEmpty(LR) && "LR cannot be empty because it has a height >= 1");
"LR cannot be empty because it has a height >= 1.");
TreeTy* LRL = Left(LR); TreeTy* LRL = Left(LR);
TreeTy* LRR = Right(LR); TreeTy* LRR = Right(LR);
@ -477,8 +474,7 @@ private:
return CreateNode(CreateNode(LL,L,LRL), LR, CreateNode(LRR,V,R)); return CreateNode(CreateNode(LL,L,LRL), LR, CreateNode(LRR,V,R));
} }
else if (hr > hl + 2) { else if (hr > hl + 2) {
assert (!isEmpty(R) && assert(!isEmpty(R) && "Right tree cannot be empty to have a height >= 2");
"Right tree cannot be empty to have a height >= 2.");
TreeTy* RL = Left(R); TreeTy* RL = Left(R);
TreeTy* RR = Right(R); TreeTy* RR = Right(R);
@ -486,8 +482,7 @@ private:
if (Height(RR) >= Height(RL)) if (Height(RR) >= Height(RL))
return CreateNode(CreateNode(L,V,RL), R, RR); return CreateNode(CreateNode(L,V,RL), R, RR);
assert (!isEmpty(RL) && assert(!isEmpty(RL) && "RL cannot be empty because it has a height >= 1");
"RL cannot be empty because it has a height >= 1.");
TreeTy* RLL = Left(RL); TreeTy* RLL = Left(RL);
TreeTy* RLR = Right(RL); TreeTy* RLR = Right(RL);
@ -505,7 +500,7 @@ private:
if (isEmpty(T)) if (isEmpty(T))
return CreateNode(T, V, T); return CreateNode(T, V, T);
assert (!T->isMutable()); assert(!T->isMutable());
key_type_ref K = ImutInfo::KeyOfValue(V); key_type_ref K = ImutInfo::KeyOfValue(V);
key_type_ref KCurrent = ImutInfo::KeyOfValue(Value(T)); key_type_ref KCurrent = ImutInfo::KeyOfValue(Value(T));
@ -526,7 +521,7 @@ private:
if (isEmpty(T)) if (isEmpty(T))
return T; return T;
assert (!T->isMutable()); assert(!T->isMutable());
key_type_ref KCurrent = ImutInfo::KeyOfValue(Value(T)); key_type_ref KCurrent = ImutInfo::KeyOfValue(Value(T));
@ -548,7 +543,7 @@ private:
} }
TreeTy* RemoveMinBinding(TreeTy* T, TreeTy*& NodeRemoved) { TreeTy* RemoveMinBinding(TreeTy* T, TreeTy*& NodeRemoved) {
assert (!isEmpty(T)); assert(!isEmpty(T));
if (isEmpty(Left(T))) { if (isEmpty(Left(T))) {
NodeRemoved = T; NodeRemoved = T;
@ -641,12 +636,12 @@ public:
} }
TreeTy* operator*() const { TreeTy* operator*() const {
assert (!stack.empty()); assert(!stack.empty());
return reinterpret_cast<TreeTy*>(stack.back() & ~Flags); return reinterpret_cast<TreeTy*>(stack.back() & ~Flags);
} }
uintptr_t getVisitState() { uintptr_t getVisitState() {
assert (!stack.empty()); assert(!stack.empty());
return stack.back() & Flags; return stack.back() & Flags;
} }
@ -658,7 +653,7 @@ public:
} }
void SkipToParent() { void SkipToParent() {
assert (!stack.empty()); assert(!stack.empty());
stack.pop_back(); stack.pop_back();
if (stack.empty()) if (stack.empty())
@ -672,7 +667,7 @@ public:
stack.back() |= VisitedRight; stack.back() |= VisitedRight;
break; break;
default: default:
assert (false && "Unreachable."); assert(false && "Unreachable.");
} }
} }
@ -690,10 +685,10 @@ public:
inline bool operator!=(const _Self& x) const { return !operator==(x); } inline bool operator!=(const _Self& x) const { return !operator==(x); }
_Self& operator++() { _Self& operator++() {
assert (!stack.empty()); assert(!stack.empty());
TreeTy* Current = reinterpret_cast<TreeTy*>(stack.back() & ~Flags); TreeTy* Current = reinterpret_cast<TreeTy*>(stack.back() & ~Flags);
assert (Current); assert(Current);
switch (getVisitState()) { switch (getVisitState()) {
case VisitedNone: case VisitedNone:
@ -717,17 +712,17 @@ public:
break; break;
default: default:
assert (false && "Unreachable."); assert(false && "Unreachable.");
} }
return *this; return *this;
} }
_Self& operator--() { _Self& operator--() {
assert (!stack.empty()); assert(!stack.empty());
TreeTy* Current = reinterpret_cast<TreeTy*>(stack.back() & ~Flags); TreeTy* Current = reinterpret_cast<TreeTy*>(stack.back() & ~Flags);
assert (Current); assert(Current);
switch (getVisitState()) { switch (getVisitState()) {
case VisitedNone: case VisitedNone:
@ -752,7 +747,7 @@ public:
break; break;
default: default:
assert (false && "Unreachable."); assert(false && "Unreachable.");
} }
return *this; return *this;