Commit f761e7d6 authored by Hans Wennborg's avatar Hans Wennborg
Browse files

Merging r292034: (PR32315)

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

llvm-svn: 301479
parent 6ccc7b46
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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; }