Another attempt at fixing PR2975.
[oota-llvm.git] / include / llvm / AbstractTypeUser.h
index 80656d89b726a20f3d5b954dc50eaa4dd3a35fe1..c1216baabf8fac950ba59fcd29efd55897f0b6aa 100644 (file)
@@ -137,6 +137,7 @@ public:
 ///
 class PATypeHolder {
   mutable const Type *Ty;
+  void destroy();
 public:
   PATypeHolder(const Type *ty) : Ty(ty) {
     addRef();
@@ -145,7 +146,7 @@ public:
     addRef();
   }
 
-  ~PATypeHolder() { dropRef(); }
+  ~PATypeHolder() { if (Ty) dropRef(); }
 
   operator Type *() const { return get(); }
   Type *get() const;
@@ -173,6 +174,7 @@ public:
 private:
   void addRef();
   void dropRef();
+  friend class TypeMapBase;
 };
 
 // simplify_type - Allow clients to treat uses just like values when using