This is an archive of the discontinued LLVM Phabricator instance.

[libc++][spaceship] Implement `operator<=>` for `duration`
ClosedPublic

Authored by H-G-Hristov on Mar 12 2023, 10:32 AM.

Details

Reviewers
Mordante
Group Reviewers
Restricted Project
Commits
rG83542e47644e: [libc++][spaceship] Implement `operator<=>` for `duration`
Summary

Implements parts of P1614R2
Implemented operator<=> for std::chrono::duration

Diff Detail

Event Timeline

H-G-Hristov created this revision.Mar 12 2023, 10:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 12 2023, 10:32 AM
Herald added a subscriber: yaxunl. · View Herald Transcript
H-G-Hristov requested review of this revision.Mar 12 2023, 10:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 12 2023, 10:32 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript

@Mordante I decided to work on <=> for duration and time_point. I see these are assigned to you. Sorry if I am interfering with your plans, feel free to reject this patch if necessary.

H-G-Hristov edited the summary of this revision. (Show Details)Mar 12 2023, 10:36 AM
H-G-Hristov edited the summary of this revision. (Show Details)
H-G-Hristov retitled this revision from [libc++][spaceship] Implement `operator<=>` for `duration` to [WIP][libc++][spaceship] Implement `operator<=>` for `duration`.Mar 12 2023, 10:42 AM
  • Fixed revision
  • Minor tweak
H-G-Hristov retitled this revision from [WIP][libc++][spaceship] Implement `operator<=>` for `duration` to [libc++][spaceship] Implement `operator<=>` for `duration`.Mar 12 2023, 12:35 PM
H-G-Hristov updated this revision to Diff 504467.EditedMar 12 2023, 1:31 PM
  • Missing include
  • Minor tweak

Thanks for working on this! A few comments.

libcxx/docs/Status/SpaceshipProjects.csv
55

Please reach out to us on Discord when you want to work on patches that are assigned to people, me in this case.
Some of the patches in this list already have patches locally that are block for various reasons.

libcxx/test/std/time/time.duration/time.duration.comparisons/compare.three_way.pass.cpp
27

Please add runtime tests too.
I'm quite sure you already used our

test();
static_assert(test());

pattern in other patches. If not I can point you to examples.

66

Nit I think it's safer to use less or greater when comparing floating point values.

Thanks for working on this! A few comments.

Thank you for the review. I'll make sure to contact you first in the future as you recommend.
Sorry if working on this and on time_point D146250 was inappropirate.

  • Updated tests

Thanks for working on this! A few comments.

Thank you for the review. I'll make sure to contact you first in the future as you recommend.
Sorry if working on this and on time_point D146250 was inappropirate.

The main thing we want to avoid is having multiple people working on the same feature.
Somethings something in the list is assigned and appears not to be moving, but there might be reasons.
For example parts of the regex spaceship I've been working on, but it was blocked.

I've not started on duration and timepoint, so feel free to implement them.

If you want to look at other things for the spaceship operator. I *think* not all items of paper P1614 are on the list, specifically the removal of operator!=, which will be automatically generated.
If you want to update the status page with these missing entries it would be very much appreciated.

libcxx/test/std/time/time.duration/time.duration.comparisons/compare.three_way.pass.cpp
29

I would remove the constexpr here, I don't think it's needed.

H-G-Hristov edited the summary of this revision. (Show Details)Mar 17 2023, 5:15 PM
H-G-Hristov edited the summary of this revision. (Show Details)
H-G-Hristov edited the summary of this revision. (Show Details)
H-G-Hristov edited the summary of this revision. (Show Details)
  • Updated tests
H-G-Hristov marked 2 inline comments as done.Mar 18 2023, 5:31 AM

Thanks for working on this! A few comments.

Thank you for the review. I'll make sure to contact you first in the future as you recommend.
Sorry if working on this and on time_point D146250 was inappropirate.

The main thing we want to avoid is having multiple people working on the same feature.
Somethings something in the list is assigned and appears not to be moving, but there might be reasons.
For example parts of the regex spaceship I've been working on, but it was blocked.

