Related to http://llvm.org/bugs/show_bug.cgi?id=9214

This patch converts the Metadata API (principally MDNode::get*()) to
use ArrayRef<>.

I've converted the llvm and clang trees (tested with "make check") and
also dragonegg (only tested by building it). Other clients will also
need updating. (Clients that just use DIBuilder to created debug info
metadata won't need any changes.)

OK to commit?

Thanks,
Jay.
Index: llvm/trunk/include/llvm/Metadata.h
===================================================================
--- llvm/trunk/include/llvm/Metadata.h	(revision 129909)
+++ llvm/trunk/include/llvm/Metadata.h	(working copy)
@@ -111,30 +111,25 @@
   void replaceOperand(MDNodeOperand *Op, Value *NewVal);
   ~MDNode();
 
-  MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
-         bool isFunctionLocal);
+  MDNode(LLVMContext &C, ArrayRef<Value*> Vals, bool isFunctionLocal);
   
-  static MDNode *getMDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
+  static MDNode *getMDNode(LLVMContext &C, ArrayRef<Value*> Vals,
                            FunctionLocalness FL, bool Insert = true);
 public:
   // Constructors and destructors.
-  static MDNode *get(LLVMContext &Context, ArrayRef<Value*> V);
-  // FIXME: Eliminate this constructor form.
-  static MDNode *get(LLVMContext &Context, Value *const *Vals,
-                     unsigned NumVals);
+  static MDNode *get(LLVMContext &Context, ArrayRef<Value*> Vals);
   // getWhenValsUnresolved - Construct MDNode determining function-localness
   // from isFunctionLocal argument, not by analyzing Vals.
-  static MDNode *getWhenValsUnresolved(LLVMContext &Context, Value *const *Vals,
-                                       unsigned NumVals, bool isFunctionLocal);
+  static MDNode *getWhenValsUnresolved(LLVMContext &Context,
+                                       ArrayRef<Value*> Vals,
+                                       bool isFunctionLocal);
                                        
-  static MDNode *getIfExists(LLVMContext &Context, Value *const *Vals,
-                             unsigned NumVals);
+  static MDNode *getIfExists(LLVMContext &Context, ArrayRef<Value*> Vals);
 
   /// getTemporary - Return a temporary MDNode, for use in constructing
   /// cyclic MDNode structures. A temporary MDNode is not uniqued,
   /// may be RAUW'd, and must be manually deleted with deleteTemporary.
-  static MDNode *getTemporary(LLVMContext &Context, Value *const *Vals,
-                              unsigned NumVals);
+  static MDNode *getTemporary(LLVMContext &Context, ArrayRef<Value*> Vals);
 
   /// deleteTemporary - Deallocate a node created by getTemporary. The
   /// node must not have any users.
Index: llvm/trunk/unittests/VMCore/MetadataTest.cpp
===================================================================
--- llvm/trunk/unittests/VMCore/MetadataTest.cpp	(revision 129909)
+++ llvm/trunk/unittests/VMCore/MetadataTest.cpp	(working copy)
@@ -87,10 +87,10 @@
   V.push_back(CI);
   V.push_back(s2);
 
-  MDNode *n1 = MDNode::get(Context, &V[0], 3);
+  MDNode *n1 = MDNode::get(Context, V);
   Value *const c1 = n1;
-  MDNode *n2 = MDNode::get(Context, &c1, 1);
-  MDNode *n3 = MDNode::get(Context, &V[0], 3);
+  MDNode *n2 = MDNode::get(Context, c1);
+  MDNode *n3 = MDNode::get(Context, V);
   EXPECT_NE(n1, n2);
 #ifdef ENABLE_MDNODE_UNIQUING
   EXPECT_EQ(n1, n3);
@@ -112,7 +112,7 @@
   Instruction *I = new BitCastInst(C, Type::getInt32Ty(getGlobalContext()));
 
   Value *const V = I;
-  MDNode *n = MDNode::get(Context, &V, 1);
+  MDNode *n = MDNode::get(Context, V);
   WeakVH wvh = n;
 
   EXPECT_EQ(n, wvh);
@@ -127,8 +127,8 @@
 
   Value *const V = C;
   Value *const V2 = C2;
-  MDNode *n = MDNode::get(Context, &V, 1);
-  MDNode *n2 = MDNode::get(Context, &V2, 1);
+  MDNode *n = MDNode::get(Context, V);
+  MDNode *n2 = MDNode::get(Context, V2);
 
   Module M("MyModule", Context);
   const char *Name = "llvm.NMD1";
