This is an archive of the discontinued LLVM Phabricator instance.

Compilation error when using operator++ (post increment) function of SmallPtrSetIterator class
ClosedPublic

Authored by Abhilash on Dec 27 2016, 10:24 PM.

Details

Summary

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

Diff Detail

Repository
rL LLVM

Event Timeline

Abhilash updated this revision to Diff 82582.Dec 27 2016, 10:24 PM
Abhilash retitled this revision from to Compilation error when using operator++ (post increment) function of SmallPtrSetIterator class.
Abhilash updated this object.
Abhilash set the repository for this revision to rL LLVM.
Abhilash added a subscriber: llvm-commits.
mehdi_amini edited edge metadata.Dec 27 2016, 10:26 PM

Can you update the unit test?

Abhilash updated this revision to Diff 82588.Dec 28 2016, 4:38 AM
Abhilash edited edge metadata.

ReverseIterationTest has been updated.

mehdi_amini accepted this revision.Dec 28 2016, 11:12 AM
mehdi_amini edited edge metadata.

LGTM. Thanks!

This revision is now accepted and ready to land.Dec 28 2016, 11:12 AM
This revision was automatically updated to reflect the committed changes.