diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-25 00:01:47 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-25 00:01:47 +0000 |
commit | d4e07f200ad7b99d4decc61eb0136d25a6fde4cb (patch) | |
tree | ab67ec06b4e759dd2bf8073a5c140264c6af4d77 /llvm | |
parent | 3a8248f79dd0b233ac3f455053a6e5f6fc0dc433 (diff) | |
download | bcm5719-llvm-d4e07f200ad7b99d4decc61eb0136d25a6fde4cb.tar.gz bcm5719-llvm-d4e07f200ad7b99d4decc61eb0136d25a6fde4cb.zip |
Actually, for getHighBitsSet and getLowBitsSet, don't make a 0 bit size
illegal. Instead do the 0 valued construction for the user. This is because
the caller may not know (or care to check) that the number of bits set is
zero.
llvm-svn: 35315
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/ADT/APInt.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 8f3b2f6a6d4..7e5132f0d02 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -355,7 +355,9 @@ 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"); + // Handle a degenerate case, to avoid shifting by word size + if (hiBitsSet == 0) + return APInt(numBits, 0); uint32_t shiftAmt = numBits - hiBitsSet; // For small values, return quickly if (numBits <= APINT_BITS_PER_WORD) @@ -369,7 +371,9 @@ 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"); + // Handle a degenerate case, to avoid shifting by word size + if (loBitsSet == 0) + return APInt(numBits, 0); uint32_t shiftAmt = numBits - loBitsSet; // For small values, return quickly if (numBits <= APINT_BITS_PER_WORD) |