Index: llvm/trunk/lib/Analysis/DIBuilder.cpp
===================================================================
--- llvm/trunk/lib/Analysis/DIBuilder.cpp	(revision 129909)
+++ llvm/trunk/lib/Analysis/DIBuilder.cpp	(working copy)
@@ -518,7 +518,7 @@
   // Give the temporary MDNode a tag. It doesn't matter what tag we
   // use here as long as DIType accepts it.
   Value *Elts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
-  MDNode *Node = MDNode::getTemporary(VMContext, Elts, 1);
+  MDNode *Node = MDNode::getTemporary(VMContext, Elts);
   return DIType(Node);
 }
 
@@ -532,7 +532,7 @@
     NULL,
     F
   };
-  MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts));
+  MDNode *Node = MDNode::getTemporary(VMContext, Elts);
   return DIType(Node);
 }
 
@@ -540,9 +540,9 @@
 DIArray DIBuilder::getOrCreateArray(Value *const *Elements, unsigned NumElements) {
   if (NumElements == 0) {
     Value *Null = llvm::Constant::getNullValue(Type::getInt32Ty(VMContext));
-    return DIArray(MDNode::get(VMContext, &Null, 1));
+    return DIArray(MDNode::get(VMContext, Null));
   }
-  return DIArray(MDNode::get(VMContext, Elements, NumElements));
+  return DIArray(MDNode::get(VMContext, ArrayRef<Value*>(Elements, NumElements)));
 }
 
 /// getOrCreateSubrange - Create a descriptor for a value range.  This
@@ -778,7 +778,7 @@
   if (!DeclareFn)
     DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
 
-  Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), VarInfo };
+  Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
   return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore);
 }
 
@@ -790,7 +790,7 @@
   if (!DeclareFn)
     DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
 
-  Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), VarInfo };
+  Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
 
   // If this block already has a terminator then insert this intrinsic
   // before the terminator.
@@ -809,7 +809,7 @@
   if (!ValueFn)
     ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
 
-  Value *Args[] = { MDNode::get(V->getContext(), &V, 1),
+  Value *Args[] = { MDNode::get(V->getContext(), V),
                     ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
                     VarInfo };
   return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore);
@@ -824,7 +824,7 @@
   if (!ValueFn)
     ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
 
-  Value *Args[] = { MDNode::get(V->getContext(), &V, 1),
+  Value *Args[] = { MDNode::get(V->getContext(), V),
                     ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
                     VarInfo };
   return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd);
Index: llvm/trunk/lib/VMCore/Core.cpp
===================================================================
--- llvm/trunk/lib/VMCore/Core.cpp	(revision 129909)
+++ llvm/trunk/lib/VMCore/Core.cpp	(working copy)
@@ -543,7 +543,8 @@
 
 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
                                  unsigned Count) {
-  return wrap(MDNode::get(*unwrap(C), unwrap<Value>(Vals, Count), Count));
+  return wrap(MDNode::get(*unwrap(C),
+                          ArrayRef<Value*>(unwrap<Value>(Vals, Count), Count)));
 }
 
 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) {
Index: llvm/trunk/lib/VMCore/Metadata.cpp
===================================================================
--- llvm/trunk/lib/VMCore/Metadata.cpp	(revision 129909)
+++ llvm/trunk/lib/VMCore/Metadata.cpp	(working copy)
@@ -84,18 +84,18 @@
   return reinterpret_cast<MDNodeOperand*>(N+1)+Op;
 }
 
-MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
-               bool isFunctionLocal)
+MDNode::MDNode(LLVMContext &C, ArrayRef<Value*> Vals, bool isFunctionLocal)
 : Value(Type::getMetadataTy(C), Value::MDNodeVal) {
-  NumOperands = NumVals;
+  NumOperands = Vals.size();
 
   if (isFunctionLocal)
     setValueSubclassData(getSubclassDataFromValue() | FunctionLocalBit);
 
   // Initialize the operand list, which is co-allocated on the end of the node.
+  unsigned i = 0;
   for (MDNodeOperand *Op = getOperandPtr(this, 0), *E = Op+NumOperands;
-       Op != E; ++Op, ++Vals)
-    new (Op) MDNodeOperand(*Vals, this);
+       Op != E; ++Op, ++i)
+    new (Op) MDNodeOperand(Vals[i], this);
 }
 
 
