From e8e4605021141d689493132a9c7c6fce6294937f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 30 Jul 2002 18:54:22 +0000 Subject: Cleanup ConstantExpr handling: * Correctly delete TypeHandles in AsmParser. In addition to not leaking memory, this prevents a bug that could have occurred when a type got resolved that the constexpr was using * Check for errors in the AsmParser instead of hitting assertion failures deep in the code * Simplify the interface to the ConstantExpr class, removing unneccesary parameters to the ::get* methods. * Rename the 'getelementptr' version of ConstantExpr::get to ConstantExpr::getGetElementPtr git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3160 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Constants.h | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 1674e0a..07a82ed 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -11,11 +11,9 @@ #include "llvm/Constant.h" #include "Support/DataTypes.h" - class ArrayType; class StructType; class PointerType; -class ConstantExpr; //===--------------------------------------------------------------------------- // ConstantBool - Boolean Values @@ -340,25 +338,29 @@ public: // Use the appropriate Constant subclass above for known constants. // class ConstantExpr : public Constant { - unsigned iType; // operation type + unsigned iType; // Operation type protected: - ConstantExpr(unsigned opCode, Constant *C, const Type *Ty); - ConstantExpr(unsigned opCode, Constant* C1, Constant* C2, const Type *Ty); - ConstantExpr(unsigned opCode, Constant* C, - const std::vector &IdxList, const Type *Ty); + ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty); + ConstantExpr(unsigned Opcode, Constant *C1, Constant *C2); + ConstantExpr(Constant *C, const std::vector &IdxList, + const Type *DestTy); ~ConstantExpr() {} virtual void destroyConstant(); public: // Static methods to construct a ConstantExpr of different kinds. + + // Unary constant expr - Use with unary operators and casts static ConstantExpr *get(unsigned Opcode, Constant *C, const Type *Ty); - static ConstantExpr *get(unsigned Opcode, - Constant *C1, Constant *C2, const Type *Ty); - static ConstantExpr *get(unsigned Opcode, Constant *C, - const std::vector &IdxList, - const Type *Ty); + + // Binary constant expr - Use with binary operators... + static ConstantExpr *get(unsigned Opcode, Constant *C1, Constant *C2); + + // Getelementptr form... + static ConstantExpr *getGetElementPtr(Constant *C, + const std::vector &IdxList); // isNullValue - Return true if this is the value that would be returned by // getNullValue. @@ -368,10 +370,7 @@ public: unsigned getOpcode() const { return iType; } // getOpcodeName - Return a string representation for an opcode. - static const char *getOpcodeName(unsigned opCode); - const char *getOpcodeName() const { - return getOpcodeName(getOpcode()); - } + const char *getOpcodeName() const; // isConstantExpr - Return true if this is a ConstantExpr virtual bool isConstantExpr() const { return true; } -- cgit v1.1