mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 18:24:00 +00:00
Miscellaneous Fixes for SparseBitVector
Summary: 1. Fix return value in `SparseBitVector::operator&=`. 2. Add checks if SBV is being assigned is invoking SBV. Reviewers: dberlin Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11342 Committed on behalf of sl@ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242693 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -453,6 +453,9 @@ public:
|
||||
|
||||
// Assignment
|
||||
SparseBitVector& operator=(const SparseBitVector& RHS) {
|
||||
if (this == &RHS)
|
||||
return *this;
|
||||
|
||||
Elements.clear();
|
||||
|
||||
ElementListConstIter ElementIter = RHS.Elements.begin();
|
||||
@ -559,6 +562,9 @@ public:
|
||||
|
||||
// Union our bitmap with the RHS and return true if we changed.
|
||||
bool operator|=(const SparseBitVector &RHS) {
|
||||
if (this == &RHS)
|
||||
return false;
|
||||
|
||||
bool changed = false;
|
||||
ElementListIter Iter1 = Elements.begin();
|
||||
ElementListConstIter Iter2 = RHS.Elements.begin();
|
||||
@ -587,6 +593,9 @@ public:
|
||||
|
||||
// Intersect our bitmap with the RHS and return true if ours changed.
|
||||
bool operator&=(const SparseBitVector &RHS) {
|
||||
if (this == &RHS)
|
||||
return false;
|
||||
|
||||
bool changed = false;
|
||||
ElementListIter Iter1 = Elements.begin();
|
||||
ElementListConstIter Iter2 = RHS.Elements.begin();
|
||||
@ -619,9 +628,13 @@ public:
|
||||
ElementListIter IterTmp = Iter1;
|
||||
++Iter1;
|
||||
Elements.erase(IterTmp);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
Elements.erase(Iter1, Elements.end());
|
||||
if (Iter1 != Elements.end()) {
|
||||
Elements.erase(Iter1, Elements.end());
|
||||
changed = true;
|
||||
}
|
||||
CurrElementIter = Elements.begin();
|
||||
return changed;
|
||||
}
|
||||
@ -629,6 +642,14 @@ public:
|
||||
// Intersect our bitmap with the complement of the RHS and return true
|
||||
// if ours changed.
|
||||
bool intersectWithComplement(const SparseBitVector &RHS) {
|
||||
if (this == &RHS) {
|
||||
if (!empty()) {
|
||||
clear();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
ElementListIter Iter1 = Elements.begin();
|
||||
ElementListConstIter Iter2 = RHS.Elements.begin();
|
||||
@ -675,6 +696,15 @@ public:
|
||||
void intersectWithComplement(const SparseBitVector<ElementSize> &RHS1,
|
||||
const SparseBitVector<ElementSize> &RHS2)
|
||||
{
|
||||
if (this == &RHS1) {
|
||||
intersectWithComplement(RHS2);
|
||||
return;
|
||||
} else if (this == &RHS2) {
|
||||
SparseBitVector RHS2Copy(RHS2);
|
||||
intersectWithComplement(RHS1, RHS2Copy);
|
||||
return;
|
||||
}
|
||||
|
||||
Elements.clear();
|
||||
CurrElementIter = Elements.begin();
|
||||
ElementListConstIter Iter1 = RHS1.Elements.begin();
|
||||
|
Reference in New Issue
Block a user