@@ -183,9 +183,8 @@
          (isa<MDNode>(V) && cast<MDNode>(V)->isFunctionLocal());
 }
 
-MDNode *MDNode::getMDNode(LLVMContext &Context, Value *const *Vals,
-                          unsigned NumVals, FunctionLocalness FL,
-                          bool Insert) {
+MDNode *MDNode::getMDNode(LLVMContext &Context, ArrayRef<Value*> Vals,
+                          FunctionLocalness FL, bool Insert) {
   LLVMContextImpl *pImpl = Context.pImpl;
 
   // Add all the operand pointers. Note that we don't have to add the
@@ -193,7 +192,7 @@
   // Note that if the operands are later nulled out, the node will be
   // removed from the uniquing map.
   FoldingSetNodeID ID;
-  for (unsigned i = 0; i != NumVals; ++i)
+  for (unsigned i = 0; i != Vals.size(); ++i)
     ID.AddPointer(Vals[i]);
 
   void *InsertPoint;
@@ -205,7 +204,7 @@
   bool isFunctionLocal = false;
   switch (FL) {
   case FL_Unknown:
-    for (unsigned i = 0; i != NumVals; ++i) {
+    for (unsigned i = 0; i != Vals.size(); ++i) {
       Value *V = Vals[i];
       if (!V) continue;
       if (isFunctionLocalValue(V)) {
@@ -223,8 +222,8 @@
   }
 
   // Coallocate space for the node and Operands together, then placement new.
-  void *Ptr = malloc(sizeof(MDNode)+NumVals*sizeof(MDNodeOperand));
-  N = new (Ptr) MDNode(Context, Vals, NumVals, isFunctionLocal);
+  void *Ptr = malloc(sizeof(MDNode)+Vals.size()*sizeof(MDNodeOperand));
+  N = new (Ptr) MDNode(Context, Vals, isFunctionLocal);
 
   // InsertPoint will have been set by the FindNodeOrInsertPos call.
   pImpl->MDNodeSet.InsertNode(N, InsertPoint);
@@ -233,26 +232,23 @@
 }
 
 MDNode *MDNode::get(LLVMContext &Context, ArrayRef<Value*> Vals) {
-  return getMDNode(Context, Vals.data(), Vals.size(), FL_Unknown);
+  return getMDNode(Context, Vals, FL_Unknown);
 }
-MDNode *MDNode::get(LLVMContext &Context, Value*const* Vals, unsigned NumVals) {
-  return getMDNode(Context, Vals, NumVals, FL_Unknown);
-}
 
-MDNode *MDNode::getWhenValsUnresolved(LLVMContext &Context, Value *const *Vals,
-                                      unsigned NumVals, bool isFunctionLocal) {
-  return getMDNode(Context, Vals, NumVals, isFunctionLocal ? FL_Yes : FL_No);
+MDNode *MDNode::getWhenValsUnresolved(LLVMContext &Context,
+                                      ArrayRef<Value*> Vals,
+                                      bool isFunctionLocal) {
+  return getMDNode(Context, Vals, isFunctionLocal ? FL_Yes : FL_No);
 }
 
-MDNode *MDNode::getIfExists(LLVMContext &Context, Value *const *Vals,
-                            unsigned NumVals) {
-  return getMDNode(Context, Vals, NumVals, FL_Unknown, false);
+MDNode *MDNode::getIfExists(LLVMContext &Context, ArrayRef<Value*> Vals) {
+  return getMDNode(Context, Vals, FL_Unknown, false);
 }
 
-MDNode *MDNode::getTemporary(LLVMContext &Context, Value *const *Vals,
-                             unsigned NumVals) {
-  MDNode *N = (MDNode *)malloc(sizeof(MDNode)+NumVals*sizeof(MDNodeOperand));
-  N = new (N) MDNode(Context, Vals, NumVals, FL_No);
+MDNode *MDNode::getTemporary(LLVMContext &Context, ArrayRef<Value*> Vals) {
+  MDNode *N =
+    (MDNode *)malloc(sizeof(MDNode)+Vals.size()*sizeof(MDNodeOperand));
+  N = new (N) MDNode(Context, Vals, FL_No);
   N->setValueSubclassData(N->getSubclassDataFromValue() |
                           NotUniquedBit);
   LeakDetector::addGarbageObject(N);
Index: llvm/trunk/lib/VMCore/DebugLoc.cpp
===================================================================
--- llvm/trunk/lib/VMCore/DebugLoc.cpp	(revision 129909)
+++ llvm/trunk/lib/VMCore/DebugLoc.cpp	(working copy)
@@ -109,7 +109,7 @@
     ConstantInt::get(Int32, getLine()), ConstantInt::get(Int32, getCol()),
     Scope, IA
   };
-  return MDNode::get(Ctx2, &Elts[0], 4);
+  return MDNode::get(Ctx2, Elts);
 }
 
 /// getFromDILocation - Translate the DILocation quad into a DebugLoc.
Index: llvm/trunk/lib/AsmParser/LLParser.cpp
===================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp	(revision 129909)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp	(working copy)
@@ -514,7 +514,7 @@
   if (Result) return false;
 
   // Otherwise, create MDNode forward reference.
-  MDNode *FwdNode = MDNode::getTemporary(Context, 0, 0);
+  MDNode *FwdNode = MDNode::getTemporary(Context, ArrayRef<Value*>());
   ForwardRefMDNodes[MID] = std::make_pair(FwdNode, Lex.getLoc());
   
   if (NumberedMetadata.size() <= MID)
@@ -572,7 +572,7 @@
       ParseToken(lltok::rbrace, "expected end of metadata node"))
     return true;
 
-  MDNode *Init = MDNode::get(Context, Elts.data(), Elts.size());
+  MDNode *Init = MDNode::get(Context, Elts);
   
   // See if this was forward referenced, if so, handle it.
   std::map<unsigned, std::pair<TrackingVH<MDNode>, LocTy> >::iterator
@@ -2498,7 +2498,7 @@
       ParseToken(lltok::rbrace, "expected end of metadata node"))
     return true;
 
-  ID.MDNodeVal = MDNode::get(Context, Elts.data(), Elts.size());
+  ID.MDNodeVal = MDNode::get(Context, Elts);
   ID.Kind = ValID::t_MDNode;
   return false;
 }
Index: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp	(revision 129909)
+++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp	(working copy)
@@ -39,7 +39,7 @@
       return VM[V] = const_cast<Value*>(V);
     
     // Create a dummy node in case we have a metadata cycle.
-    MDNode *Dummy = MDNode::getTemporary(V->getContext(), 0, 0);
+    MDNode *Dummy = MDNode::getTemporary(V->getContext(), ArrayRef<Value*>());
     VM[V] = Dummy;
     
     // Check all operands to see if any need to be remapped.
@@ -54,7 +54,7 @@
         Value *Op = MD->getOperand(i);
         Elts.push_back(Op ? MapValue(Op, VM, Flags) : 0);
       }
-      MDNode *NewMD = MDNode::get(V->getContext(), Elts.data(), Elts.size());
+      MDNode *NewMD = MDNode::get(V->getContext(), Elts);
       Dummy->replaceAllUsesWith(NewMD);
       VM[V] = NewMD;
       MDNode::deleteTemporary(Dummy);
Index: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp	(revision 129909)
+++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp	(working copy)
@@ -104,7 +104,7 @@
 /// FindAllocaDbgDeclare - Finds the llvm.dbg.declare intrinsic describing the
 /// alloca 'V', if any.
 static DbgDeclareInst *FindAllocaDbgDeclare(Value *V) {
-  if (MDNode *DebugNode = MDNode::getIfExists(V->getContext(), &V, 1))
+  if (MDNode *DebugNode = MDNode::getIfExists(V->getContext(), V))
     for (Value::use_iterator UI = DebugNode->use_begin(),
          E = DebugNode->use_end(); UI != E; ++UI)
       if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(*UI))
Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp	(revision 129909)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp	(working copy)
@@ -349,7 +349,7 @@
   }
 
   // Create and return a placeholder, which will later be RAUW'd.
-  Value *V = MDNode::getTemporary(Context, 0, 0);
+  Value *V = MDNode::getTemporary(Context, ArrayRef<Value*>());
   MDValuePtrs[Idx] = V;
   return V;
 }
