From: Jay Foad Date: Wed, 13 Apr 2011 13:46:01 +0000 (+0000) Subject: PR9214: Convert ConstantExpr::getWithOperands() to use ArrayRef. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b81e457eb02b67a9ef5fb9edc1604b177acb821d;p=oota-llvm.git PR9214: Convert ConstantExpr::getWithOperands() to use ArrayRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129439 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index c12b33fae71..62a2d9f06fd 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -897,10 +897,7 @@ 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 { - return getWithOperands(&Ops[0], (unsigned)Ops.size()); - } - Constant *getWithOperands(Constant *const *Ops, unsigned NumOps) const; + Constant *getWithOperands(llvm::ArrayRef Ops) const; virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 8223f76bbbc..d42fb924bd1 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -301,8 +301,7 @@ void BitcodeReaderValueList::ResolveConstantForwardRefs() { NewC = ConstantVector::get(NewOps); } else { assert(isa(UserC) && "Must be a ConstantExpr."); - NewC = cast(UserC)->getWithOperands(&NewOps[0], - NewOps.size()); + NewC = cast(UserC)->getWithOperands(NewOps); } UserC->replaceAllUsesWith(NewC); diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 7a4dcf92bb2..3c347ddd41b 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -855,10 +855,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(Constant *const *Ops, unsigned NumOps) const { - assert(NumOps == getNumOperands() && "Operand count mismatch!"); +getWithOperands(llvm::ArrayRef Ops) const { + assert(Ops.size() == getNumOperands() && "Operand count mismatch!"); bool AnyChange = false; - for (unsigned i = 0; i != NumOps; ++i) { + for (unsigned i = 0; i != Ops.size(); ++i) { assert(Ops[i]->getType() == getOperand(i)->getType() && "Operand type mismatch!"); AnyChange |= Ops[i] != getOperand(i); @@ -890,8 +890,8 @@ getWithOperands(Constant *const *Ops, unsigned NumOps) const { return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]); case Instruction::GetElementPtr: return cast(this)->isInBounds() ? - ConstantExpr::getInBoundsGetElementPtr(Ops[0], &Ops[1], NumOps-1) : - ConstantExpr::getGetElementPtr(Ops[0], &Ops[1], NumOps-1); + ConstantExpr::getInBoundsGetElementPtr(Ops[0], &Ops[1], Ops.size()-1) : + ConstantExpr::getGetElementPtr(Ops[0], &Ops[1], Ops.size()-1); case Instruction::ICmp: case Instruction::FCmp: return ConstantExpr::getCompare(getPredicate(), Ops[0], Ops[1]);