From 5ed61fe6a108636a6f3de37d21ad80452f4c05a3 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 18 Nov 2010 17:14:56 +0000 Subject: Bounds-check APInt's operator[]. llvm-svn: 119708 --- llvm/lib/Support/APInt.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'llvm/lib/Support/APInt.cpp') diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index 88f9ac6..6bbe9ab 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/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; } -- cgit v1.1