[llvm] 4c0a965 - Fix off by one error in Bitfields
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 6 01:52:14 PDT 2020
Author: Guillaume Chatelet
Date: 2020-07-06T08:47:58Z
New Revision: 4c0a965c0926d5d6aa786a7de60f7939239099e3
URL: https://github.com/llvm/llvm-project/commit/4c0a965c0926d5d6aa786a7de60f7939239099e3
DIFF: https://github.com/llvm/llvm-project/commit/4c0a965c0926d5d6aa786a7de60f7939239099e3.diff
LOG: Fix off by one error in Bitfields
Differential Revision: https://reviews.llvm.org/D83192
Added:
Modified:
llvm/include/llvm/ADT/Bitfields.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/Bitfields.h b/llvm/include/llvm/ADT/Bitfields.h
index 2e38cca673ea..68b1549a0ac5 100644
--- a/llvm/include/llvm/ADT/Bitfields.h
+++ b/llvm/include/llvm/ADT/Bitfields.h
@@ -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;
}
};
More information about the llvm-commits
mailing list