Page MenuHomePhabricator

[libc++][chrono] Implements formatter day.
ClosedPublic

Authored by Mordante on Jun 25 2022, 2:39 AM.

Details

Reviewers
ldionne
vitaut
Group Reviewers
Restricted Project
Commits
rGe5d2d3eafbb3: [libc++][chrono] Implements formatter day.
Summary

This implements the enabled specializaton
template<class charT> struct formatter<chrono::day, charT>;

and
template<class charT, class traits>

basic_ostream<charT, traits>&
  operator<<(basic_ostream<charT, traits>& os, const day& d);

Implements:

  • LWG 3241 chrono-spec grammar ambiguity in §[time.format]

Partially implements:

  • P1361 Integration of chrono with text formatting

Diff Detail

Unit TestsFailed

TimeTest
15,110 mslibcxx CI AIX (32-bit) > ibm-libc++-shared-cfg-in.std/time/time_syn::formatter.day.pass.cpp
Script: -- : 'COMPILED WITH'; /opt/clang/clang-15-c745f2ce6c03bc6d1e59cac69cc15923d4400191/bin/clang++ /scratch/powerllvm/cpap8008/llvm-project/libcxx-ci/libcxx/test/std/time/time.syn/formatter.day.pass.cpp --target=powerpc-ibm-aix -nostdinc++ -D__LIBC_NO_CPP_MATH_OVERLOADS__ -I /scratch/powerllvm/cpap8008/llvm-project/libcxx-ci/build/aix/include/c++/v1 -I /scratch/powerllvm/cpap8008/llvm-project/libcxx-ci/libcxx/test/support -pthread -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -nostdlib++ -L /scratch/powerllvm/cpap8008/llvm-project/libcxx-ci/build/aix/lib -lc++ -lc++abi -latomic -Wl,-bbigtoc -o /scratch/powerllvm/cpap8008/llvm-project/libcxx-ci/build/aix/test/std/time/time.syn/Output/formatter.day.pass.cpp.dir/t.tmp.exe
14,870 mslibcxx CI AIX (64-bit) > ibm-libc++-shared-cfg-in.std/time/time_syn::formatter.day.pass.cpp
Script: -- : 'COMPILED WITH'; /opt/clang/clang-15-c745f2ce6c03bc6d1e59cac69cc15923d4400191/bin/clang++ /scratch/powerllvm/cpap8009/llvm-project/libcxx-ci/libcxx/test/std/time/time.syn/formatter.day.pass.cpp --target=powerpc64-ibm-aix -nostdinc++ -D__LIBC_NO_CPP_MATH_OVERLOADS__ -I /scratch/powerllvm/cpap8009/llvm-project/libcxx-ci/build/aix/include/c++/v1 -I /scratch/powerllvm/cpap8009/llvm-project/libcxx-ci/libcxx/test/support -pthread -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -nostdlib++ -L /scratch/powerllvm/cpap8009/llvm-project/libcxx-ci/build/aix/lib -lc++ -lc++abi -latomic -Wl,-bbigtoc -o /scratch/powerllvm/cpap8009/llvm-project/libcxx-ci/build/aix/test/std/time/time.syn/Output/formatter.day.pass.cpp.dir/t.tmp.exe
4,090 mslibcxx CI Apple back-deployment macosx10.15 > apple-libc++-backdeployment-cfg-in.libcxx::modules_include.sh.cpp
Script: -- : 'RUN: at line 44'; rm -rf /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/y10-8-macminivault-com/llvm-project/libcxx-ci/build/apple-system-backdeployment-10.15/test/libcxx/Output/modules_include.sh.cpp.dir/t.tmp
4,490 mslibcxx CI Apple back-deployment macosx10.9 > apple-libc++-backdeployment-cfg-in.libcxx::modules_include.sh.cpp
Script: -- : 'RUN: at line 44'; rm -rf /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/y10-8-macminivault-com/llvm-project/libcxx-ci/build/apple-system-backdeployment-10.9/test/libcxx/Output/modules_include.sh.cpp.dir/t.tmp
1,260 mslibcxx CI Apple back-deployment macosx11.0 arm64 > apple-libc++-backdeployment-cfg-in.libcxx::modules_include.sh.cpp
Script: -- : 'RUN: at line 44'; rm -rf /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/f1-1-macminivault-com/llvm-project/libcxx-ci/build/apple-system-backdeployment-11.0/test/libcxx/Output/modules_include.sh.cpp.dir/t.tmp
View Full Test Results (6 Failed)

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Mordante marked 5 inline comments as done.Jul 17 2022, 10:59 PM
Mordante added inline comments.
libcxx/include/__chrono/formatter.h
61–62

@vitaut suggested something similar. I like this approach better, modulo the trailing comma.

Mordante updated this revision to Diff 445390.Jul 17 2022, 11:00 PM
Mordante marked an inline comment as done.

