summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-01-12 20:21:37 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-01-12 20:21:37 +0000
commit942623540b24fbd3df5df314ee2e02a98a0909de (patch)
tree323c2efbb4c23965f88156eb1bfafeb7c9606ef3 /llvm
parentb565b10956ab80e83bf17b878c7866347010d627 (diff)
downloadbcm5719-llvm-942623540b24fbd3df5df314ee2e02a98a0909de.tar.gz
bcm5719-llvm-942623540b24fbd3df5df314ee2e02a98a0909de.zip
IR: Move creation logic to MDNodeFwdDecl, NFC
Same as with `MDTuple`, factor out a `friend MDNode` by moving creation logic to the concrete subclass. llvm-svn: 225690
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/IR/Metadata.h5
-rw-r--r--llvm/lib/IR/Metadata.cpp8
2 files changed, 6 insertions, 7 deletions
diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h
index d06621df3aa..1f327f6bdb3 100644
--- a/llvm/include/llvm/IR/Metadata.h
+++ b/llvm/include/llvm/IR/Metadata.h
@@ -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;
}
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 3d444660c67..9088a75156e 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -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");
OpenPOWER on IntegriCloud