diff options
| author | Joerg Sonnenberger <joerg@bec.de> | 2014-03-31 22:53:57 +0000 |
|---|---|---|
| committer | Joerg Sonnenberger <joerg@bec.de> | 2014-03-31 22:53:57 +0000 |
| commit | deb1e4adc1fd0c80b464bda39ac7f724dea20f47 (patch) | |
| tree | b7ff19bfde0827f8df077e3a03e60fd6675cefc2 | |
| parent | ae2f0bbcf1b8ac81295a59ac9ad6858a054a811a (diff) | |
| download | bcm5719-llvm-deb1e4adc1fd0c80b464bda39ac7f724dea20f47.tar.gz bcm5719-llvm-deb1e4adc1fd0c80b464bda39ac7f724dea20f47.zip | |
Shifting into the sign bit is UB as discussed on IRC. Explicitly use the
BitWord type for the constants to avoid this.
llvm-svn: 205257
| -rw-r--r-- | llvm/include/llvm/ADT/BitVector.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/include/llvm/ADT/BitVector.h b/llvm/include/llvm/ADT/BitVector.h index e1aa0826cb6..b53182021ed 100644 --- a/llvm/include/llvm/ADT/BitVector.h +++ b/llvm/include/llvm/ADT/BitVector.h @@ -58,14 +58,14 @@ public: reference& operator=(bool t) { if (t) - *WordRef |= 1L << BitPos; + *WordRef |= BitWord(1) << BitPos; else - *WordRef &= ~(1L << BitPos); + *WordRef &= ~(BitWord(1) << BitPos); return *this; } operator bool() const { - return ((*WordRef) & (1L << BitPos)) ? true : false; + return ((*WordRef) & (BitWord(1) << BitPos)) ? true : false; } }; @@ -238,7 +238,7 @@ public: } BitVector &set(unsigned Idx) { - Bits[Idx / BITWORD_SIZE] |= 1L << (Idx % BITWORD_SIZE); + Bits[Idx / BITWORD_SIZE] |= BitWord(1) << (Idx % BITWORD_SIZE); return *this; } @@ -277,7 +277,7 @@ public: } BitVector &reset(unsigned Idx) { - Bits[Idx / BITWORD_SIZE] &= ~(1L << (Idx % BITWORD_SIZE)); + Bits[Idx / BITWORD_SIZE] &= ~(BitWord(1) << (Idx % BITWORD_SIZE)); return *this; } @@ -318,7 +318,7 @@ public: } BitVector &flip(unsigned Idx) { - Bits[Idx / BITWORD_SIZE] ^= 1L << (Idx % BITWORD_SIZE); + Bits[Idx / BITWORD_SIZE] ^= BitWord(1) << (Idx % BITWORD_SIZE); return *this; } @@ -330,7 +330,7 @@ public: bool operator[](unsigned Idx) const { assert (Idx < Size && "Out-of-bounds Bit access."); - BitWord Mask = 1L << (Idx % BITWORD_SIZE); + BitWord Mask = BitWord(1) << (Idx % BITWORD_SIZE); return (Bits[Idx / BITWORD_SIZE] & Mask) != 0; } |

