This is an archive of the discontinued LLVM Phabricator instance.

[libc++][chrono] Fixes month inc and dec operations.
ClosedPublic

Authored by Mordante on Jul 17 2023, 11:41 AM.

Details

Reviewers
ldionne
Group Reviewers
Restricted Project
Commits
rGab0d757bcfc4: [libc++][chrono] Fixes month inc and dec operations.
Summary

The operator++, operator++(int), operator--, and operator--(int) need to
change the month to a valid value. The wording is specified in terms of

operator+(const month& x, const months& y) noexcept;

which has the correct behavior. The aforementioned operators instead
used ++/-- on the internal value direction, resulting in incorrect
behaviour.

As a drive-by improve the unit tests:

  • use the typical constexpr test method
  • test whether the month is valid after the operations
  • format the tests

Fixes: https://llvm.org/PR63912

Diff Detail

Event Timeline

Mordante created this revision.Jul 17 2023, 11:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2023, 11:41 AM
Mordante requested review of this revision.Jul 17 2023, 11:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2023, 11:41 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Jul 17 2023, 3:47 PM
This revision is now accepted and ready to land.Jul 17 2023, 3:47 PM
This revision was automatically updated to reflect the committed changes.