summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Regehr <regehr@cs.utah.edu>2018-11-18 01:51:43 +0000
committerJohn Regehr <regehr@cs.utah.edu>2018-11-18 01:51:43 +0000
commitab7781493d9edd2ad92e896ec310eb95dbf69d41 (patch)
tree47b9a5912b9d1743948cdb96c62317c83e44d228
parent35f504c1131a8de2c12b70d36222667803981b67 (diff)
downloadbcm5719-llvm-ab7781493d9edd2ad92e896ec310eb95dbf69d41.tar.gz
bcm5719-llvm-ab7781493d9edd2ad92e896ec310eb95dbf69d41.zip
tighten up a couple of assertions. hitting the BitPosition == BitWidth case that was previously not caught resulted in nasty corruption of APInts that (on my system at least) could not be detected using UBSan, ASan, or Valgrind. this patch does not cause any extra failures in a check-all nor does it interfere with bootstrapping. David Blaikie informally approved this change.
llvm-svn: 347148
-rw-r--r--llvm/include/llvm/ADT/APInt.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 1befe7a0273..90387bba4d6 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -1395,7 +1395,7 @@ public:
///
/// Set the given bit to 1 whose position is given as "bitPosition".
void setBit(unsigned BitPosition) {
- assert(BitPosition <= BitWidth && "BitPosition out of range");
+ assert(BitPosition < BitWidth && "BitPosition out of range");
WordType Mask = maskBit(BitPosition);
if (isSingleWord())
U.VAL |= Mask;
@@ -1454,7 +1454,7 @@ public:
///
/// Set the given bit to 0 whose position is given as "bitPosition".
void clearBit(unsigned BitPosition) {
- assert(BitPosition <= BitWidth && "BitPosition out of range");
+ assert(BitPosition < BitWidth && "BitPosition out of range");
WordType Mask = ~maskBit(BitPosition);
if (isSingleWord())
U.VAL &= Mask;
OpenPOWER on IntegriCloud