From 6cc89aad25155ecd93b5318414851aa46351196d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 23 May 2003 20:02:05 +0000 Subject: [PATCH] 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 --- include/llvm/Constants.h | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 7e2cd845dc8..77c39452d18 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -15,6 +15,8 @@ class ArrayType; class StructType; class PointerType; +template +struct ConstantCreator; //===--------------------------------------------------------------------------- /// ConstantIntegral - Shared superclass of boolean and integer constants. @@ -67,7 +69,6 @@ public: class ConstantBool : public ConstantIntegral { bool Val; ConstantBool(bool V); - ~ConstantBool() {} public: static ConstantBool *True, *False; // The True & False values @@ -113,7 +114,6 @@ protected: } Val; ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT ConstantInt(const Type *Ty, uint64_t V); - ~ConstantInt() {} public: /// 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 @@ -151,9 +151,10 @@ public: /// class ConstantSInt : public ConstantInt { ConstantSInt(const ConstantSInt &); // DO NOT IMPLEMENT + friend struct ConstantCreator; + protected: ConstantSInt(const Type *Ty, int64_t V); - ~ConstantSInt() {} public: /// get() - Static factory methods - Return objects of the specified value static ConstantSInt *get(const Type *Ty, int64_t V); @@ -199,9 +200,9 @@ public: /// class ConstantUInt : public ConstantInt { ConstantUInt(const ConstantUInt &); // DO NOT IMPLEMENT + friend struct ConstantCreator; protected: ConstantUInt(const Type *Ty, uint64_t V); - ~ConstantUInt() {} public: /// get() - Static factory methods - Return objects of the specified value static ConstantUInt *get(const Type *Ty, uint64_t V); @@ -233,10 +234,10 @@ public: /// class ConstantFP : public Constant { double Val; + friend struct ConstantCreator; ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT protected: ConstantFP(const Type *Ty, double V); - ~ConstantFP() {} public: /// get() - Static factory methods - Return objects of the specified value static ConstantFP *get(const Type *Ty, double V); @@ -262,11 +263,12 @@ public: /// ConstantArray - Constant Array Declarations /// class ConstantArray : public Constant { + friend struct ConstantCreator >; ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT protected: ConstantArray(const ArrayType *T, const std::vector &Val); - ~ConstantArray() {} - + void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); public: /// get() - Static factory methods - Return objects of the specified value static ConstantArray *get(const ArrayType *T, const std::vector &); @@ -316,11 +318,12 @@ public: // ConstantStruct - Constant Struct Declarations // class ConstantStruct : public Constant { + friend struct ConstantCreator >; ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT protected: ConstantStruct(const StructType *T, const std::vector &Val); - ~ConstantStruct() {} - + void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); public: /// get() - Static factory methods - Return objects of the specified value static ConstantStruct *get(const StructType *T, @@ -367,8 +370,7 @@ public: class ConstantPointer : public Constant { ConstantPointer(const ConstantPointer &); // DO NOT IMPLEMENT protected: - inline ConstantPointer(const PointerType *T) : Constant((const Type*)T){} - ~ConstantPointer() {} + inline ConstantPointer(const PointerType *T) : Constant((const Type*)T) {} public: inline const PointerType *getType() const { return (PointerType*)Value::getType(); @@ -389,10 +391,12 @@ public: /// ConstantPointerNull - a constant pointer value that points to null /// class ConstantPointerNull : public ConstantPointer { + friend struct ConstantCreator; ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT protected: - inline ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {} - inline ~ConstantPointerNull() {} + ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {} + void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); + public: /// get() - Static factory methods - Return objects of the specified value @@ -427,7 +431,6 @@ class ConstantPointerRef : public ConstantPointer { protected: ConstantPointerRef(GlobalValue *GV); - ~ConstantPointerRef() {} public: /// get() - Static factory methods - Return objects of the specified value static ConstantPointerRef *get(GlobalValue *GV); @@ -457,7 +460,6 @@ public: } }; - // ConstantExpr - a constant value that is initialized with an expression using // 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 @@ -465,9 +467,11 @@ public: // Constant subclass above for known constants. // class ConstantExpr : public Constant { - unsigned iType; // Operation type + unsigned iType; // Operation type (an Instruction opcode) + friend struct ConstantCreator > >; -protected: +protected: // Cast creation ctor ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty); // Binary/Shift instruction creation ctor @@ -475,6 +479,7 @@ protected: // GEP instruction creation ctor ConstantExpr(Constant *C, const std::vector &IdxList, const Type *DestTy); + void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); public: // Static methods to construct a ConstantExpr of different kinds. Note that