I've not started on duration and timepoint, so feel free to implement them.

If you want to look at other things for the spaceship operator. I *think* not all items of paper P1614 are on the list, specifically the removal of operator!=, which will be automatically generated.
If you want to update the status page with these missing entries it would be very much appreciated.

Thank you for this suggestion and the review! Sure, I'll look into P1614R2 and see what I can do when I have time and I'll report back on Discord if necessary.

libcxx/test/std/time/time.duration/time.duration.comparisons/compare.three_way.pass.cpp
66

I hope I resolved it as you requested.

Mordante accepted this revision.Mar 19 2023, 10:47 AM

Thanks! LGTM! IIRC you have commit access right?

This revision is now accepted and ready to land.Mar 19 2023, 10:47 AM

Thanks! LGTM! IIRC you have commit access right?

Thank you for the review!

I should have commit access now but it will be my first attempt.

I've setup SSH keys with my GitHub account.
Would that be the right procedure:

$ cd llvm-project
$ git checkout P1614R2-spaceship-operator-duration
$ arc land

This page describes a git based approach https://llvm.org/docs/Contributing.html

The CI failures appear unrelated. Shall I try to commit now?

H-G-Hristov marked an inline comment as done.Mar 20 2023, 12:19 PM

Thanks! LGTM! IIRC you have commit access right?

Thank you for the review!

I should have commit access now but it will be my first attempt.

I've setup SSH keys with my GitHub account.
Would that be the right procedure:

$ cd llvm-project
$ git checkout P1614R2-spaceship-operator-duration
$ arc land

This page describes a git based approach https://llvm.org/docs/Contributing.html

The CI failures appear unrelated. Shall I try to commit now?

If you created the review you can indeed use arc land. Feel free to commit the change!

If you run into issues best visit Discord, there we're faster to respond.

This revision was landed with ongoing or failed builds.Mar 21 2023, 11:06 AM
This revision was automatically updated to reflect the committed changes.

Rebased

Nice I see committing work!

FYI arc land will automatically rebase for you. There is no need to update the review with these changes.

Rebased

Nice I see committing work!

FYI arc land will automatically rebase for you. There is no need to update the review with these changes.

Thank you very much!

I got two error messages one after another. So I thought that I needed to rebase to fix them:

To GitHub-Zingam:llvm/llvm-project.git
! [rejected] cac4b7737e82 -> main (fetch first)
error: failed to push some refs to 'GitHub-Zingam:llvm/llvm-project.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

LOAD STATE Restoring local state (to ref "hgh/libcxx/P1614R2-spaceship-operator-duration" at commit "1d649b88b388").
USAGE EXCEPTION Push failed! Fix the error and run "arc land" again.

And then:

INTO COMMIT Preparing merge into "main" from remote "origin", at commit "fa6ea7a419f3".

<!> UNKNOWN REVISION
Unable to determine which revision is associated with commit "934d897e41a9".
Use "arc diff" to create or update a revision with this commit, or
"--revision" to force selection of a particular revision.

USAGE EXCEPTION Unable to determine revision for commit "934d897e41a9".

Only after the second rebase and arc diff --update-ing twice the arc land completed successfuly.

Maybe I did something wrong. I hope that it's not a problem.

Rebased

Nice I see committing work!

FYI arc land will automatically rebase for you. There is no need to update the review with these changes.

Thank you very much!

I got two error messages one after another. So I thought that I needed to rebase to fix them:

<snip>

Only after the second rebase and arc diff --update-ing twice the arc land completed successfuly.

Maybe I did something wrong. I hope that it's not a problem.

This happens sometimes, the arc land operation is not atomic. For example

  • you fetch the commits
  • somebody else lands their patch
  • you rebase
  • now your push fails

I normally just do arc land a second time, and occasionally a third time.

This happens sometimes, the arc land operation is not atomic. For example

  • you fetch the commits
  • somebody else lands their patch
  • you rebase
  • now your push fails

I normally just do arc land a second time, and occasionally a third time.

Thanks!