[cleanup] Add a getOperandNo method to the Use class and implement it
[oota-llvm.git] / lib / IR / Use.cpp
index 5f01e238e04f711e74ac6db6cf9a275dbed5ef21..60a0c5668890fc686c57a320a5ae12588f6b95dd 100644 (file)
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/IR/Use.h"
+#include "llvm/IR/User.h"
 #include "llvm/IR/Value.h"
 #include <new>
 
@@ -44,6 +45,10 @@ User *Use::getUser() const {
                        : reinterpret_cast<User *>(const_cast<Use *>(End));
 }
 
+unsigned Use::getOperandNo() const {
+  return this - getUser()->op_begin();
+}
+
 // Sets up the waymarking algoritm's tags for a series of Uses. See the
 // algorithm details here:
 //