summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-06-29 19:20:38 +0000
committerChris Lattner <sabre@nondot.org>2010-06-29 19:20:38 +0000
commit190a7f4a18dc909c8ec2dbb908a55196e7098d01 (patch)
tree5f5f6493d520eaac77166e450baf700ab24cd812 /include
parentd1303d2a66241c70e0e35dac371636c883235df8 (diff)
downloadllvm-190a7f4a18dc909c8ec2dbb908a55196e7098d01.tar.gz
llvm-190a7f4a18dc909c8ec2dbb908a55196e7098d01.tar.bz2
llvm-190a7f4a18dc909c8ec2dbb908a55196e7098d01.tar.xz
give PATypeHolder an explicit copy ctor which initializes the type pointer,
and make PATypeHolder work with null pointers. The implicitly generated one didn't work on numerous levels, but was still accepted, allowing all sorts of bugs with default constructed pa type holders. Previously, they "sort of" worked if they were default constructed and then destructed. Now they really work, and you can even default construct one, then assign to it, amazing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107195 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/AbstractTypeUser.h3
-rw-r--r--include/llvm/Type.h6
2 files changed, 5 insertions, 4 deletions
diff --git a/include/llvm/AbstractTypeUser.h b/include/llvm/AbstractTypeUser.h
index b6cceb4011..81f5c5c768 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 52229acb32..617ef69de4 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<Type*>(Ty);
return *const_cast<PATypeHolder*>(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();
}