[llvm] r292034 - Adding const overloads of operator* and operator-> for DenseSet iterators
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 14 13:54:58 PST 2017
Author: majnemer
Date: Sat Jan 14 15:54:58 2017
New Revision: 292034
URL: http://llvm.org/viewvc/llvm-project?rev=292034&view=rev
Log:
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
Modified:
llvm/trunk/include/llvm/ADT/DenseSet.h
Modified: llvm/trunk/include/llvm/ADT/DenseSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseSet.h?rev=292034&r1=292033&r2=292034&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseSet.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseSet.h Sat Jan 14 15:54:58 2017
@@ -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; }
More information about the llvm-commits
mailing list