@@ -843,9 +843,7 @@
         else
           Elts.push_back(NULL);
       }
-      Value *V = MDNode::getWhenValsUnresolved(Context,
-                                               Elts.data(), Elts.size(),
-                                               IsFunctionLocal);
+      Value *V = MDNode::getWhenValsUnresolved(Context, Elts, IsFunctionLocal);
       IsFunctionLocal = false;
       MDValueList.AssignValue(V, NextMDValueNo++);
       break;
Index: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp	(revision 129909)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp	(working copy)
@@ -1035,7 +1035,7 @@
       llvm::MDString::get(VMContext, Class->getSuperClass()->getNameAsString()),
       llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), IsClassMessage)
    };
-  llvm::MDNode *node = llvm::MDNode::get(VMContext, impMD, 3);
+  llvm::MDNode *node = llvm::MDNode::get(VMContext, impMD);
 
   llvm::Instruction *call;
   RValue msgRet = CGF.EmitCall(FnInfo, imp, Return, ActualArgs,
@@ -1109,7 +1109,7 @@
         llvm::MDString::get(VMContext, Class ? Class->getNameAsString() :""),
         llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), Class!=0)
    };
-  llvm::MDNode *node = llvm::MDNode::get(VMContext, impMD, 3);
+  llvm::MDNode *node = llvm::MDNode::get(VMContext, impMD);
 
   // Get the IMP to call
   llvm::Value *imp = LookupIMP(CGF, Receiver, cmd, node);
