diff --git a/include/llvm/AbstractTypeUser.h b/include/llvm/AbstractTypeUser.h index b6cceb4011a..81f5c5c7680 100644 --- a/include/llvm/AbstractTypeUser.h +++ b/include/llvm/AbstractTypeUser.h @@ -146,6 +146,7 @@ class PATypeHolder { mutable const Type *Ty; void destroy(); public: + PATypeHolder() : Ty(0) {} PATypeHolder(const Type *ty) : Ty(ty) { addRef(); } @@ -153,7 +154,7 @@ public: addRef(); } - ~PATypeHolder() { if (Ty) dropRef(); } + ~PATypeHolder() { dropRef(); } operator Type *() const { return get(); } Type *get() const; diff --git a/include/llvm/Type.h b/include/llvm/Type.h index 52229acb323..617ef69de46 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -504,19 +504,19 @@ inline void PATypeHandle::removeUser() { /// reference to the type. /// inline Type* PATypeHolder::get() const { + if (Ty == 0) return 0; const Type *NewTy = Ty->getForwardedType(); if (!NewTy) return const_cast(Ty); return *const_cast(this) = NewTy; } inline void PATypeHolder::addRef() { - assert(Ty && "Type Holder has a null type!"); - if (Ty->isAbstract()) + if (Ty && Ty->isAbstract()) Ty->addRef(); } inline void PATypeHolder::dropRef() { - if (Ty->isAbstract()) + if (Ty && Ty->isAbstract()) Ty->dropRef(); }