This is an archive of the discontinued LLVM Phabricator instance.

[libc++][test] Move `common_input_iterator` to `test_iterators.h`
ClosedPublic

Authored by jloser on Jan 8 2023, 2:12 PM.

Details

Summary

There's a bit of duplication in use of common_input_iterator as noted in
https://reviews.llvm.org/D141216. Lift common_input_iterator into
test_iterators.h.

Diff Detail

Event Timeline

jloser created this revision.Jan 8 2023, 2:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 8 2023, 2:12 PM
jloser requested review of this revision.Jan 8 2023, 2:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 8 2023, 2:12 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
philnik accepted this revision.Jan 8 2023, 2:47 PM

Thanks for the cleanup! LGTM with comment applied and green CI.

libcxx/test/support/test_iterators.h
700
This revision is now accepted and ready to land.Jan 8 2023, 2:47 PM
jloser updated this revision to Diff 487408.Jan 9 2023, 6:34 AM

Rebase and use >= 20 instead of > 17

jloser added inline comments.Jan 9 2023, 6:36 AM
libcxx/test/support/test_iterators.h
700

Just switched to using >= 20. Did we decide on using >= always going forward? I thought there was a discussion within the last 6 months or so, but I forget and am used to the old-school way.

jloser added a comment.Jan 9 2023, 7:16 AM

@philnik mind if I land this? CI isn't green yet due to unrelated issues.

  1. https://reviews.llvm.org/harbormaster/unit/view/5710279/ is fixed with https://reviews.llvm.org/D141284
  1. https://reviews.llvm.org/harbormaster/unit/view/5710280/ is a separate issue — module map problem?
philnik requested changes to this revision.Jan 9 2023, 7:32 AM

@philnik mind if I land this? CI isn't green yet due to unrelated issues.

  1. https://reviews.llvm.org/harbormaster/unit/view/5710279/ is fixed with https://reviews.llvm.org/D141284
  1. https://reviews.llvm.org/harbormaster/unit/view/5710280/ is a separate issue — module map problem?

Given that I've found a small issue I think it would be better to rebase and have a green CI. The second failure is also a problem with includes. I'll fix it myself.

libcxx/test/support/test_iterators.h
700

Yes, we decided to use >=. Not sure when exactly it was, but I think was within this release cycle.

720

@huixie90 This is different in the two versions we have. Is std::iter_reference_t<Base> correct here, or should we just use decltype(auto)?

This revision now requires changes to proceed.Jan 9 2023, 7:32 AM
jloser added inline comments.
libcxx/test/support/test_iterators.h
720

Thanks for calling this out explicitly. I noticed this and stuck with std::iter_reference_t<Base> rather than decltype(auto) that @CaseyCarter fixed in https://reviews.llvm.org/D141216. I think using iter_reference_t is fine, but I'll let others chime in here.

jloser updated this revision to Diff 487444.Jan 9 2023, 7:54 AM

Use decltype(auto) in operator* in case the base type is const qualified

libcxx/test/support/test_iterators.h
720

Actually, based on the rationale in https://reviews.llvm.org/D141216, it seems the problem is when the template type parameter Base is const-qualified, we'd actually need to use std::iter_const_reference_t and not std::iter_reference_t. Given that, it's easier to just always use decltype(auto) and let the deduction happen for us.

But I'm not sure we have a call site or test mandating that behavior, but we should change it to use decltype(auto) AFAICT now. Is that right, @CaseyCarter @huixie90? In any case, I just changed it to use decltype(auto).

huixie90 accepted this revision.Jan 10 2023, 7:01 AM

LGTM with green CI

libcxx/test/support/test_iterators.h
720

Yeah. decltype(auto) looks good to me. It should always be iter_reference_t though. The problem in D141216 was I mistakenly hard coded it to be int*. iter_const_reference_t is just a different thing (with slightly confusing name)

jloser updated this revision to Diff 487859.Jan 10 2023, 9:55 AM

Rebase in quest for the green CI

This revision was not accepted when it landed; it landed in state Needs Review.Jan 10 2023, 4:16 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.

I landed this as the CI failures are unrelated