Update/correct comment.
[oota-llvm.git] / include / llvm / IR / ValueHandle.h
index e3c9d3e1e592d569f0103edf77fca87e28069f5c..3c2805913ef597dd5ce76279a53dd33e5c306f81 100644 (file)
@@ -51,7 +51,15 @@ protected:
     Tracking,
     Weak
   };
-  ValueHandleBase(const ValueHandleBase&) = default;
+
+  ValueHandleBase(const ValueHandleBase &RHS)
+      : ValueHandleBase(RHS.PrevPair.getInt(), RHS) {}
+
+  ValueHandleBase(HandleBaseKind Kind, const ValueHandleBase &RHS)
+      : PrevPair(nullptr, Kind), Next(nullptr), V(RHS.V) {
+    if (isValid(V))
+      AddToExistingUseList(RHS.getPrevPtr());
+  }
 
 private:
   PointerIntPair<ValueHandleBase**, 2, HandleBaseKind> PrevPair;
@@ -67,11 +75,7 @@ public:
     if (isValid(V))
       AddToUseList();
   }
-  ValueHandleBase(HandleBaseKind Kind, const ValueHandleBase &RHS)
-    : PrevPair(nullptr, Kind), Next(nullptr), V(RHS.V) {
-    if (isValid(V))
-      AddToExistingUseList(RHS.getPrevPtr());
-  }
+
   ~ValueHandleBase() {
     if (isValid(V))
       RemoveFromUseList();
@@ -144,10 +148,8 @@ public:
   WeakVH(Value *P) : ValueHandleBase(Weak, P) {}
   WeakVH(const WeakVH &RHS)
     : ValueHandleBase(Weak, RHS) {}
-  // Questionable - these are stored in a vector in AssumptionCache (perhaps
-  // other copies too) and need to be copied. When copied, how would they
-  // properly insert into the use list?
-  WeakVH&operator=(const WeakVH &RHS) = default;
+
+  WeakVH &operator=(const WeakVH &RHS) = default;
 
   Value *operator=(Value *RHS) {
     return ValueHandleBase::operator=(RHS);
@@ -163,11 +165,13 @@ public:
 
 // Specialize simplify_type to allow WeakVH to participate in
 // dyn_cast, isa, etc.
-template<> struct simplify_type<WeakVH> {
-  typedef Value* SimpleType;
-  static SimpleType getSimplifiedValue(WeakVH &WVH) {
-    return WVH;
-  }
+template <> struct simplify_type<WeakVH> {
+  typedef Value *SimpleType;
+  static SimpleType getSimplifiedValue(WeakVH &WVH) { return WVH; }
+};
+template <> struct simplify_type<const WeakVH> {
+  typedef Value *SimpleType;
+  static SimpleType getSimplifiedValue(const WeakVH &WVH) { return WVH; }
 };
 
 /// \brief Value handle that asserts if the Value is deleted.
@@ -316,7 +320,6 @@ class TrackingVH : public ValueHandleBase {
 public:
   TrackingVH() : ValueHandleBase(Tracking) {}
   TrackingVH(ValueTy *P) : ValueHandleBase(Tracking, GetAsValue(P)) {}
-  TrackingVH(const TrackingVH &RHS) : ValueHandleBase(Tracking, RHS) {}
 
   operator ValueTy*() const {
     return getValPtr();
@@ -326,10 +329,6 @@ public:
     setValPtr(RHS);
     return getValPtr();
   }
-  ValueTy *operator=(const TrackingVH<ValueTy> &RHS) {
-    setValPtr(RHS.getValPtr());
-    return getValPtr();
-  }
 
   ValueTy *operator->() const { return getValPtr(); }
   ValueTy &operator*() const { return *getValPtr(); }
@@ -341,15 +340,12 @@ public:
 /// when the underlying Value has RAUW called on it or is destroyed.  This
 /// class can be used as the key of a map, as long as the user takes it out of
 /// the map before calling setValPtr() (since the map has to rearrange itself
-/// when the pointer changes).  Unlike ValueHandleBase, this class has a vtable
-/// and a virtual destructor.
+/// when the pointer changes).  Unlike ValueHandleBase, this class has a vtable.
 class CallbackVH : public ValueHandleBase {
   virtual void anchor();
 protected:
-  CallbackVH(const CallbackVH &RHS)
-    : ValueHandleBase(Callback, RHS) {}
-
-  virtual ~CallbackVH() = default;
+  ~CallbackVH() = default;
+  CallbackVH(const CallbackVH &) = default;
   CallbackVH &operator=(const CallbackVH &) = default;
 
   void setValPtr(Value *P) {