Merging r292034: (PR32315)
authorHans Wennborg <hans@hanshq.net>
Wed, 26 Apr 2017 21:37:30 +0000 (21:37 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 26 Apr 2017 21:37:30 +0000 (21:37 +0000)
Tweaked to not remove the non-const variants as to not change the ABI.

------------------------------------------------------------------------
r292034 | majnemer | 2017-01-14 13:54:58 -0800 (Sat, 14 Jan 2017) | 7 lines

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
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@301479 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/DenseSet.h

index b25d3b7cba6f4dae8dc8e2aae565de01adeb722c..9ab91507928b6c010812612860841310631d4dc1 100644 (file)
@@ -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; }
@@ -126,7 +128,9 @@ public:
     ConstIterator(const typename MapTy::const_iterator &i) : I(i) {}
 
     const ValueT &operator*() { return I->getFirst(); }
+    const ValueT &operator*() const { return I->getFirst(); }
     const ValueT *operator->() { return &I->getFirst(); }
+    const ValueT *operator->() const { return &I->getFirst(); }
 
     ConstIterator& operator++() { ++I; return *this; }
     ConstIterator operator++(int) { auto T = *this; ++I; return T; }