[llvm] r342697 - Fix DenseSet::ConstIterator typedefs
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 20 16:11:27 PDT 2018
Author: dblaikie
Date: Thu Sep 20 16:11:27 2018
New Revision: 342697
URL: http://llvm.org/viewvc/llvm-project?rev=342697&view=rev
Log:
Fix DenseSet::ConstIterator typedefs
Fix DenseSet::ConstIterator pointer/reference typedefs to be const
Patch by Brad Moody!
Differential Revision: https://reviews.llvm.org/D52260
Modified:
llvm/trunk/include/llvm/ADT/DenseSet.h
llvm/trunk/unittests/ADT/DenseSetTest.cpp
Modified: llvm/trunk/include/llvm/ADT/DenseSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseSet.h?rev=342697&r1=342696&r2=342697&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseSet.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseSet.h Thu Sep 20 16:11:27 2018
@@ -136,8 +136,8 @@ public:
public:
using difference_type = typename MapTy::const_iterator::difference_type;
using value_type = ValueT;
- using pointer = value_type *;
- using reference = value_type &;
+ using pointer = const value_type *;
+ using reference = const value_type &;
using iterator_category = std::forward_iterator_tag;
ConstIterator() = default;
Modified: llvm/trunk/unittests/ADT/DenseSetTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/DenseSetTest.cpp?rev=342697&r1=342696&r2=342697&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/DenseSetTest.cpp (original)
+++ llvm/trunk/unittests/ADT/DenseSetTest.cpp Thu Sep 20 16:11:27 2018
@@ -15,6 +15,13 @@ using namespace llvm;
namespace {
+static_assert(std::is_const<std::remove_pointer<
+ DenseSet<int>::const_iterator::pointer>::type>::value,
+ "Iterator pointer type should be const");
+static_assert(std::is_const<std::remove_reference<
+ DenseSet<int>::const_iterator::reference>::type>::value,
+ "Iterator reference type should be const");
+
// Test hashing with a set of only two entries.
TEST(DenseSetTest, DoubleEntrySetTest) {
llvm::DenseSet<unsigned> set(2);
More information about the llvm-commits
mailing list