forked from OSchip/llvm-project
There is no need to keep name ref in NamedMDNode.
llvm-svn: 77511
This commit is contained in:
parent
c23c7e6a51
commit
4a942d0863
|
@ -185,31 +185,26 @@ class NamedMDNode : public MetadataBase, public ilist_node<NamedMDNode> {
|
|||
friend class LLVMContextImpl;
|
||||
|
||||
Module *Parent;
|
||||
StringRef Name;
|
||||
SmallVector<WeakMetadataVH, 4> Node;
|
||||
typedef SmallVectorImpl<WeakMetadataVH>::iterator elem_iterator;
|
||||
|
||||
protected:
|
||||
explicit NamedMDNode(const char *N, unsigned NameLength,
|
||||
MetadataBase*const* Vals, unsigned NumVals,
|
||||
Module *M = 0);
|
||||
explicit NamedMDNode(const Twine &N, MetadataBase*const* Vals,
|
||||
unsigned NumVals, Module *M = 0);
|
||||
public:
|
||||
static NamedMDNode *Create(const char *N, unsigned NamedLength,
|
||||
MetadataBase*const*MDs, unsigned NumMDs,
|
||||
Module *M = 0) {
|
||||
return new NamedMDNode(N, NamedLength, MDs, NumMDs, M);
|
||||
static NamedMDNode *Create(const Twine &N, MetadataBase*const*MDs,
|
||||
unsigned NumMDs, Module *M = 0) {
|
||||
return new NamedMDNode(N, MDs, NumMDs, M);
|
||||
}
|
||||
|
||||
typedef SmallVectorImpl<WeakMetadataVH>::const_iterator const_elem_iterator;
|
||||
|
||||
StringRef getName() const { return Name; }
|
||||
|
||||
/// getParent - Get the module that holds this named metadata collection.
|
||||
inline Module *getParent() { return Parent; }
|
||||
inline const Module *getParent() const { return Parent; }
|
||||
void setParent(Module *M) { Parent = M; }
|
||||
|
||||
Value *getElement(unsigned i) const {
|
||||
MetadataBase *getElement(unsigned i) const {
|
||||
return Node[i];
|
||||
}
|
||||
|
||||
|
|
|
@ -440,8 +440,7 @@ bool LLParser::ParseNamedMetadata() {
|
|||
if (ParseToken(lltok::rbrace, "expected end of metadata node"))
|
||||
return true;
|
||||
|
||||
NamedMDNode::Create(Name.c_str(), Name.length(),
|
||||
Elts.data(), Elts.size(), M);
|
||||
NamedMDNode::Create(Name, Elts.data(), Elts.size(), M);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,15 +33,12 @@ void MDNode::Profile(FoldingSetNodeID &ID) const {
|
|||
//===----------------------------------------------------------------------===//
|
||||
//NamedMDNode implementation
|
||||
//
|
||||
NamedMDNode::NamedMDNode(const char *N, unsigned NameLength,
|
||||
MetadataBase*const* MDs, unsigned NumMDs,
|
||||
Module *M)
|
||||
: MetadataBase(Type::MetadataTy, Value::NamedMDNodeVal),
|
||||
Name(N, NameLength) {
|
||||
NamedMDNode::NamedMDNode(const Twine &N, MetadataBase*const* MDs,
|
||||
unsigned NumMDs, Module *ParentModule)
|
||||
: MetadataBase(Type::MetadataTy, Value::NamedMDNodeVal) {
|
||||
setName(N);
|
||||
for (unsigned i = 0; i != NumMDs; ++i)
|
||||
Node.push_back(WeakMetadataVH(MDs[i]));
|
||||
|
||||
if (M)
|
||||
M->getNamedMDList().push_back(this);
|
||||
if (ParentModule)
|
||||
ParentModule->getNamedMDList().push_back(this);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue