1 //===-- llvm/Support/ValueHolder.h - Wrapper for Value's --------*- C++ -*-===//
3 // This class defines a simple subclass of User, which keeps a pointer to a
4 // Value, which automatically updates when Value::replaceAllUsesWith is called.
5 // This is useful when you have pointers to Value's in your pass, but the
6 // pointers get invalidated when some other portion of the algorithm is
7 // replacing Values with other Values.
9 //===----------------------------------------------------------------------===//
11 #ifndef LLVM_SUPPORT_VALUEHOLDER_H
12 #define LLVM_SUPPORT_VALUEHOLDER_H
14 #include "llvm/User.h"
16 struct ValueHolder : public User {
17 ValueHolder(Value *V = 0);
20 const Value *get() const { return getOperand(0); }
21 operator const Value*() const { return getOperand(0); }
22 Value *get() { return getOperand(0); }
23 operator Value*() { return getOperand(0); }
26 const ValueHolder &operator=(Value *V) {
31 virtual void print(std::ostream& OS) const {