diff --git a/llvm/include/llvm/Constants.h b/llvm/include/llvm/Constants.h index 22acbfcd4507..efae25525d26 100644 --- a/llvm/include/llvm/Constants.h +++ b/llvm/include/llvm/Constants.h @@ -752,7 +752,10 @@ public: /// getWithOperands - This returns the current constant expression with the /// operands replaced with the specified values. The specified operands must /// match count and type with the existing ones. - Constant *getWithOperands(const std::vector &Ops) const; + Constant *getWithOperands(const std::vector &Ops) const { + return getWithOperands(&Ops[0], Ops.size()); + } + Constant *getWithOperands(Constant* const *Ops, unsigned NumOps) const; virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index bb8fa655565e..df1ac086b779 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -879,10 +879,10 @@ ConstantExpr::getWithOperandReplaced(unsigned OpNo, Constant *Op) const { /// operands replaced with the specified values. The specified operands must /// match count and type with the existing ones. Constant *ConstantExpr:: -getWithOperands(const std::vector &Ops) const { - assert(Ops.size() == getNumOperands() && "Operand count mismatch!"); +getWithOperands(Constant* const *Ops, unsigned NumOps) const { + assert(NumOps == getNumOperands() && "Operand count mismatch!"); bool AnyChange = false; - for (unsigned i = 0, e = Ops.size(); i != e; ++i) { + for (unsigned i = 0; i != NumOps; ++i) { assert(Ops[i]->getType() == getOperand(i)->getType() && "Operand type mismatch!"); AnyChange |= Ops[i] != getOperand(i); @@ -913,7 +913,7 @@ getWithOperands(const std::vector &Ops) const { case Instruction::ShuffleVector: return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]); case Instruction::GetElementPtr: - return ConstantExpr::getGetElementPtr(Ops[0], &Ops[1], Ops.size()-1); + return ConstantExpr::getGetElementPtr(Ops[0], &Ops[1], NumOps-1); case Instruction::ICmp: case Instruction::FCmp: case Instruction::VICmp: