diff options
author | Devang Patel <dpatel@apple.com> | 2009-10-21 17:33:41 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-10-21 17:33:41 +0000 |
commit | b5df28a151421fcce53547763ae9772461d5bbdb (patch) | |
tree | 22a960d2c46acdd59de81d3333df3cabcdb2e24a /include/llvm/Metadata.h | |
parent | 36a9c8f0b3c5a9ae606283c62a725b9bf75df070 (diff) | |
download | external_llvm-b5df28a151421fcce53547763ae9772461d5bbdb.zip external_llvm-b5df28a151421fcce53547763ae9772461d5bbdb.tar.gz external_llvm-b5df28a151421fcce53547763ae9772461d5bbdb.tar.bz2 |
Incorporate various suggestions Chris gave during metadata review.
- i < getNumElements() instead of getNumElements() > i
- Make setParent() private
- Fix use of resizeOperands
- Reset HasMetadata bit after removing all metadata attached to an instruction
- Efficient use of iterators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84765 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Metadata.h')
-rw-r--r-- | include/llvm/Metadata.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/include/llvm/Metadata.h b/include/llvm/Metadata.h index 388361e..3b2f303 100644 --- a/include/llvm/Metadata.h +++ b/include/llvm/Metadata.h @@ -145,7 +145,7 @@ public: /// getElement - Return specified element. Value *getElement(unsigned i) const { - assert(getNumElements() > i && "Invalid element number!"); + assert(i < getNumElements() && "Invalid element number!"); return Node[i]; } @@ -211,6 +211,7 @@ class NamedMDNode : public MetadataBase, public ilist_node<NamedMDNode> { SmallVector<WeakMetadataVH, 4> Node; typedef SmallVectorImpl<WeakMetadataVH>::iterator elem_iterator; + void setParent(Module *M) { Parent = M; } protected: explicit NamedMDNode(LLVMContext &C, const Twine &N, MetadataBase*const *Vals, unsigned NumVals, Module *M = 0); @@ -240,11 +241,10 @@ public: /// getParent - Get the module that holds this named metadata collection. inline Module *getParent() { return Parent; } inline const Module *getParent() const { return Parent; } - void setParent(Module *M) { Parent = M; } /// getElement - Return specified element. MetadataBase *getElement(unsigned i) const { - assert(getNumElements() > i && "Invalid element number!"); + assert(i < getNumElements() && "Invalid element number!"); return Node[i]; } @@ -255,7 +255,7 @@ public: /// addElement - Add metadata element. void addElement(MetadataBase *M) { - resizeOperands(0); + resizeOperands(NumOperands + 1); OperandList[NumOperands++] = M; Node.push_back(WeakMetadataVH(M)); } @@ -319,8 +319,8 @@ public: /// removeMD - Remove metadata of given kind attached with an instuction. void removeMD(unsigned Kind, Instruction *Inst); - /// removeMDs - Remove all metadata attached with an instruction. - void removeMDs(const Instruction *Inst); + /// removeAllMetadata - Remove all metadata attached with an instruction. + void removeAllMetadata(Instruction *Inst); /// copyMD - If metadata is attached with Instruction In1 then attach /// the same metadata to In2. @@ -333,8 +333,8 @@ public: /// ValueIsDeleted - This handler is used to update metadata store /// when a value is deleted. void ValueIsDeleted(const Value *) {} - void ValueIsDeleted(const Instruction *Inst) { - removeMDs(Inst); + void ValueIsDeleted(Instruction *Inst) { + removeAllMetadata(Inst); } void ValueIsRAUWd(Value *V1, Value *V2); |