From: Duncan P. N. Exon Smith Date: Mon, 12 Jan 2015 20:21:37 +0000 (+0000) Subject: IR: Move creation logic to MDNodeFwdDecl, NFC X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=c88b471b9d172d96301c790592bfe19b6d5a9b5c 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 --- diff --git a/include/llvm/IR/Metadata.h b/include/llvm/IR/Metadata.h index d06621df3aa..1f327f6bdb3 100644 --- a/include/llvm/IR/Metadata.h +++ b/include/llvm/IR/Metadata.h @@ -813,7 +813,6 @@ MDNode *MDNode::getDistinct(LLVMContext &Context, ArrayRef MDs) { /// uniqued, and is suitable for forward references. class MDNodeFwdDecl : public MDNode, ReplaceableMetadataImpl { friend class Metadata; - friend class MDNode; friend class ReplaceableMetadataImpl; MDNodeFwdDecl(LLVMContext &C, ArrayRef Vals) @@ -823,6 +822,10 @@ public: ~MDNodeFwdDecl() { dropAllReferences(); } using MDNode::operator delete; + static MDNodeFwdDecl *get(LLVMContext &Context, ArrayRef MDs) { + return new (MDs.size()) MDNodeFwdDecl(Context, MDs); + } + static bool classof(const Metadata *MD) { return MD->getMetadataID() == MDNodeFwdDeclKind; } diff --git a/lib/IR/Metadata.cpp b/lib/IR/Metadata.cpp index 3d444660c67..9088a75156e 100644 --- a/lib/IR/Metadata.cpp +++ b/lib/IR/Metadata.cpp @@ -607,14 +607,10 @@ MDTuple *MDTuple::getDistinct(LLVMContext &Context, ArrayRef MDs) { MDNodeFwdDecl *MDNode::getTemporary(LLVMContext &Context, ArrayRef MDs) { - MDNodeFwdDecl *N = new (MDs.size()) MDNodeFwdDecl(Context, MDs); - return N; + return MDNodeFwdDecl::get(Context, MDs); } -void MDNode::deleteTemporary(MDNode *N) { - assert(isa(N) && "Expected forward declaration"); - delete cast(N); -} +void MDNode::deleteTemporary(MDNode *N) { delete cast(N); } void UniquableMDNode::storeDistinctInContext() { assert(!IsDistinctInContext && "Expected newly distinct metadata");