[llvm] r290749 - [ADT] Fix for compilation error when operator++(int) (post-increment function) of SmallPtrSetIterator is used.

Abhilash Bhandari via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 30 04:34:37 PST 2016


Author: abhandari
Date: Fri Dec 30 06:34:36 2016
New Revision: 290749

URL: http://llvm.org/viewvc/llvm-project?rev=290749&view=rev
Log:
[ADT] Fix for compilation error when operator++(int) (post-increment function) of SmallPtrSetIterator is used.
The bug was introduced in r289619.

Reviewers: Mehdi Amini

Subscribers: llvm-commits

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

Modified:
    llvm/trunk/include/llvm/ADT/SmallPtrSet.h
    llvm/trunk/unittests/ADT/ReverseIterationTest.cpp

Modified: llvm/trunk/include/llvm/ADT/SmallPtrSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallPtrSet.h?rev=290749&r1=290748&r2=290749&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SmallPtrSet.h (original)
+++ llvm/trunk/include/llvm/ADT/SmallPtrSet.h Fri Dec 30 06:34:36 2016
@@ -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;
   }

Modified: llvm/trunk/unittests/ADT/ReverseIterationTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/ReverseIterationTest.cpp?rev=290749&r1=290748&r2=290749&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/ReverseIterationTest.cpp (original)
+++ llvm/trunk/unittests/ADT/ReverseIterationTest.cpp Fri Dec 30 06:34:36 2016
@@ -31,9 +31,22 @@ TEST(ReverseIterationTest, SmallPtrSetTe
   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




More information about the llvm-commits mailing list