From 1003e8fbfa2f436e88ef801cf4c3d33fc978e565 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Wed, 26 Mar 2014 20:41:15 +0000 Subject: 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 --- include/llvm/IR/Instructions.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'include/llvm/IR') 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 arg_operands() { - return iterator_range(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_begin(), op_end() - 1); } /// arg_operands - iteration adapter for range-for loops. iterator_range arg_operands() const { - return iterator_range(op_begin(), op_end()); + return iterator_range(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 arg_operands() { - return iterator_range(op_begin(), op_end()); + return iterator_range(op_begin(), op_end() - 3); } /// arg_operands - iteration adapter for range-for loops. iterator_range arg_operands() const { - return iterator_range(op_begin(), op_end()); + return iterator_range(op_begin(), op_end() - 3); } /// \brief Wrappers for getting the \c Use of a invoke argument. -- cgit v1.2.3