diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-11-05 01:53:26 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-11-05 01:53:26 +0000 |
commit | 4ae094a8512df6cdb6d3f8f17ef2565b8f9cd7e5 (patch) | |
tree | 8ed3938d931f1063670fdb0fd11c3db5697e4fbf /lib/IR | |
parent | 331a8c8a870f582385e659dc8785c7ba522136f5 (diff) |
[IR] Add bounds checking to dataOperandHasImpliedAttr
This is similar to the bounds check added to paramHasAttr in r252073.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252130 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r-- | lib/IR/Instructions.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp index 7c3695b1531..dfd711f5c23 100644 --- a/lib/IR/Instructions.cpp +++ b/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. |