diff options
author | Chris Lattner <sabre@nondot.org> | 2002-07-30 18:54:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-07-30 18:54:22 +0000 |
commit | e8e4605021141d689493132a9c7c6fce6294937f (patch) | |
tree | 0f0c6d598e711050201cc4079fb8b874214dc62c /include | |
parent | 53b7f26150060c990c4b3431d340d52747c0b24c (diff) | |
download | external_llvm-e8e4605021141d689493132a9c7c6fce6294937f.zip external_llvm-e8e4605021141d689493132a9c7c6fce6294937f.tar.gz external_llvm-e8e4605021141d689493132a9c7c6fce6294937f.tar.bz2 |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Constants.h | 31 |
1 files changed, 15 insertions, 16 deletions
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<Constant*> &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<Constant*> &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<Constant*> &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<Constant*> &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; } |