diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2017-01-14 21:54:58 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2017-01-14 21:54:58 +0000 |
| commit | 70110ec5827a1d776bdf6a80060ee89bce1ef746 (patch) | |
| tree | ebefee09159fa7dda6f42044019d0274f0ed7631 | |
| parent | fa3674017a7df04630112947fd2de969ac51f7ec (diff) | |
| download | bcm5719-llvm-70110ec5827a1d776bdf6a80060ee89bce1ef746.tar.gz bcm5719-llvm-70110ec5827a1d776bdf6a80060ee89bce1ef746.zip | |
Adding const overloads of operator* and operator-> for DenseSet iterators
This fixes some problems when building ClangDiagnostics.cpp on Visual Studio 2017 RC. As far as I understand, there was a change in the implementation of the constructor for std::vector with two iterator parameters, which in our case causes an attempt to dereference const Iterator objects. Since there was no overload for a const Iterator, the compile would fail.
Patch by Hugo Puhlmann!
Differential Revision: https://reviews.llvm.org/D28726
llvm-svn: 292034
| -rw-r--r-- | llvm/include/llvm/ADT/DenseSet.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/include/llvm/ADT/DenseSet.h b/llvm/include/llvm/ADT/DenseSet.h index b25d3b7cba6..0e26a9d42e8 100644 --- a/llvm/include/llvm/ADT/DenseSet.h +++ b/llvm/include/llvm/ADT/DenseSet.h @@ -104,7 +104,9 @@ public: Iterator(const typename MapTy::iterator &i) : I(i) {} ValueT &operator*() { return I->getFirst(); } + const ValueT &operator*() const { return I->getFirst(); } ValueT *operator->() { return &I->getFirst(); } + const ValueT *operator->() const { return &I->getFirst(); } Iterator& operator++() { ++I; return *this; } Iterator operator++(int) { auto T = *this; ++I; return T; } @@ -125,8 +127,8 @@ public: ConstIterator(const typename MapTy::const_iterator &i) : I(i) {} - const ValueT &operator*() { return I->getFirst(); } - const ValueT *operator->() { return &I->getFirst(); } + const ValueT &operator*() const { return I->getFirst(); } + const ValueT *operator->() const { return &I->getFirst(); } ConstIterator& operator++() { ++I; return *this; } ConstIterator operator++(int) { auto T = *this; ++I; return T; } |

