diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 0577db3efc4..eaf56a301cd 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -521,6 +521,11 @@ public: /// @brief Implement superclass method. virtual CmpInst *clone() const; + /// @brief Get the opcode casted to the right type + OtherOps getOpcode() const { + return static_cast(Instruction::getOpcode()); + } + /// The predicate for CmpInst is defined by the subclasses but stored in /// the SubclassData field (see Value.h). We allow it to be fetched here /// as the predicate but there is no enum type for it, just the raw unsigned diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index f9271178a4d..5f1aaea9094 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -378,8 +378,7 @@ struct VISIBILITY_HIDDEN CompareConstantExpr : public ConstantExpr { Use Ops[2]; CompareConstantExpr(Instruction::OtherOps opc, unsigned short pred, Constant* LHS, Constant* RHS) - : ConstantExpr(Type::BoolTy, Instruction::OtherOps(opc), Ops, 2), - predicate(pred) { + : ConstantExpr(Type::BoolTy, opc, Ops, 2), predicate(pred) { OperandList[0].init(LHS, this); OperandList[1].init(RHS, this); } diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 1cc04334cdb..57dd5a56b8a 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -2252,8 +2252,7 @@ BinaryOperator *BinaryOperator::clone() const { } CmpInst* CmpInst::clone() const { - return create(Instruction::OtherOps(getOpcode()), getPredicate(), - Ops[0], Ops[1]); + return create(getOpcode(), getPredicate(), Ops[0], Ops[1]); } MallocInst *MallocInst::clone() const { return new MallocInst(*this); }