IR: MDNode => Value: NamedMDNode::getOperator()

Change `NamedMDNode::getOperator()` from returning `MDNode *` to
returning `Value *`.  To reduce boilerplate at some call sites, add a
`getOperatorAsMDNode()` for named metadata that's expected to only
return `MDNode` -- for now, that's everything, but debug node named
metadata (such as llvm.dbg.cu and llvm.dbg.sp) will soon change.  This
is part of PR21433.

Note that there's a follow-up patch to clang for the API change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221375 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2014-11-05 18:16:03 +00:00
parent 4a6537c0a9
commit bad06b13ba
17 changed files with 47 additions and 42 deletions

View File

@@ -555,7 +555,7 @@ void Verifier::visitGlobalAlias(const GlobalAlias &GA) {
void Verifier::visitNamedMDNode(const NamedMDNode &NMD) {
for (unsigned i = 0, e = NMD.getNumOperands(); i != e; ++i) {
MDNode *MD = NMD.getOperand(i);
MDNode *MD = NMD.getOperandAsMDNode(i);
if (!MD)
continue;
@@ -624,7 +624,7 @@ void Verifier::visitModuleIdents(const Module &M) {
// llvm.ident takes a list of metadata entry. Each entry has only one string.
// Scan each llvm.ident entry and make sure that this requirement is met.
for (unsigned i = 0, e = Idents->getNumOperands(); i != e; ++i) {
const MDNode *N = Idents->getOperand(i);
const MDNode *N = Idents->getOperandAsMDNode(i);
Assert1(N->getNumOperands() == 1,
"incorrect number of operands in llvm.ident metadata", N);
Assert1(isa<MDString>(N->getOperand(0)),
@@ -642,7 +642,7 @@ void Verifier::visitModuleFlags(const Module &M) {
DenseMap<const MDString*, const MDNode*> SeenIDs;
SmallVector<const MDNode*, 16> Requirements;
for (unsigned I = 0, E = Flags->getNumOperands(); I != E; ++I) {
visitModuleFlag(Flags->getOperand(I), SeenIDs, Requirements);
visitModuleFlag(Flags->getOperandAsMDNode(I), SeenIDs, Requirements);
}
// Validate that the requirements in the module are valid.