Bounds-check APInt's operator[].

llvm-svn: 119708
This commit is contained in:
Dan Gohman 2010-11-18 17:14:56 +00:00
parent 21a9683641
commit 5ed61fe6a1
1 changed files with 1 additions and 0 deletions

View File

@ -483,6 +483,7 @@ APInt APInt::operator-(const APInt& RHS) const {
}
bool APInt::operator[](unsigned bitPosition) const {
assert(bitPosition < getBitWidth() && "Bit position out of bounds!");
return (maskBit(bitPosition) &
(isSingleWord() ? VAL : pVal[whichWord(bitPosition)])) != 0;
}