Fix DenseMap iterator constness.

This patch forbids implicit conversion of DenseMap::const_iterator to
DenseMap::iterator which was possible because DenseMapIterator inherited
(publicly) from DenseMapConstIterator. Conversion the other way around is now
allowed as one may expect.

The template DenseMapConstIterator is removed and the template parameter
IsConst which specifies whether the iterator is constant is added to
DenseMapIterator.

Actually IsConst parameter is not necessary since the constness can be
determined from KeyT but this is not relevant to the fix and can be addressed
later.

Patch by Victor Zverovich!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86636 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jeffrey Yasskin
2009-11-10 01:02:17 +00:00
parent d06094f068
commit 81cf432569
14 changed files with 76 additions and 61 deletions

View File

@@ -341,11 +341,11 @@ MDNode *MetadataContextImpl::getMD(unsigned MDKind, const Instruction *Inst) {
/// getMDs - Get the metadata attached to an Instruction.
void MetadataContextImpl::
getMDs(const Instruction *Inst, SmallVectorImpl<MDPairTy> &MDs) const {
MDStoreTy::iterator I = MetadataStore.find(Inst);
MDStoreTy::const_iterator I = MetadataStore.find(Inst);
if (I == MetadataStore.end())
return;
MDs.resize(I->second.size());
for (MDMapTy::iterator MI = I->second.begin(), ME = I->second.end();
for (MDMapTy::const_iterator MI = I->second.begin(), ME = I->second.end();
MI != ME; ++MI)
// MD kinds are numbered from 1.
MDs[MI->first - 1] = std::make_pair(MI->first, MI->second);