[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h
Reid Spencer
reid at x10sys.com
Sat Mar 24 16:48:15 PDT 2007
Changes in directory llvm/include/llvm/ADT:
APInt.h updated: 1.54 -> 1.55
---
Log message:
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.
---
Diffs of the changes: (+2 -0)
APInt.h | 2 ++
1 files changed, 2 insertions(+)
Index: llvm/include/llvm/ADT/APInt.h
diff -u llvm/include/llvm/ADT/APInt.h:1.54 llvm/include/llvm/ADT/APInt.h:1.55
--- llvm/include/llvm/ADT/APInt.h:1.54 Sat Mar 24 18:42:47 2007
+++ llvm/include/llvm/ADT/APInt.h Sat Mar 24 18:47:58 2007
@@ -355,6 +355,7 @@
/// @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 @@
/// @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)
More information about the llvm-commits
mailing list