Remove some cruft, add some methods to allow implementation of bugfix for

Bug: Linker/2003-04-26-NullPtrLinkProblem.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6313 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-05-23 20:02:05 +00:00
parent f96eb64666
commit 6cc89aad25

View File

@ -15,6 +15,8 @@ class ArrayType;
class StructType; class StructType;
class PointerType; class PointerType;
template<class ConstantClass, class TypeClass, class ValType>
struct ConstantCreator;
//===--------------------------------------------------------------------------- //===---------------------------------------------------------------------------
/// ConstantIntegral - Shared superclass of boolean and integer constants. /// ConstantIntegral - Shared superclass of boolean and integer constants.
@ -67,7 +69,6 @@ public:
class ConstantBool : public ConstantIntegral { class ConstantBool : public ConstantIntegral {
bool Val; bool Val;
ConstantBool(bool V); ConstantBool(bool V);
~ConstantBool() {}
public: public:
static ConstantBool *True, *False; // The True & False values static ConstantBool *True, *False; // The True & False values
@ -113,7 +114,6 @@ protected:
} Val; } Val;
ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
ConstantInt(const Type *Ty, uint64_t V); ConstantInt(const Type *Ty, uint64_t V);
~ConstantInt() {}
public: public:
/// equalsInt - Provide a helper method that can be used to determine if the /// equalsInt - Provide a helper method that can be used to determine if the
/// constant contained within is equal to a constant. This only works for /// constant contained within is equal to a constant. This only works for
@ -151,9 +151,10 @@ public:
/// ///
class ConstantSInt : public ConstantInt { class ConstantSInt : public ConstantInt {
ConstantSInt(const ConstantSInt &); // DO NOT IMPLEMENT ConstantSInt(const ConstantSInt &); // DO NOT IMPLEMENT
friend struct ConstantCreator<ConstantSInt, Type, int64_t>;
protected: protected:
ConstantSInt(const Type *Ty, int64_t V); ConstantSInt(const Type *Ty, int64_t V);
~ConstantSInt() {}
public: public:
/// get() - Static factory methods - Return objects of the specified value /// get() - Static factory methods - Return objects of the specified value
static ConstantSInt *get(const Type *Ty, int64_t V); static ConstantSInt *get(const Type *Ty, int64_t V);
@ -199,9 +200,9 @@ public:
/// ///
class ConstantUInt : public ConstantInt { class ConstantUInt : public ConstantInt {
ConstantUInt(const ConstantUInt &); // DO NOT IMPLEMENT ConstantUInt(const ConstantUInt &); // DO NOT IMPLEMENT
friend struct ConstantCreator<ConstantUInt, Type, uint64_t>;
protected: protected:
ConstantUInt(const Type *Ty, uint64_t V); ConstantUInt(const Type *Ty, uint64_t V);
~ConstantUInt() {}
public: public:
/// get() - Static factory methods - Return objects of the specified value /// get() - Static factory methods - Return objects of the specified value
static ConstantUInt *get(const Type *Ty, uint64_t V); static ConstantUInt *get(const Type *Ty, uint64_t V);
@ -233,10 +234,10 @@ public:
/// ///
class ConstantFP : public Constant { class ConstantFP : public Constant {
double Val; double Val;
friend struct ConstantCreator<ConstantFP, Type, double>;
ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT
protected: protected:
ConstantFP(const Type *Ty, double V); ConstantFP(const Type *Ty, double V);
~ConstantFP() {}
public: public:
/// get() - Static factory methods - Return objects of the specified value /// get() - Static factory methods - Return objects of the specified value
static ConstantFP *get(const Type *Ty, double V); static ConstantFP *get(const Type *Ty, double V);
@ -262,11 +263,12 @@ public:
/// ConstantArray - Constant Array Declarations /// ConstantArray - Constant Array Declarations
/// ///
class ConstantArray : public Constant { class ConstantArray : public Constant {
friend struct ConstantCreator<ConstantArray, ArrayType,
std::vector<Constant*> >;
ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
protected: protected:
ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val); ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
~ConstantArray() {} void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
public: public:
/// get() - Static factory methods - Return objects of the specified value /// get() - Static factory methods - Return objects of the specified value
static ConstantArray *get(const ArrayType *T, const std::vector<Constant*> &); static ConstantArray *get(const ArrayType *T, const std::vector<Constant*> &);
@ -316,11 +318,12 @@ public:
// ConstantStruct - Constant Struct Declarations // ConstantStruct - Constant Struct Declarations
// //
class ConstantStruct : public Constant { class ConstantStruct : public Constant {
friend struct ConstantCreator<ConstantStruct, StructType,
std::vector<Constant*> >;
ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
protected: protected:
ConstantStruct(const StructType *T, const std::vector<Constant*> &Val); ConstantStruct(const StructType *T, const std::vector<Constant*> &Val);
~ConstantStruct() {} void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
public: public:
/// get() - Static factory methods - Return objects of the specified value /// get() - Static factory methods - Return objects of the specified value
static ConstantStruct *get(const StructType *T, static ConstantStruct *get(const StructType *T,
@ -367,8 +370,7 @@ public:
class ConstantPointer : public Constant { class ConstantPointer : public Constant {
ConstantPointer(const ConstantPointer &); // DO NOT IMPLEMENT ConstantPointer(const ConstantPointer &); // DO NOT IMPLEMENT
protected: protected:
inline ConstantPointer(const PointerType *T) : Constant((const Type*)T){} inline ConstantPointer(const PointerType *T) : Constant((const Type*)T) {}
~ConstantPointer() {}
public: public:
inline const PointerType *getType() const { inline const PointerType *getType() const {
return (PointerType*)Value::getType(); return (PointerType*)Value::getType();
@ -389,10 +391,12 @@ public:
/// ConstantPointerNull - a constant pointer value that points to null /// ConstantPointerNull - a constant pointer value that points to null
/// ///
class ConstantPointerNull : public ConstantPointer { class ConstantPointerNull : public ConstantPointer {
friend struct ConstantCreator<ConstantPointerNull, PointerType, char>;
ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT
protected: protected:
inline ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {} ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {}
inline ~ConstantPointerNull() {} void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
public: public:
/// get() - Static factory methods - Return objects of the specified value /// get() - Static factory methods - Return objects of the specified value
@ -427,7 +431,6 @@ class ConstantPointerRef : public ConstantPointer {
protected: protected:
ConstantPointerRef(GlobalValue *GV); ConstantPointerRef(GlobalValue *GV);
~ConstantPointerRef() {}
public: public:
/// get() - Static factory methods - Return objects of the specified value /// get() - Static factory methods - Return objects of the specified value
static ConstantPointerRef *get(GlobalValue *GV); static ConstantPointerRef *get(GlobalValue *GV);
@ -457,7 +460,6 @@ public:
} }
}; };
// ConstantExpr - a constant value that is initialized with an expression using // ConstantExpr - a constant value that is initialized with an expression using
// other constant values. This is only used to represent values that cannot be // other constant values. This is only used to represent values that cannot be
// evaluated at compile-time (e.g., something derived from an address) because // evaluated at compile-time (e.g., something derived from an address) because
@ -465,9 +467,11 @@ public:
// Constant subclass above for known constants. // Constant subclass above for known constants.
// //
class ConstantExpr : public Constant { class ConstantExpr : public Constant {
unsigned iType; // Operation type unsigned iType; // Operation type (an Instruction opcode)
friend struct ConstantCreator<ConstantExpr,Type,
std::pair<unsigned, std::vector<Constant*> > >;
protected: protected:
// Cast creation ctor // Cast creation ctor
ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty); ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty);
// Binary/Shift instruction creation ctor // Binary/Shift instruction creation ctor
@ -475,6 +479,7 @@ protected:
// GEP instruction creation ctor // GEP instruction creation ctor
ConstantExpr(Constant *C, const std::vector<Constant*> &IdxList, ConstantExpr(Constant *C, const std::vector<Constant*> &IdxList,
const Type *DestTy); const Type *DestTy);
void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
public: public:
// Static methods to construct a ConstantExpr of different kinds. Note that // Static methods to construct a ConstantExpr of different kinds. Note that