mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Rearrange code to eliminate warnings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11512 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
31bbb5190b
commit
3e3bcbd222
@ -29,20 +29,13 @@ class StructValType;
|
|||||||
class PointerValType;
|
class PointerValType;
|
||||||
|
|
||||||
class DerivedType : public Type, public AbstractTypeUser {
|
class DerivedType : public Type, public AbstractTypeUser {
|
||||||
/// RefCount - This counts the number of PATypeHolders that are pointing to
|
|
||||||
/// this type. When this number falls to zero, if the type is abstract and
|
|
||||||
/// has no AbstractTypeUsers, the type is deleted.
|
|
||||||
///
|
|
||||||
mutable unsigned RefCount;
|
|
||||||
|
|
||||||
// AbstractTypeUsers - Implement a list of the users that need to be notified
|
// AbstractTypeUsers - Implement a list of the users that need to be notified
|
||||||
// if I am a type, and I get resolved into a more concrete type.
|
// if I am a type, and I get resolved into a more concrete type.
|
||||||
//
|
//
|
||||||
///// FIXME: kill mutable nonsense when Types are not const
|
|
||||||
mutable std::vector<AbstractTypeUser *> AbstractTypeUsers;
|
mutable std::vector<AbstractTypeUser *> AbstractTypeUsers;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DerivedType(PrimitiveID id) : Type("", id), RefCount(0) {}
|
DerivedType(PrimitiveID id) : Type("", id) {}
|
||||||
~DerivedType() {
|
~DerivedType() {
|
||||||
assert(AbstractTypeUsers.empty());
|
assert(AbstractTypeUsers.empty());
|
||||||
}
|
}
|
||||||
@ -59,6 +52,12 @@ protected:
|
|||||||
///
|
///
|
||||||
void dropAllTypeUses();
|
void dropAllTypeUses();
|
||||||
|
|
||||||
|
void RefCountIsZero() const {
|
||||||
|
if (AbstractTypeUsers.empty())
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
@ -89,22 +88,6 @@ public:
|
|||||||
///
|
///
|
||||||
void refineAbstractTypeTo(const Type *NewType);
|
void refineAbstractTypeTo(const Type *NewType);
|
||||||
|
|
||||||
void addRef() const {
|
|
||||||
assert(isAbstract() && "Cannot add a reference to a non-abstract type!");
|
|
||||||
++RefCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dropRef() const {
|
|
||||||
assert(isAbstract() && "Cannot drop a refernce to a non-abstract type!");
|
|
||||||
assert(RefCount && "No objects are currently referencing this object!");
|
|
||||||
|
|
||||||
// If this is the last PATypeHolder using this object, and there are no
|
|
||||||
// PATypeHandles using it, the type is dead, delete it now.
|
|
||||||
if (--RefCount == 0 && AbstractTypeUsers.empty())
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void dump() const { Value::dump(); }
|
void dump() const { Value::dump(); }
|
||||||
|
|
||||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
@ -406,51 +389,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Define some inline methods for the AbstractTypeUser.h:PATypeHandle class.
|
|
||||||
// These are defined here because they MUST be inlined, yet are dependent on
|
|
||||||
// the definition of the Type class. Of course Type derives from Value, which
|
|
||||||
// contains an AbstractTypeUser instance, so there is no good way to factor out
|
|
||||||
// the code. Hence this bit of uglyness.
|
|
||||||
//
|
|
||||||
inline void PATypeHandle::addUser() {
|
|
||||||
assert(Ty && "Type Handle has a null type!");
|
|
||||||
if (Ty->isAbstract())
|
|
||||||
cast<DerivedType>(Ty)->addAbstractTypeUser(User);
|
|
||||||
}
|
|
||||||
inline void PATypeHandle::removeUser() {
|
|
||||||
if (Ty->isAbstract())
|
|
||||||
cast<DerivedType>(Ty)->removeAbstractTypeUser(User);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void PATypeHandle::removeUserFromConcrete() {
|
|
||||||
if (!Ty->isAbstract())
|
|
||||||
cast<DerivedType>(Ty)->removeAbstractTypeUser(User);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define inline methods for PATypeHolder...
|
|
||||||
|
|
||||||
inline void PATypeHolder::addRef() {
|
|
||||||
if (Ty->isAbstract())
|
|
||||||
cast<DerivedType>(Ty)->addRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void PATypeHolder::dropRef() {
|
|
||||||
if (Ty->isAbstract())
|
|
||||||
cast<DerivedType>(Ty)->dropRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// get - This implements the forwarding part of the union-find algorithm for
|
|
||||||
/// abstract types. Before every access to the Type*, we check to see if the
|
|
||||||
/// type we are pointing to is forwarding to a new type. If so, we drop our
|
|
||||||
/// reference to the type.
|
|
||||||
///
|
|
||||||
inline const Type* PATypeHolder::get() const {
|
|
||||||
const Type *NewTy = Ty->getForwardedType();
|
|
||||||
if (!NewTy) return Ty;
|
|
||||||
return *const_cast<PATypeHolder*>(this) = NewTy;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -83,10 +83,17 @@ private:
|
|||||||
unsigned UID; // The unique ID number for this class
|
unsigned UID; // The unique ID number for this class
|
||||||
bool Abstract; // True if type contains an OpaqueType
|
bool Abstract; // True if type contains an OpaqueType
|
||||||
|
|
||||||
|
/// RefCount - This counts the number of PATypeHolders that are pointing to
|
||||||
|
/// this type. When this number falls to zero, if the type is abstract and
|
||||||
|
/// has no AbstractTypeUsers, the type is deleted. This is only sensical for
|
||||||
|
/// derived types.
|
||||||
|
///
|
||||||
|
mutable unsigned RefCount;
|
||||||
|
|
||||||
const Type *getForwardedTypeInternal() const;
|
const Type *getForwardedTypeInternal() const;
|
||||||
protected:
|
protected:
|
||||||
/// ctor is protected, so only subclasses can create Type objects...
|
/// ctor is protected, so only subclasses can create Type objects...
|
||||||
Type(const std::string &Name, PrimitiveID id);
|
Type(PrimitiveID id);
|
||||||
virtual ~Type() {}
|
virtual ~Type() {}
|
||||||
|
|
||||||
/// setName - Associate the name with this type in the symbol table, but don't
|
/// setName - Associate the name with this type in the symbol table, but don't
|
||||||
@ -259,8 +266,89 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "llvm/Type.def"
|
#include "llvm/Type.def"
|
||||||
|
|
||||||
|
// Virtual methods used by callbacks below. These should only be implemented
|
||||||
|
// in the DerivedType class.
|
||||||
|
virtual void addAbstractTypeUser(AbstractTypeUser *U) const {
|
||||||
|
abort(); // Only on derived types!
|
||||||
|
}
|
||||||
|
virtual void removeAbstractTypeUser(AbstractTypeUser *U) const {
|
||||||
|
abort(); // Only on derived types!
|
||||||
|
}
|
||||||
|
|
||||||
|
void addRef() const {
|
||||||
|
assert(isAbstract() && "Cannot add a reference to a non-abstract type!");
|
||||||
|
++RefCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dropRef() const {
|
||||||
|
assert(isAbstract() && "Cannot drop a refernce to a non-abstract type!");
|
||||||
|
assert(RefCount && "No objects are currently referencing this object!");
|
||||||
|
|
||||||
|
// If this is the last PATypeHolder using this object, and there are no
|
||||||
|
// PATypeHandles using it, the type is dead, delete it now.
|
||||||
|
if (--RefCount == 0)
|
||||||
|
RefCountIsZero();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
virtual void RefCountIsZero() const {
|
||||||
|
abort(); // only on derived types!
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// Define some inline methods for the AbstractTypeUser.h:PATypeHandle class.
|
||||||
|
// These are defined here because they MUST be inlined, yet are dependent on
|
||||||
|
// the definition of the Type class. Of course Type derives from Value, which
|
||||||
|
// contains an AbstractTypeUser instance, so there is no good way to factor out
|
||||||
|
// the code. Hence this bit of uglyness.
|
||||||
|
//
|
||||||
|
// In the long term, Type should not derive from Value, allowing
|
||||||
|
// AbstractTypeUser.h to #include Type.h, allowing us to eliminate this
|
||||||
|
// nastyness entirely.
|
||||||
|
//
|
||||||
|
inline void PATypeHandle::addUser() {
|
||||||
|
assert(Ty && "Type Handle has a null type!");
|
||||||
|
if (Ty->isAbstract())
|
||||||
|
Ty->addAbstractTypeUser(User);
|
||||||
|
}
|
||||||
|
inline void PATypeHandle::removeUser() {
|
||||||
|
if (Ty->isAbstract())
|
||||||
|
Ty->removeAbstractTypeUser(User);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void PATypeHandle::removeUserFromConcrete() {
|
||||||
|
if (!Ty->isAbstract())
|
||||||
|
Ty->removeAbstractTypeUser(User);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define inline methods for PATypeHolder...
|
||||||
|
|
||||||
|
inline void PATypeHolder::addRef() {
|
||||||
|
if (Ty->isAbstract())
|
||||||
|
Ty->addRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void PATypeHolder::dropRef() {
|
||||||
|
if (Ty->isAbstract())
|
||||||
|
Ty->dropRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// get - This implements the forwarding part of the union-find algorithm for
|
||||||
|
/// abstract types. Before every access to the Type*, we check to see if the
|
||||||
|
/// type we are pointing to is forwarding to a new type. If so, we drop our
|
||||||
|
/// reference to the type.
|
||||||
|
///
|
||||||
|
inline const Type* PATypeHolder::get() const {
|
||||||
|
const Type *NewTy = Ty->getForwardedType();
|
||||||
|
if (!NewTy) return Ty;
|
||||||
|
return *const_cast<PATypeHolder*>(this) = NewTy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
// Provide specializations of GraphTraits to be able to treat a type as a
|
// Provide specializations of GraphTraits to be able to treat a type as a
|
||||||
// graph of sub types...
|
// graph of sub types...
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user