summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Instructions.cpp
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2015-11-04 20:33:45 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2015-11-04 20:33:45 +0000
commitb11b440f8e354b858579af454e72988a3e5d768d (patch)
tree2d4344db0b056c81c5bdf246abd3160281f7b2e1 /llvm/lib/IR/Instructions.cpp
parent2c38141423f6ed6ec4db641be76f61631366cbb1 (diff)
downloadbcm5719-llvm-b11b440f8e354b858579af454e72988a3e5d768d.tar.gz
bcm5719-llvm-b11b440f8e354b858579af454e72988a3e5d768d.zip
[IR] Add bounds checking to paramHasAttr
Summary: This is intended to make a later change simpler. Note: adding this bounds checking required fixing `X86FastISel`. As far I can tell I've preserved original behavior but a careful review will be appreciated. Reviewers: reames Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14304 llvm-svn: 252073
Diffstat (limited to 'llvm/lib/IR/Instructions.cpp')
-rw-r--r--llvm/lib/IR/Instructions.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 59ac99b6666..3394355cfb4 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -331,6 +331,8 @@ void CallInst::addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes) {
}
bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
+ assert(i < (getNumArgOperands() + 1) && "Param index out of bounds!");
+
if (AttributeList.hasAttribute(i, A))
return true;
if (const Function *F = getCalledFunction())
@@ -575,6 +577,8 @@ bool InvokeInst::hasFnAttrImpl(Attribute::AttrKind A) const {
}
bool InvokeInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
+ assert(i < (getNumArgOperands() + 1) && "Param index out of bounds!");
+
if (AttributeList.hasAttribute(i, A))
return true;
if (const Function *F = getCalledFunction())
OpenPOWER on IntegriCloud