1 //===-- Metadata.cpp - Implement Metadata classes -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the Metadata classes.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Metadata.h"
15 #include "llvm/Module.h"
16 #include "SymbolTableListTraitsImpl.h"
19 //===----------------------------------------------------------------------===//
20 //MDNode implementation
22 MDNode::MDNode(Value*const* Vals, unsigned NumVals)
23 : MetadataBase(Type::MetadataTy, Value::MDNodeVal) {
24 for (unsigned i = 0; i != NumVals; ++i)
25 Node.push_back(WeakVH(Vals[i]));
28 void MDNode::Profile(FoldingSetNodeID &ID) const {
29 for (const_elem_iterator I = elem_begin(), E = elem_end(); I != E; ++I)
33 //===----------------------------------------------------------------------===//
34 //NamedMDNode implementation
36 NamedMDNode::NamedMDNode(const Twine &N, MetadataBase*const* MDs,
37 unsigned NumMDs, Module *ParentModule)
38 : MetadataBase(Type::MetadataTy, Value::NamedMDNodeVal) {
40 for (unsigned i = 0; i != NumMDs; ++i)
41 Node.push_back(WeakMetadataVH(MDs[i]));
43 ParentModule->getNamedMDList().push_back(this);