aboutsummaryrefslogtreecommitdiffstats
path: root/include/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
commit758d1bc919f3f0856df102f6db64ef9b894d4c23 (patch)
tree547f8a75fabff1305e8775b8d5df4400c54b0a22 /include/llvm
parent5b7e659e220ed01c8d3a7335e2b52ff2f0fb2ef3 (diff)
downloadexternal_llvm-758d1bc919f3f0856df102f6db64ef9b894d4c23.zip
external_llvm-758d1bc919f3f0856df102f6db64ef9b894d4c23.tar.gz
external_llvm-758d1bc919f3f0856df102f6db64ef9b894d4c23.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35313 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/ADT/APInt.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h
index b524b56..8f3b2f6 100644
--- a/include/llvm/ADT/APInt.h
+++ b/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)