Add a new ConstantExpr::getWithOperands that takes any array of operands
authorChris Lattner <sabre@nondot.org>
Wed, 20 Aug 2008 22:27:40 +0000 (22:27 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 20 Aug 2008 22:27:40 +0000 (22:27 +0000)
instead of requiring an std::vector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55084 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constants.h
lib/VMCore/Constants.cpp

index 22acbfcd45076afdae4786c2d16ae28973d63bb0..efae25525d26b5e57f6053bc3e71a9e490d148d9 100644 (file)
@@ -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<Constant*> &Ops) const;
+  Constant *getWithOperands(const std::vector<Constant*> &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);
index bb8fa655565e184b95f1073be697ad6f5f249edc..df1ac086b779fddb16e9d3abb059b76524c17c29 100644 (file)
@@ -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<Constant*> &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<Constant*> &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: