From c5754a65e64126743644aec2631f165a0ac3ffe4 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Wed, 5 Nov 2014 18:16:03 +0000 Subject: 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. llvm-svn: 221375 --- llvm/lib/IR/Metadata.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'llvm/lib/IR/Metadata.cpp') diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index 3806fe4fd4e..59beb734184 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -555,14 +555,13 @@ MDNode *MDNode::getMostGenericRange(MDNode *A, MDNode *B) { // NamedMDNode implementation. // -static SmallVector, 4> &getNMDOps(void *Operands) { - return *(SmallVector, 4>*)Operands; +static SmallVector, 4> &getNMDOps(void *Operands) { + return *(SmallVector, 4> *)Operands; } NamedMDNode::NamedMDNode(const Twine &N) - : Name(N.str()), Parent(nullptr), - Operands(new SmallVector, 4>()) { -} + : Name(N.str()), Parent(nullptr), + Operands(new SmallVector, 4>()) {} NamedMDNode::~NamedMDNode() { dropAllReferences(); @@ -573,7 +572,7 @@ unsigned NamedMDNode::getNumOperands() const { return (unsigned)getNMDOps(Operands).size(); } -MDNode *NamedMDNode::getOperand(unsigned i) const { +Value *NamedMDNode::getOperand(unsigned i) const { assert(i < getNumOperands() && "Invalid Operand number!"); return &*getNMDOps(Operands)[i]; } @@ -582,7 +581,7 @@ void NamedMDNode::addOperand(Value *V) { auto *M = cast(V); assert(!M->isFunctionLocal() && "NamedMDNode operands must not be function-local!"); - getNMDOps(Operands).push_back(TrackingVH(M)); + getNMDOps(Operands).push_back(TrackingVH(M)); } void NamedMDNode::eraseFromParent() { -- cgit v1.2.3