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
This commit is contained in:
Duncan P. N. Exon Smith 2015-01-12 20:21:37 +00:00
parent 45db33d634
commit c88b471b9d
2 changed files with 6 additions and 7 deletions

View File

@ -813,7 +813,6 @@ MDNode *MDNode::getDistinct(LLVMContext &Context, ArrayRef<Metadata *> 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<Metadata *> Vals)
@ -823,6 +822,10 @@ public:
~MDNodeFwdDecl() { dropAllReferences(); }
using MDNode::operator delete;
static MDNodeFwdDecl *get(LLVMContext &Context, ArrayRef<Metadata *> MDs) {
return new (MDs.size()) MDNodeFwdDecl(Context, MDs);
}
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == MDNodeFwdDeclKind;
}

View File

@ -607,14 +607,10 @@ MDTuple *MDTuple::getDistinct(LLVMContext &Context, ArrayRef<Metadata *> MDs) {
MDNodeFwdDecl *MDNode::getTemporary(LLVMContext &Context,
ArrayRef<Metadata *> MDs) {
MDNodeFwdDecl *N = new (MDs.size()) MDNodeFwdDecl(Context, MDs);
return N;
return MDNodeFwdDecl::get(Context, MDs);
}
void MDNode::deleteTemporary(MDNode *N) {
assert(isa<MDNodeFwdDecl>(N) && "Expected forward declaration");
delete cast<MDNodeFwdDecl>(N);
}
void MDNode::deleteTemporary(MDNode *N) { delete cast<MDNodeFwdDecl>(N); }
void UniquableMDNode::storeDistinctInContext() {
assert(!IsDistinctInContext && "Expected newly distinct metadata");