summaryrefslogtreecommitdiff
path: root/include/llvm/IR
diff options
context:
space:
mode:
authorEli Bendersky <eliben@google.com>2014-03-26 20:41:15 +0000
committerEli Bendersky <eliben@google.com>2014-03-26 20:41:15 +0000
commit1003e8fbfa2f436e88ef801cf4c3d33fc978e565 (patch)
tree8a5f80dab085cbee80917d8c9501063f24697e3a /include/llvm/IR
parent6da017873777cbe06bf2d5606e408c7cda85062e (diff)
downloadllvm-1003e8fbfa2f436e88ef801cf4c3d33fc978e565.tar.gz
llvm-1003e8fbfa2f436e88ef801cf4c3d33fc978e565.tar.bz2
llvm-1003e8fbfa2f436e88ef801cf4c3d33fc978e565.tar.xz
Fix problem with r204836
In CallInst, op_end() points at the callee, which we don't want to iterate over when just iterating over arguments. Now take this into account when returning a iterator_range from arg_operands. Similar reasoning for InvokeInst. Also adds a unit test to verify this actually works as expected. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204851 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/IR')
-rw-r--r--include/llvm/IR/Instructions.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h
index e1dd345681..06d7287ea1 100644
--- a/include/llvm/IR/Instructions.h
+++ b/include/llvm/IR/Instructions.h
@@ -1297,12 +1297,14 @@ public:
/// arg_operands - iteration adapter for range-for loops.
iterator_range<op_iterator> arg_operands() {
- return iterator_range<op_iterator>(op_begin(), op_end());
+ // The last operand in the op list is the callee - it's not one of the args
+ // so we don't want to iterate over it.
+ return iterator_range<op_iterator>(op_begin(), op_end() - 1);
}
/// arg_operands - iteration adapter for range-for loops.
iterator_range<const_op_iterator> arg_operands() const {
- return iterator_range<const_op_iterator>(op_begin(), op_end());
+ return iterator_range<const_op_iterator>(op_begin(), op_end() - 1);
}
/// \brief Wrappers for getting the \c Use of a call argument.
@@ -2954,12 +2956,12 @@ public:
/// arg_operands - iteration adapter for range-for loops.
iterator_range<op_iterator> arg_operands() {
- return iterator_range<op_iterator>(op_begin(), op_end());
+ return iterator_range<op_iterator>(op_begin(), op_end() - 3);
}
/// arg_operands - iteration adapter for range-for loops.
iterator_range<const_op_iterator> arg_operands() const {
- return iterator_range<const_op_iterator>(op_begin(), op_end());
+ return iterator_range<const_op_iterator>(op_begin(), op_end() - 3);
}
/// \brief Wrappers for getting the \c Use of a invoke argument.