Index: cfe/trunk/lib/CodeGen/CGStmt.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp	(revision 129909)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp	(working copy)
@@ -1351,7 +1351,7 @@
     }
   }    
   
-  return llvm::MDNode::get(CGF.getLLVMContext(), Locs.data(), Locs.size());
+  return llvm::MDNode::get(CGF.getLLVMContext(), Locs);
 }
 
 void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp	(revision 129909)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp	(working copy)
@@ -241,7 +241,7 @@
           CGM.getModule().getOrInsertNamedMetadata("opencl.kernels");
           
         llvm::Value *Op = Fn;
-        OpenCLMetadata->addOperand(llvm::MDNode::get(Context, &Op, 1));
+        OpenCLMetadata->addOperand(llvm::MDNode::get(Context, Op));
       }
   }
 
Index: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp	(revision 129909)
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp	(working copy)
@@ -74,7 +74,8 @@
   };
 
   // Create the mdnode.
-  return llvm::MDNode::get(VMContext, Ops, llvm::array_lengthof(Ops) - !Flags);
+  unsigned Len = llvm::array_lengthof(Ops) - !Flags;
+  return llvm::MDNode::get(VMContext, llvm::ArrayRef<llvm::Value*>(Ops, Len));
 }
 
 static bool TypeHasMayAlias(QualType QTy) {
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp	(revision 129909)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp	(working copy)
@@ -2160,7 +2160,7 @@
     Addr,
     GetPointerConstant(CGM.getLLVMContext(), D.getDecl())
   };
-  GlobalMetadata->addOperand(llvm::MDNode::get(CGM.getLLVMContext(), Ops, 2));
+  GlobalMetadata->addOperand(llvm::MDNode::get(CGM.getLLVMContext(), Ops));
 }
 
 /// Emits metadata nodes associating all the global values in the
@@ -2201,7 +2201,7 @@
 
     if (llvm::AllocaInst *Alloca = dyn_cast<llvm::AllocaInst>(Addr)) {
       llvm::Value *DAddr = GetPointerConstant(getLLVMContext(), D);
-      Alloca->setMetadata(DeclPtrKind, llvm::MDNode::get(Context, &DAddr, 1));
+      Alloca->setMetadata(DeclPtrKind, llvm::MDNode::get(Context, DAddr));
     } else if (llvm::GlobalValue *GV = dyn_cast<llvm::GlobalValue>(Addr)) {
       GlobalDecl GD = GlobalDecl(cast<VarDecl>(D));
       EmitGlobalDeclMetadata(CGM, GlobalMetadata, GD, GV);
Index: dragonegg/trunk/src/Debug.cpp
===================================================================
--- dragonegg/trunk/src/Debug.cpp	(revision 129911)
+++ dragonegg/trunk/src/Debug.cpp	(working copy)
@@ -1180,11 +1180,11 @@
 DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) {
   if (NumTys == 0) {
     Value *Null = llvm::Constant::getNullValue(Type::getInt32Ty(VMContext));
-    return DIArray(MDNode::get(VMContext, &Null, 1));
+    return DIArray(MDNode::get(VMContext, Null));
   }
 
   SmallVector<Value *, 16> Elts(Tys, Tys+NumTys);
-  return DIArray(MDNode::get(VMContext, Elts.data(), Elts.size()));
+  return DIArray(MDNode::get(VMContext, Elts));
 }
 
 /// GetOrCreateSubrange - Create a descriptor for a value range.  This
