Skip to content

Commit

Permalink
[IR] Add some asserts to CallInst and InvokeInst; NFCI.
Browse files Browse the repository at this point in the history
The asserts check that accessors supposed to access call / invoke
arguments only ever access call / invoke arguments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246316 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
sanjoy committed Aug 28, 2015
1 parent c93f771 commit 18188f1
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions include/llvm/IR/Instructions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1473,8 +1473,14 @@ class CallInst : public Instruction {

/// getArgOperand/setArgOperand - Return/set the i-th call argument.
///
Value *getArgOperand(unsigned i) const { return getOperand(i); }
void setArgOperand(unsigned i, Value *v) { setOperand(i, v); }
Value *getArgOperand(unsigned i) const {
assert(i < getNumArgOperands() && "Out of bounds!");
return getOperand(i);
}
void setArgOperand(unsigned i, Value *v) {
assert(i < getNumArgOperands() && "Out of bounds!");
setOperand(i, v);
}

/// arg_operands - iteration adapter for range-for loops.
iterator_range<op_iterator> arg_operands() {
Expand All @@ -1489,8 +1495,14 @@ class CallInst : public Instruction {
}

/// \brief Wrappers for getting the \c Use of a call argument.
const Use &getArgOperandUse(unsigned i) const { return getOperandUse(i); }
Use &getArgOperandUse(unsigned i) { return getOperandUse(i); }
const Use &getArgOperandUse(unsigned i) const {
assert(i < getNumArgOperands() && "Out of bounds!");
return getOperandUse(i);
}
Use &getArgOperandUse(unsigned i) {
assert(i < getNumArgOperands() && "Out of bounds!");
return getOperandUse(i);
}

/// getCallingConv/setCallingConv - Get or set the calling convention of this
/// function call.
Expand Down Expand Up @@ -3268,8 +3280,14 @@ class InvokeInst : public TerminatorInst {

/// getArgOperand/setArgOperand - Return/set the i-th invoke argument.
///
Value *getArgOperand(unsigned i) const { return getOperand(i); }
void setArgOperand(unsigned i, Value *v) { setOperand(i, v); }
Value *getArgOperand(unsigned i) const {
assert(i < getNumArgOperands() && "Out of bounds!");
return getOperand(i);
}
void setArgOperand(unsigned i, Value *v) {
assert(i < getNumArgOperands() && "Out of bounds!");
setOperand(i, v);
}

/// arg_operands - iteration adapter for range-for loops.
iterator_range<op_iterator> arg_operands() {
Expand All @@ -3282,8 +3300,14 @@ class InvokeInst : public TerminatorInst {
}

/// \brief Wrappers for getting the \c Use of a invoke argument.
const Use &getArgOperandUse(unsigned i) const { return getOperandUse(i); }
Use &getArgOperandUse(unsigned i) { return getOperandUse(i); }
const Use &getArgOperandUse(unsigned i) const {
assert(i < getNumArgOperands() && "Out of bounds!");
return getOperandUse(i);
}
Use &getArgOperandUse(unsigned i) {
assert(i < getNumArgOperands() && "Out of bounds!");
return getOperandUse(i);
}

/// getCallingConv/setCallingConv - Get or set the calling convention of this
/// function call.
Expand Down

0 comments on commit 18188f1

Please sign in to comment.