From: Dan Gohman Date: Thu, 18 Nov 2010 17:14:56 +0000 (+0000) Subject: Bounds-check APInt's operator[]. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=078d967e0a7e6dd78ac9eb28a1d50fd9319b88d1;p=oota-llvm.git Bounds-check APInt's operator[]. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119708 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp index 88f9ac63f7e..6bbe9ab4632 100644 --- a/lib/Support/APInt.cpp +++ b/lib/Support/APInt.cpp @@ -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; }