[llvm] r252130 - [IR] Add bounds checking to dataOperandHasImpliedAttr
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 4 17:53:26 PST 2015
Author: sanjoy
Date: Wed Nov 4 19:53:26 2015
New Revision: 252130
URL: http://llvm.org/viewvc/llvm-project?rev=252130&view=rev
Log:
[IR] Add bounds checking to dataOperandHasImpliedAttr
This is similar to the bounds check added to paramHasAttr in r252073.
Modified:
llvm/trunk/lib/IR/Instructions.cpp
Modified: llvm/trunk/lib/IR/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=252130&r1=252129&r2=252130&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instructions.cpp (original)
+++ llvm/trunk/lib/IR/Instructions.cpp Wed Nov 4 19:53:26 2015
@@ -343,6 +343,10 @@ bool CallInst::paramHasAttr(unsigned i,
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
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.
More information about the llvm-commits
mailing list