aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/DenseMapTest.cpp
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2009-11-10 01:02:17 +0000
committerJeffrey Yasskin <jyasskin@google.com>2009-11-10 01:02:17 +0000
commitb40d3f76a01406b9f21de5e73aa0ff0274b8e96c (patch)
tree6f8f5855c6aad581a49c7cb33c1614e152f70d63 /llvm/unittests/ADT/DenseMapTest.cpp
parenta71e9d61be9676c6b0209b3ed9c08cd3ad5be53b (diff)
downloadllvm-b40d3f76a01406b9f21de5e73aa0ff0274b8e96c.zip
llvm-b40d3f76a01406b9f21de5e73aa0ff0274b8e96c.tar.gz
llvm-b40d3f76a01406b9f21de5e73aa0ff0274b8e96c.tar.bz2
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! llvm-svn: 86636
Diffstat (limited to 'llvm/unittests/ADT/DenseMapTest.cpp')
-rw-r--r--llvm/unittests/ADT/DenseMapTest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp
index 15a5379..afac651 100644
--- a/llvm/unittests/ADT/DenseMapTest.cpp
+++ b/llvm/unittests/ADT/DenseMapTest.cpp
@@ -164,4 +164,16 @@ TEST_F(DenseMapTest, IterationTest) {
}
}
+// const_iterator test
+TEST_F(DenseMapTest, ConstIteratorTest) {
+ // Check conversion from iterator to const_iterator.
+ DenseMap<uint32_t, uint32_t>::iterator it = uintMap.begin();
+ DenseMap<uint32_t, uint32_t>::const_iterator cit(it);
+ EXPECT_TRUE(it == cit);
+
+ // Check copying of const_iterators.
+ DenseMap<uint32_t, uint32_t>::const_iterator cit2(cit);
+ EXPECT_TRUE(cit == cit2);
+}
+
}