@@ -1196,7 +1196,7 @@
     ConstantInt::get(Type::getInt64Ty(VMContext), Hi)
   };
 
-  return DISubrange(MDNode::get(VMContext, &Elts[0], 3));
+  return DISubrange(MDNode::get(VMContext, Elts));
 }
 
 /// CreateUnspecifiedParameter - Create unspeicified type descriptor
@@ -1205,7 +1205,7 @@
   Value *Elts[] = {
     GetTagConstant(dwarf::DW_TAG_unspecified_parameters)
   };
-  return DIDescriptor(MDNode::get(VMContext, &Elts[0], 1));
+  return DIDescriptor(MDNode::get(VMContext, Elts));
 }
 
 /// CreateCompileUnit - Create a new descriptor for the specified compile
@@ -1231,7 +1231,7 @@
     ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer)
   };
 
-  return DICompileUnit(MDNode::get(VMContext, &Elts[0], 10));
+  return DICompileUnit(MDNode::get(VMContext, Elts));
 }
 
 /// CreateFile -  Create a new descriptor for the specified file.
@@ -1245,7 +1245,7 @@
     CU
   };
 
-  return DIFile(MDNode::get(VMContext, &Elts[0], 4));
+  return DIFile(MDNode::get(VMContext, Elts));
 }
 
 /// CreateEnumerator - Create a single enumerator value.
@@ -1255,7 +1255,7 @@
     MDString::get(VMContext, Name),
     ConstantInt::get(Type::getInt64Ty(VMContext), Val)
   };
-  return DIEnumerator(MDNode::get(VMContext, &Elts[0], 3));
+  return DIEnumerator(MDNode::get(VMContext, Elts));
 }
 
 
@@ -1280,7 +1280,7 @@
     ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
     ConstantInt::get(Type::getInt32Ty(VMContext), Encoding)
   };
-  return DIBasicType(MDNode::get(VMContext, &Elts[0], 10));
+  return DIBasicType(MDNode::get(VMContext, Elts));
 }
 
 
@@ -1305,7 +1305,7 @@
     ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
     ConstantInt::get(Type::getInt32Ty(VMContext), Encoding)
   };
-  return DIBasicType(MDNode::get(VMContext, &Elts[0], 10));
+  return DIBasicType(MDNode::get(VMContext, Elts));
 }
 
 /// CreateArtificialType - Create a new DIType with "artificial" flag set.
@@ -1329,7 +1329,7 @@
   // Flags are stored at this slot.
   Elts[8] =  ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags);
 
-  return DIType(MDNode::get(VMContext, Elts.data(), Elts.size()));
+  return DIType(MDNode::get(VMContext, Elts));
 }
 
 /// CreateDerivedType - Create a derived type like const qualified type,
@@ -1356,7 +1356,7 @@
     ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
     DerivedFrom,
   };
-  return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10));
+  return DIDerivedType(MDNode::get(VMContext, Elts));
 }
 
 
@@ -1384,7 +1384,7 @@
     ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
     DerivedFrom,
   };
-  return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10));
+  return DIDerivedType(MDNode::get(VMContext, Elts));
 }
 
 
@@ -1419,7 +1419,7 @@
     ContainingType
   };
 
-  MDNode *Node = MDNode::get(VMContext, &Elts[0], 13);
+  MDNode *Node = MDNode::get(VMContext, Elts);
   // Create a named metadata so that we do not lose this enum info.
   if (Tag == dwarf::DW_TAG_enumeration_type) {
     NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum");
@@ -1435,7 +1435,7 @@
   Value *Elts[] = {
     GetTagConstant(DW_TAG_base_type)
   };
-  MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts));
+  MDNode *Node = MDNode::getTemporary(VMContext, Elts);
   return DIType(Node);
 }
 
@@ -1449,7 +1449,7 @@
     NULL,
     F
   };
-  MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts));
+  MDNode *Node = MDNode::getTemporary(VMContext, Elts);
   return DIType(Node);
 }
 
@@ -1482,7 +1482,7 @@
     ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang),
     ContainingType
   };
