[llvm-commits] CVS: llvm/include/llvm/Constants.h

Chris Lattner lattner at cs.uiuc.edu
Fri May 23 15:03:02 PDT 2003


Changes in directory llvm/include/llvm:

Constants.h updated: 1.24 -> 1.25

---
Log message:

Remove some cruft, add some methods to allow implementation of bugfix for
Bug: Linker/2003-04-26-NullPtrLinkProblem.ll


---
Diffs of the changes:

Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.24 llvm/include/llvm/Constants.h:1.25
--- llvm/include/llvm/Constants.h:1.24	Fri May 23 12:13:15 2003
+++ llvm/include/llvm/Constants.h	Fri May 23 15:02:05 2003
@@ -15,6 +15,8 @@
 class StructType;
 class PointerType;
 
+template<class ConstantClass, class TypeClass, class ValType>
+struct ConstantCreator;
 
 //===---------------------------------------------------------------------------
 /// ConstantIntegral - Shared superclass of boolean and integer constants.
@@ -67,7 +69,6 @@
 class ConstantBool : public ConstantIntegral {
   bool Val;
   ConstantBool(bool V);
-  ~ConstantBool() {}
 public:
   static ConstantBool *True, *False;  // The True & False values
 
@@ -113,7 +114,6 @@
   } 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 @@
 ///
 class ConstantSInt : public ConstantInt {
   ConstantSInt(const ConstantSInt &);      // DO NOT IMPLEMENT
+  friend struct ConstantCreator<ConstantSInt, Type, int64_t>;
+
 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 @@
 ///
 class ConstantUInt : public ConstantInt {
   ConstantUInt(const ConstantUInt &);      // DO NOT IMPLEMENT
+  friend struct ConstantCreator<ConstantUInt, Type, uint64_t>;
 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 @@
 ///
 class ConstantFP : public Constant {
   double Val;
+  friend struct ConstantCreator<ConstantFP, Type, double>;
   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 @@
 /// ConstantArray - Constant Array Declarations
 ///
 class ConstantArray : public Constant {
+  friend struct ConstantCreator<ConstantArray, ArrayType,
+                                    std::vector<Constant*> >;
   ConstantArray(const ConstantArray &);      // DO NOT IMPLEMENT
 protected:
   ConstantArray(const ArrayType *T, const std::vector<Constant*> &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<Constant*> &);
@@ -316,11 +318,12 @@
 // ConstantStruct - Constant Struct Declarations
 //
 class ConstantStruct : public Constant {
+  friend struct ConstantCreator<ConstantStruct, StructType,
+                                    std::vector<Constant*> >;
   ConstantStruct(const ConstantStruct &);      // DO NOT IMPLEMENT
 protected:
   ConstantStruct(const StructType *T, const std::vector<Constant*> &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 @@
 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 @@
 /// ConstantPointerNull - a constant pointer value that points to null
 ///
 class ConstantPointerNull : public ConstantPointer {
+  friend struct ConstantCreator<ConstantPointerNull, PointerType, char>;
   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 @@
 
 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 @@
   }
 };
 
-
 // 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 @@
 // Constant subclass above for known constants.
 //
 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
   ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty);
   // Binary/Shift instruction creation ctor
@@ -475,6 +479,7 @@
   // GEP instruction creation ctor
   ConstantExpr(Constant *C, const std::vector<Constant*> &IdxList,
                const Type *DestTy);
+  void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
   
 public:
   // Static methods to construct a ConstantExpr of different kinds.  Note that





More information about the llvm-commits mailing list