[PATCH] D28134: Compilation error when using operator++ (post increment) function of SmallPtrSetIterator class

Abhilash Bhandari via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 27 22:24:22 PST 2016


Abhilash created this revision.
Abhilash added reviewers: mgrang, dexonsmith, mehdi_amini.
Abhilash added a subscriber: llvm-commits.
Abhilash set the repository for this revision to rL LLVM.

The function operator++ (post increment) in the SmallPtrSetIterator class has been recently changed to handle reverse iterations through command line option. The new change leads to a compilation error when operator++ is used.

The compilation error is:
/mySandBox/llvm/include/llvm/ADT/SmallPtrSet.h: In instantiation of 'llvm::SmallPtrSetIterator<PtrTy> llvm::SmallPtrSetIterator<PtrTy>::operator++(int) [with PtrTy = llvm::User*]':
/mySandBox/llvm/lib/Transforms/Scalar/myopt.cpp:418:32:   required from here
/mySandBox/llvm/include/llvm/ADT/SmallPtrSet.h:295:7: error: no match for 'operator--' (operand type is 'llvm::SmallPtrSetIterator<llvm::User*>')

  --*this;
  ^

make[2]: *** [lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/myopt.cpp.o] Error 1
make[1]: *** [lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/all] Error 2
make: *** [all] Error 2

The compilation fails stating that operator-- is not defined for SmallPtrSetIterator.
I see that, operator++ (post-increment) function internally calls operator++ (pre-increment). Since pre-increment already handles reverse iteration, I feel we do not need to specifically handle reverse iterations in the post-increment function.
This patch contains the corresponding changes.

The differential for the early changes: https://reviews.llvm.org/D26718


Repository:
  rL LLVM

https://reviews.llvm.org/D28134

Files:
  include/llvm/ADT/SmallPtrSet.h


Index: include/llvm/ADT/SmallPtrSet.h
===================================================================
--- include/llvm/ADT/SmallPtrSet.h
+++ include/llvm/ADT/SmallPtrSet.h
@@ -290,12 +290,6 @@
 
   SmallPtrSetIterator operator++(int) {        // Postincrement
     SmallPtrSetIterator tmp = *this;
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
-    if (ReverseIterate<bool>::value) {
-      --*this;
-      return tmp;
-    }
-#endif
     ++*this;
     return tmp;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28134.82582.patch
Type: text/x-patch
Size: 465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161228/aed2c17f/attachment.bin>


More information about the llvm-commits mailing list