-  MDNode *Node = MDNode::get(VMContext, &Elts[0], 13);
+  MDNode *Node = MDNode::get(VMContext, Elts);
   // Create a named metadata so that we do not lose this enum info.
   if (Tag == dwarf::DW_TAG_enumeration_type) {
     NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum");
@@ -1528,7 +1528,7 @@
     ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
     Fn
   };
-  MDNode *Node = MDNode::get(VMContext, &Elts[0], 17);
+  MDNode *Node = MDNode::get(VMContext, Elts);
 
   // Create a named metadata so that we do not lose this mdnode.
   NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.sp");
@@ -1562,7 +1562,7 @@
     DeclNode->getOperand(15), // isOptimized
     SPDeclaration.getFunction()
   };
-  MDNode *Node =MDNode::get(VMContext, &Elts[0], 16);
+  MDNode *Node =MDNode::get(VMContext, Elts);
 
   // Create a named metadata so that we do not lose this mdnode.
   NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.sp");
@@ -1593,8 +1593,7 @@
     Val
   };
 
-  Value *const *Vs = &Elts[0];
-  MDNode *Node = MDNode::get(VMContext,Vs, 12);
+  MDNode *Node = MDNode::get(VMContext, Elts);
 
   // Create a named metadata so that we do not lose this mdnode.
   NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv");
@@ -1626,8 +1625,7 @@
     Val
   };
 
-  Value *const *Vs = &Elts[0];
-  MDNode *Node = MDNode::get(VMContext,Vs, 12);
+  MDNode *Node = MDNode::get(VMContext, Elts);
 
   // Create a named metadata so that we do not lose this mdnode.
   NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv");
@@ -1652,7 +1650,7 @@
     Ty,
     ConstantInt::get(Type::getInt32Ty(VMContext), Flags)
   };
-  MDNode *Node = MDNode::get(VMContext, &Elts[0], 7);
+  MDNode *Node = MDNode::get(VMContext, Elts);
   if (AlwaysPreserve) {
     // The optimizer may remove local variable. If there is an interest
     // to preserve variable info in such situation then stash it in a
@@ -1689,7 +1687,7 @@
   Elts.push_back(Ty);
   Elts.append(Addr, Addr+NumAddr);
 
-  return DIVariable(MDNode::get(VMContext, Elts.data(), Elts.size()));
+  return DIVariable(MDNode::get(VMContext, Elts));
 }
 
 
@@ -1708,7 +1706,7 @@
     F,
     ConstantInt::get(Type::getInt32Ty(VMContext), unique_id++)
   };
-  return DILexicalBlock(MDNode::get(VMContext, &Elts[0], 6));
+  return DILexicalBlock(MDNode::get(VMContext, Elts));
 }
 
 /// CreateNameSpace - This creates new descriptor for a namespace
@@ -1723,7 +1721,7 @@
     F,
     ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)
   };
-  return DINameSpace(MDNode::get(VMContext, &Elts[0], 5));
+  return DINameSpace(MDNode::get(VMContext, Elts));
 }
 
 /// CreateLocation - Creates a debug info location.
@@ -1735,7 +1733,7 @@
     S,
     OrigLoc,
   };
-  return DILocation(MDNode::get(VMContext, &Elts[0], 4));
+  return DILocation(MDNode::get(VMContext, Elts));
 }
 
 //===----------------------------------------------------------------------===//
@@ -1750,7 +1748,7 @@
   if (!DeclareFn)
     DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
 
-  Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1),
+  Value *Args[] = { MDNode::get(Storage->getContext(), Storage), 
                     D };
   return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore);
 }
@@ -1763,7 +1761,7 @@
   if (!DeclareFn)
     DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
 
-  Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1),
+  Value *Args[] = { MDNode::get(Storage->getContext(), Storage),
                     D };
 
   // If this block already has a terminator then insert this intrinsic
@@ -1782,7 +1780,7 @@
   if (!ValueFn)
     ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
 
-  Value *Args[] = { MDNode::get(V->getContext(), &V, 1),
+  Value *Args[] = { MDNode::get(V->getContext(), V),
                     ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
                     D };
   return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore);
@@ -1797,7 +1795,7 @@
   if (!ValueFn)
     ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
 
-  Value *Args[] = { MDNode::get(V->getContext(), &V, 1),
+  Value *Args[] = { MDNode::get(V->getContext(), V),
                     ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
                     D };
   return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd);
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to