From 893f025262574d01de5585d64860673e13d77ee5 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 18 Jun 2003 19:22:36 +0000 Subject: Detemplatize the PATypeHandle class, which was only really instantiated on 'Type'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6774 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/AbstractTypeUser.h | 33 ++++++++++++++++----------------- include/llvm/DerivedTypes.h | 17 ++++++++--------- include/llvm/Value.h | 2 +- 3 files changed, 25 insertions(+), 27 deletions(-) (limited to 'include') diff --git a/include/llvm/AbstractTypeUser.h b/include/llvm/AbstractTypeUser.h index 272560f..751c5ac 100644 --- a/include/llvm/AbstractTypeUser.h +++ b/include/llvm/AbstractTypeUser.h @@ -58,9 +58,8 @@ public: // example. This class is a simple class used to keep the use list of abstract // types up-to-date. // -template class PATypeHandle { - const TypeSubClass *Ty; + const Type *Ty; AbstractTypeUser * const User; // These functions are defined at the bottom of Type.h. See the comment there @@ -69,7 +68,7 @@ class PATypeHandle { inline void removeUser(); public: // ctor - Add use to type if abstract. Note that Ty must not be null - inline PATypeHandle(const TypeSubClass *ty, AbstractTypeUser *user) + inline PATypeHandle(const Type *ty, AbstractTypeUser *user) : Ty(ty), User(user) { addUser(); } @@ -83,11 +82,11 @@ public: inline ~PATypeHandle() { removeUser(); } // Automatic casting operator so that the handle may be used naturally - inline operator const TypeSubClass *() const { return Ty; } - inline const TypeSubClass *get() const { return Ty; } + inline operator const Type *() const { return Ty; } + inline const Type *get() const { return Ty; } // operator= - Allow assignment to handle - inline const TypeSubClass *operator=(const TypeSubClass *ty) { + inline const Type *operator=(const Type *ty) { if (Ty != ty) { // Ensure we don't accidentally drop last ref to Ty removeUser(); Ty = ty; @@ -97,16 +96,16 @@ public: } // operator= - Allow assignment to handle - inline const TypeSubClass *operator=(const PATypeHandle &T) { + inline const Type *operator=(const PATypeHandle &T) { return operator=(T.Ty); } - inline bool operator==(const TypeSubClass *ty) { + inline bool operator==(const Type *ty) { return Ty == ty; } // operator-> - Allow user to dereference handle naturally... - inline const TypeSubClass *operator->() const { return Ty; } + inline const Type *operator->() const { return Ty; } // removeUserFromConcrete - This function should be called when the User is // notified that our type is refined... and the type is being refined to @@ -122,10 +121,10 @@ public: // as both a handle (as above) and an AbstractTypeUser. It uses the callback to // keep its pointer member updated to the current version of the type. // -struct PATypeHolder : public AbstractTypeUser, public PATypeHandle { - inline PATypeHolder(const Type *ty) : PATypeHandle(ty, this) {} +struct PATypeHolder : public AbstractTypeUser, public PATypeHandle { + inline PATypeHolder(const Type *ty) : PATypeHandle(ty, this) {} inline PATypeHolder(const PATypeHolder &T) - : AbstractTypeUser(T), PATypeHandle(T, this) {} + : AbstractTypeUser(T), PATypeHandle(T, this) {} // refineAbstractType - All we do is update our PATypeHandle member to point // to the new type. @@ -138,20 +137,20 @@ struct PATypeHolder : public AbstractTypeUser, public PATypeHandle { removeUserFromConcrete(); if ((const Type*)OldTy != NewTy) - PATypeHandle::operator=(NewTy); + PATypeHandle::operator=(NewTy); } // operator= - Allow assignment to handle inline const Type *operator=(const Type *ty) { - return PATypeHandle::operator=(ty); + return PATypeHandle::operator=(ty); } // operator= - Allow assignment to handle - inline const Type *operator=(const PATypeHandle &T) { - return PATypeHandle::operator=(T); + inline const Type *operator=(const PATypeHandle &T) { + return PATypeHandle::operator=(T); } inline const Type *operator=(const PATypeHolder &H) { - return PATypeHandle::operator=(H); + return PATypeHandle::operator=(H); } void dump() const; diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h index ed1856f..bd44bd2 100644 --- a/include/llvm/DerivedTypes.h +++ b/include/llvm/DerivedTypes.h @@ -86,9 +86,9 @@ public: class FunctionType : public DerivedType { public: - typedef std::vector > ParamTypes; + typedef std::vector ParamTypes; private: - PATypeHandle ResultType; + PATypeHandle ResultType; ParamTypes ParamTys; bool isVarArgs; @@ -181,7 +181,7 @@ public: class StructType : public CompositeType { public: - typedef std::vector > ElementTypes; + typedef std::vector ElementTypes; private: ElementTypes ETypes; // Element types of struct @@ -245,10 +245,10 @@ class SequentialType : public CompositeType { SequentialType(const SequentialType &); // Do not implement! const SequentialType &operator=(const SequentialType &); // Do not implement! protected: - PATypeHandle ElementType; + PATypeHandle ElementType; SequentialType(PrimitiveID TID, const Type *ElType) - : CompositeType(TID), ElementType(PATypeHandle(ElType, this)) { + : CompositeType(TID), ElementType(PATypeHandle(ElType, this)) { } public: @@ -390,18 +390,17 @@ public: // contains an AbstractTypeUser instance, so there is no good way to factor out // the code. Hence this bit of uglyness. // -template void PATypeHandle::addUser() { +inline void PATypeHandle::addUser() { assert(Ty && "Type Handle has a null type!"); if (Ty->isAbstract()) cast(Ty)->addAbstractTypeUser(User); } -template void PATypeHandle::removeUser() { +inline void PATypeHandle::removeUser() { if (Ty->isAbstract()) cast(Ty)->removeAbstractTypeUser(User); } -template -void PATypeHandle::removeUserFromConcrete() { +inline void PATypeHandle::removeUserFromConcrete() { if (!Ty->isAbstract()) cast(Ty)->removeAbstractTypeUser(User); } diff --git a/include/llvm/Value.h b/include/llvm/Value.h index f6bd144..aef3434 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -50,7 +50,7 @@ public: private: std::vector Uses; std::string Name; - PATypeHandle Ty; + PATypeHandle Ty; ValueTy VTy; void operator=(const Value &); // Do not implement -- cgit v1.1