llvm.org GIT mirror llvm / c88b471
IR: Move creation logic to MDNodeFwdDecl, NFC Same as with `MDTuple`, factor out a `friend MDNode` by moving creation logic to the concrete subclass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225690 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
2 changed file(s) with 8 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
812812 /// uniqued, and is suitable for forward references.
813813 class MDNodeFwdDecl : public MDNode, ReplaceableMetadataImpl {
814814 friend class Metadata;
815 friend class MDNode;
816815 friend class ReplaceableMetadataImpl;
817816
818817 MDNodeFwdDecl(LLVMContext &C, ArrayRef Vals)
821820 public:
822821 ~MDNodeFwdDecl() { dropAllReferences(); }
823822 using MDNode::operator delete;
823
824 static MDNodeFwdDecl *get(LLVMContext &Context, ArrayRef MDs) {
825 return new (MDs.size()) MDNodeFwdDecl(Context, MDs);
826 }
824827
825828 static bool classof(const Metadata *MD) {
826829 return MD->getMetadataID() == MDNodeFwdDeclKind;
606606
607607 MDNodeFwdDecl *MDNode::getTemporary(LLVMContext &Context,
608608 ArrayRef MDs) {
609 MDNodeFwdDecl *N = new (MDs.size()) MDNodeFwdDecl(Context, MDs);
610 return N;
611 }
612
613 void MDNode::deleteTemporary(MDNode *N) {
614 assert(isa(N) && "Expected forward declaration");
615 delete cast(N);
616 }
609 return MDNodeFwdDecl::get(Context, MDs);
610 }
611
612 void MDNode::deleteTemporary(MDNode *N) { delete cast(N); }
617613
618614 void UniquableMDNode::storeDistinctInContext() {
619615 assert(!IsDistinctInContext && "Expected newly distinct metadata");