IR: Move MDNode clone() methods from ValueMapper to MDNode, NFC

Now that the clone methods used by `MapMetadata()` don't do any
remapping (and return a temporary), they make more sense as member
functions on `MDNode` (and subclasses).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226541 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-01-20 02:56:57 +00:00
parent eefbe59844
commit 749d6fbf7e
3 changed files with 41 additions and 34 deletions

View File

@ -418,6 +418,17 @@ MDNode::MDNode(LLVMContext &Context, unsigned ID, StorageType Storage,
this->Context.makeReplaceable(make_unique<ReplaceableMetadataImpl>(Context));
}
TempMDNode MDNode::clone() const {
switch (getMetadataID()) {
default:
llvm_unreachable("Invalid MDNode subclass");
#define HANDLE_MDNODE_LEAF(CLASS) \
case CLASS##Kind: \
return cast<CLASS>(this)->cloneImpl();
#include "llvm/IR/Metadata.def"
}
}
static bool isOperandUnresolved(Metadata *Op) {
if (auto *N = dyn_cast_or_null<MDNode>(Op))
return !N->isResolved();