summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2015-11-05 01:53:26 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2015-11-05 01:53:26 +0000
commit776e4a7da7a8da2dee2f2aa89235379ff9698047 (patch)
tree679696c01a59d1ae857313db1a5e0d5333b390b8
parentc29e698b8e50e8e0c7ea419b0632e95a5e3614d7 (diff)
downloadbcm5719-llvm-776e4a7da7a8da2dee2f2aa89235379ff9698047.tar.gz
bcm5719-llvm-776e4a7da7a8da2dee2f2aa89235379ff9698047.zip
[IR] Add bounds checking to dataOperandHasImpliedAttr
This is similar to the bounds check added to paramHasAttr in r252073. llvm-svn: 252130
-rw-r--r--llvm/lib/IR/Instructions.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 7c3695b1531..dfd711f5c23 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -343,6 +343,10 @@ bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
bool CallInst::dataOperandHasImpliedAttr(unsigned i,
Attribute::AttrKind A) const {
+ // There are getNumOperands() - 1 data operands. The last operand is the
+ // callee.
+ assert(i < getNumOperands() && "Data operand index out of bounds!");
+
// The attribute A can either be directly specified, if the operand in
// question is a call argument; or be indirectly implied by the kind of its
// containing operand bundle, if the operand is a bundle operand.
@@ -603,6 +607,10 @@ bool InvokeInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
bool InvokeInst::dataOperandHasImpliedAttr(unsigned i,
Attribute::AttrKind A) const {
+ // There are getNumOperands() - 3 data operands. The last three operands are
+ // the callee and the two successor basic blocks.
+ assert(i < (getNumOperands() - 2) && "Data operand index out of bounds!");
+
// The attribute A can either be directly specified, if the operand in
// question is an invoke argument; or be indirectly implied by the kind of its
// containing operand bundle, if the operand is a bundle operand.
OpenPOWER on IntegriCloud