diff --git a/llvm/include/llvm/ADT/SmallPtrSet.h b/llvm/include/llvm/ADT/SmallPtrSet.h index 518ed5cd0672..ee4a11768eb7 100644 --- a/llvm/include/llvm/ADT/SmallPtrSet.h +++ b/llvm/include/llvm/ADT/SmallPtrSet.h @@ -290,12 +290,6 @@ public: SmallPtrSetIterator operator++(int) { // Postincrement SmallPtrSetIterator tmp = *this; -#if LLVM_ENABLE_ABI_BREAKING_CHECKS - if (ReverseIterate::value) { - --*this; - return tmp; - } -#endif ++*this; return tmp; } diff --git a/llvm/unittests/ADT/ReverseIterationTest.cpp b/llvm/unittests/ADT/ReverseIterationTest.cpp index 9235ecd74321..a1fd3b26d4e3 100644 --- a/llvm/unittests/ADT/ReverseIterationTest.cpp +++ b/llvm/unittests/ADT/ReverseIterationTest.cpp @@ -31,9 +31,22 @@ TEST(ReverseIterationTest, SmallPtrSetTest) { for (const auto &Tuple : zip(Set, Ptrs)) ASSERT_EQ(std::get<0>(Tuple), std::get<1>(Tuple)); + // Check operator++ (post-increment) in forward iteration. + int i = 0; + for (auto begin = Set.begin(), end = Set.end(); + begin != end; i++) + ASSERT_EQ(*begin++, Ptrs[i]); + // Check reverse iteration. ReverseIterate::value = true; for (const auto &Tuple : zip(Set, ReversePtrs)) ASSERT_EQ(std::get<0>(Tuple), std::get<1>(Tuple)); + + // Check operator++ (post-increment) in reverse iteration. + i = 0; + for (auto begin = Set.begin(), end = Set.end(); + begin != end; i++) + ASSERT_EQ(*begin++, ReversePtrs[i]); + } #endif