]> granicus.if.org Git - llvm/commitdiff
[ADT] Fix for compilation error when operator++(int) (post-increment function) of...
authorAbhilash Bhandari <abhilash_bhandari@yahoo.co.in>
Fri, 30 Dec 2016 12:34:36 +0000 (12:34 +0000)
committerAbhilash Bhandari <abhilash_bhandari@yahoo.co.in>
Fri, 30 Dec 2016 12:34:36 +0000 (12:34 +0000)
The bug was introduced in r289619.

Reviewers: Mehdi Amini

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D28134

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290749 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/SmallPtrSet.h
unittests/ADT/ReverseIterationTest.cpp

index 518ed5cd0672231f5cffb948855297069c0ac300..ee4a11768eb7ddf517208467b786d94d5630a5a0 100644 (file)
@@ -290,12 +290,6 @@ public:
 
   SmallPtrSetIterator operator++(int) {        // Postincrement
     SmallPtrSetIterator tmp = *this;
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
-    if (ReverseIterate<bool>::value) {
-      --*this;
-      return tmp;
-    }
-#endif
     ++*this;
     return tmp;
   }
index 9235ecd74321e2401a2da93aa170eec2d99d9010..a1fd3b26d4e3a155262b35071ef028d2d26a5575 100644 (file)
@@ -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<bool>::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