Add CallSite::getArgumentNo() to be able to translate an operand number into a
authorMatthijs Kooijman <matthijs@stdin.nl>
Tue, 8 Jul 2008 08:51:47 +0000 (08:51 +0000)
committerMatthijs Kooijman <matthijs@stdin.nl>
Tue, 8 Jul 2008 08:51:47 +0000 (08:51 +0000)
argument number.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53225 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/CallSite.h

index dfb3b5eae1adc6eb2c45f9e2b4ee08c45f5ae289..ce95cc5aaac0ed91e5a45394a6851161389caf83 100644 (file)
@@ -133,6 +133,15 @@ public:
     I->setOperand(getArgumentOffset() + ArgNo, newVal);
   }
 
+  /// Given an operand number, returns the argument that corresponds to it.
+  /// OperandNo must be a valid operand number that actually corresponds to an
+  /// argument.
+  unsigned getArgumentNo(unsigned OperandNo) const {
+    assert(OperandNo >= getArgumentOffset() && "Operand number passed was not "
+                                               "a valid argument");
+    return OperandNo - getArgumentOffset();
+  }
+
   /// hasArgument - Returns true if this CallSite passes the given Value* as an
   /// argument to the called function.
   bool hasArgument(const Value *Arg) const;