1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

Fix off by one error in Bitfields

Differential Revision: https://reviews.llvm.org/D83192
This commit is contained in:
Guillaume Chatelet 2020-07-06 08:47:58 +00:00
parent 309087bb01
commit 6e9457fc4d

View File

@ -227,7 +227,7 @@ struct Bitfield {
static constexpr unsigned Shift = Offset;
static constexpr unsigned Bits = Size;
static constexpr unsigned FirstBit = Offset;
static constexpr unsigned LastBit = Shift + Bits;
static constexpr unsigned LastBit = Shift + Bits - 1;
private:
template <typename, typename> friend struct bitfields_details::Impl;
@ -273,7 +273,7 @@ struct Bitfield {
/// Returns whether the two bitfields share common bits.
template <typename A, typename B> static constexpr bool isOverlapping() {
return A::LastBit > B::FirstBit && B::LastBit > A::FirstBit;
return A::LastBit >= B::FirstBit && B::LastBit >= A::FirstBit;
}
};