This is an archive of the discontinued LLVM Phabricator instance.

Correctly instantiate `iterator_adaptor_base` when defining `pointer_iterator`
ClosedPublic

Authored by ecstatic-morse on Nov 10 2018, 3:19 AM.

Details

Summary

The definition of pointer_iterator omits what should be a iterator_traits::<>::iterator_category parameter from iterator_adaptor_base. As a result, iterators based on pointer_iterator always have defaulted value types and the wrong iterator category.

The definition of pointee_iterator just a few lines above does this correctly.

This resolves bug 39617.

Diff Detail

Repository
rL LLVM

Event Timeline

ecstatic-morse created this revision.Nov 10 2018, 3:19 AM

Could you add a test case? (probably a static_assert in unittests/ADT/iterator.cpp or something like that)

(oh, also, looks like this is intended as a fix for PR39617? Good to mention that in reviews/commits - also, there's no need to file a bug before sending a patch. You can skip the bug & send the patch instead if you like!

Added tests for pointer_iterator and pointee_iterator to ensure that the category of the underlying iterator is forwarded correctly.

ecstatic-morse edited the summary of this revision. (Show Details)Nov 13 2018, 8:07 PM

I added tests via static_assert and updated the description to mention the bug report.

Sorry, I wasn't sure if I was going to go to the trouble of setting up phabricator when I filed the bug.

dblaikie accepted this revision.Nov 13 2018, 9:02 PM

Looks good - thanks! Do you need me to commit this for you? (Or do you have commit rights & can commit it yourself)

This revision is now accepted and ready to land.Nov 13 2018, 9:02 PM
ecstatic-morse added a comment.EditedNov 13 2018, 10:21 PM

I don't have commit rights. Could you commit this for me? I'm new here BTW.

ecstatic-morse edited the summary of this revision. (Show Details)Nov 13 2018, 10:25 PM
This revision was automatically updated to reflect the committed changes.