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 04288e93be
commit 4c0a965c09
1 changed files with 2 additions and 2 deletions

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;
}
};