Addresses review comments and attempts to fix the CI.

Mordante updated this revision to Diff 445529.Jul 18 2022, 8:59 AM

Attempt to fix CI.

ldionne added inline comments.Jul 26 2022, 9:48 AM
libcxx/include/__chrono/formatter.h
52

I think it might be important to use = tm() to get proper zero initialization, otherwise some members might be left uninitialized.

ldionne requested changes to this revision.Aug 9 2022, 9:38 AM
ldionne added inline comments.
libcxx/docs/Status/Cxx20Issues.csv
178
libcxx/include/__chrono/formatter.h
51

I don't think this should be in formatter.h or in the __formatter namespace. This seems generally useful, don't you think? I might suggest something like __chrono/convert_to_tm.h to mirror convert_to_timespec.h.

libcxx/include/__chrono/statically_widen.h
14
36

Equivalent since _LIBCPP_STATICALLY_WIDEN should only be used in our namespace, but still more idiomatic since this is a macro.

46

Ditto.

libcxx/include/module.modulemap.in
445

This shouldn't be here.

460

Not needed.

464

Not needed.

libcxx/test/libcxx/utilities/format/format.formatter/format.formatter.spec/formattable.compile.pass.cpp
146

I would prefer instead:

// The chrono formatters require localization support because {XXXXXXXX}
#ifndef TEST_HAS_NO_LOCALIZATION
  assert_is_formattable<std::chrono::day, CharT>();
#endif

We don't need to test that it's not formattable when localization is disabled.

libcxx/test/std/time/time.cal/time.cal.day/time.cal.day.nonmembers/ostream.pass.cpp
35–37

Leftover?

90–91

Leftover?

libcxx/test/std/time/time.syn/formatter_tests.h
8

Missing header guard.

61–67
89–93

I would suggest putting that above so it doesn't clutter the body of the function so much. You could use something like using Context = ..... The same comment applies above too.

104–105
libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/types.compile.pass.cpp
119

Same comment as above for TEST_HAS_NO_LOCALIZATION.

This revision now requires changes to proceed.Aug 9 2022, 9:38 AM
Mordante updated this revision to Diff 451231.Aug 9 2022, 12:05 PM
Mordante marked 16 inline comments as done.
  • Rebased
  • Addresses most review comments
  • Qualify several calls
  • Comment out some transitive includes that caused include cycles
Mordante planned changes to this revision.Aug 9 2022, 12:05 PM
Mordante updated this revision to Diff 451474.Aug 10 2022, 8:04 AM

Adds work-around to test CI.

Mordante updated this revision to Diff 451552.Aug 10 2022, 10:46 AM

Attempts to fix Windows build.
Adds convert_to_tm private header.

Mordante updated this revision to Diff 452413.Aug 13 2022, 5:00 AM

Fixes CI.

Mordante updated this revision to Diff 452491.Aug 14 2022, 1:05 AM

Attempts to fix CI.

Mordante updated this revision to Diff 452538.Aug 14 2022, 10:22 AM

Tests failing CI.

Mordante updated this revision to Diff 452696.Aug 15 2022, 8:55 AM

Attempt to fix the CI.

Mordante updated this revision to Diff 452727.Aug 15 2022, 10:14 AM

Remove more parts of the experimental library.

Mordante updated this revision to Diff 452756.Aug 15 2022, 11:41 AM

Another attempt to fix the CI.

Notes from live review:

  1. Let's move transitive includes to the end of each file to break cycles
  2. Let's guard transitive includes on standard versions

Also, please update this to its final form and we can take a look at the Windows DLL errors.

Mordante updated this revision to Diff 453056.Aug 16 2022, 10:01 AM

Restore CI and try to fix circular dependencies.

Mordante updated this revision to Diff 453074.Aug 16 2022, 11:02 AM

Disable a test and test CI

Mordante added inline comments.Aug 25 2022, 8:51 AM
libcxx/include/chrono
732

As tested in D132284.

736

The header can be unconditional again.

Mordante updated this revision to Diff 457342.Thu, Sep 1, 11:59 AM

Rebased and integrated all upstream changes.

Mordante updated this revision to Diff 457607.Fri, Sep 2, 8:31 AM

Attempts to fix CI.

Mordante updated this revision to Diff 457787.Sat, Sep 3, 5:58 AM

Rebased and some final polishing.

ldionne accepted this revision.Tue, Sep 6, 8:48 AM
ldionne added inline comments.
libcxx/include/chrono
731

Is this comment still required? I think it is no longer needed since we inlined the destructor of format_error to workaround Windows DLL issues.

This revision is now accepted and ready to land.Tue, Sep 6, 8:48 AM
Mordante marked 3 inline comments as done.Wed, Sep 7, 9:43 AM
Mordante added inline comments.
libcxx/include/chrono
731

No it's not, removed it.

This revision was automatically updated to reflect the committed changes.
Mordante marked an inline comment as done.