mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-21 21:41:43 +00:00
Shifting into the sign bit is UB as discussed on IRC. Explicitly use the
BitWord type for the constants to avoid this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205257 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d8c9577764
commit
d73449481d
@ -58,14 +58,14 @@ public:
|
|||||||
|
|
||||||
reference& operator=(bool t) {
|
reference& operator=(bool t) {
|
||||||
if (t)
|
if (t)
|
||||||
*WordRef |= 1L << BitPos;
|
*WordRef |= BitWord(1) << BitPos;
|
||||||
else
|
else
|
||||||
*WordRef &= ~(1L << BitPos);
|
*WordRef &= ~(BitWord(1) << BitPos);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool() const {
|
operator bool() const {
|
||||||
return ((*WordRef) & (1L << BitPos)) ? true : false;
|
return ((*WordRef) & (BitWord(1) << BitPos)) ? true : false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
BitVector &set(unsigned Idx) {
|
BitVector &set(unsigned Idx) {
|
||||||
Bits[Idx / BITWORD_SIZE] |= 1L << (Idx % BITWORD_SIZE);
|
Bits[Idx / BITWORD_SIZE] |= BitWord(1) << (Idx % BITWORD_SIZE);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
BitVector &reset(unsigned Idx) {
|
BitVector &reset(unsigned Idx) {
|
||||||
Bits[Idx / BITWORD_SIZE] &= ~(1L << (Idx % BITWORD_SIZE));
|
Bits[Idx / BITWORD_SIZE] &= ~(BitWord(1) << (Idx % BITWORD_SIZE));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
BitVector &flip(unsigned Idx) {
|
BitVector &flip(unsigned Idx) {
|
||||||
Bits[Idx / BITWORD_SIZE] ^= 1L << (Idx % BITWORD_SIZE);
|
Bits[Idx / BITWORD_SIZE] ^= BitWord(1) << (Idx % BITWORD_SIZE);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ public:
|
|||||||
|
|
||||||
bool operator[](unsigned Idx) const {
|
bool operator[](unsigned Idx) const {
|
||||||
assert (Idx < Size && "Out-of-bounds Bit access.");
|
assert (Idx < Size && "Out-of-bounds Bit access.");
|
||||||
BitWord Mask = 1L << (Idx % BITWORD_SIZE);
|
BitWord Mask = BitWord(1) << (Idx % BITWORD_SIZE);
|
||||||
return (Bits[Idx / BITWORD_SIZE] & Mask) != 0;
|
return (Bits[Idx / BITWORD_SIZE] & Mask) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user