summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-03-24 23:47:58 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-03-24 23:47:58 +0000
commit42fbb4fbe3bf58c15055d64a91e8eaa4a27ed87f (patch)
treef522181314dcb429b5e169084102689b0eddd9c1 /llvm
parent790631ff2d22e74cd35d8326c401f6114c357f59 (diff)
downloadbcm5719-llvm-42fbb4fbe3bf58c15055d64a91e8eaa4a27ed87f.tar.gz
bcm5719-llvm-42fbb4fbe3bf58c15055d64a91e8eaa4a27ed87f.zip
Make it illegal to set 0 bits in getHighBitsSet and getLowBitsSet. For that
they should have used the uint64_t constructor. This avoids causing undefined results via shifts by the word size when the bit width is an exact multiple of the word size. llvm-svn: 35313
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/ADT/APInt.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index b524b56e9b4..8f3b2f6a6d4 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -355,6 +355,7 @@ public:
/// @brief Get a value with high bits set
static APInt getHighBitsSet(uint32_t numBits, uint32_t hiBitsSet) {
assert(hiBitsSet <= numBits && "Too many bits to set!");
+ assert(hiBitsSet > 0 && "You must set SOME bits");
uint32_t shiftAmt = numBits - hiBitsSet;
// For small values, return quickly
if (numBits <= APINT_BITS_PER_WORD)
@@ -368,6 +369,7 @@ public:
/// @brief Get a value with low bits set
static APInt getLowBitsSet(uint32_t numBits, uint32_t loBitsSet) {
assert(loBitsSet <= numBits && "Too many bits to set!");
+ assert(loBitsSet > 0 && "You must set SOME bits");
uint32_t shiftAmt = numBits - loBitsSet;
// For small values, return quickly
if (numBits <= APINT_BITS_PER_WORD)
OpenPOWER on IntegriCloud