[all-commits] [llvm/llvm-project] ab0d75: [libc++][chrono] Fixes month inc and dec operations.

Mark de Wever via All-commits all-commits at lists.llvm.org
Tue Jul 18 08:33:56 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ab0d757bcfc486ac6ed8ba69d4e630feda2b6ab7
      https://github.com/llvm/llvm-project/commit/ab0d757bcfc486ac6ed8ba69d4e630feda2b6ab7
  Author: Mark de Wever <koraq at xs4all.nl>
  Date:   2023-07-18 (Tue, 18 Jul 2023)

  Changed paths:
    M libcxx/include/__chrono/month.h
    M libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.members/decrement.pass.cpp
    M libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.members/increment.pass.cpp
    M libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.members/plus_minus_equal.pass.cpp
    M libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.nonmembers/minus.pass.cpp
    M libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.nonmembers/plus.pass.cpp

  Log Message:
  -----------
  [libc++][chrono] Fixes month inc and dec operations.

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

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D155504




More information about the All-commits mailing list