This is an archive of the discontinued LLVM Phabricator instance.

[libc++][format] Adds bool formatter.
ClosedPublic

Authored by Mordante on Jun 3 2021, 10:59 PM.

Details

Reviewers
curdeius
ldionne
miscco
vitaut
Group Reviewers
Restricted Project
Commits
rG7fb9f99f3bb6: [libc++][format] Adds bool formatter.
Summary

Implements the formatter for Boolean types.
[format.formatter.spec]/2.3
For each charT, for each cv-unqualified arithmetic type ArithmeticT other
than char, wchar_t, char8_t, char16_t, or char32_t, a specialization

template<> struct formatter<ArithmeticT, charT>;

This removes the stub implemented in D96664.

Implements parts of:

  • P0645 Text Formatting
  • P1652 Printf corner cases in std::format

Completes:

  • P1868 width: clarifying units of width and precision in std::format

Diff Detail

Event Timeline

Mordante created this revision.Jun 3 2021, 10:59 PM
Mordante requested review of this revision.Jun 3 2021, 10:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2021, 10:59 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Mordante edited the summary of this revision. (Show Details)Jun 5 2021, 4:18 AM
Mordante added reviewers: curdeius, ldionne, miscco, vitaut.
Mordante planned changes to this revision.Jun 27 2021, 5:38 AM

This patch will be updated due to changes in other patches in the series.

Mordante updated this revision to Diff 355638.Jun 30 2021, 11:18 AM
Mordante edited the summary of this revision. (Show Details)

Rebased and updated:

  • Address some changes from previous patches
  • Minor cleanups and comment improvements
  • Added a module map
Mordante added inline comments.
libcxx/test/std/utilities/format/format.functions/tests.inc
493

Remove this replacement with the method @Quuxplusone suggested in D96664.

Mordante updated this revision to Diff 357286.Jul 8 2021, 11:04 AM

Rebase.
Use the method for '\0' in the tests as suggested in D96664.

vitaut added inline comments.Jul 18 2021, 6:29 AM
libcxx/test/std/utilities/format/format.functions/tests.inc
455–456

As in D103466: . alone is not a prevision field.

Mordante marked an inline comment as done.Jul 18 2021, 10:34 AM
Mordante added inline comments.
libcxx/test/std/utilities/format/format.functions/tests.inc
455–456

Like there the message has changed.

Mordante updated this revision to Diff 359637.Jul 18 2021, 10:59 AM
Mordante marked an inline comment as done.

Rebase
Use private module headers
Guard unit tests for implementation details

Mordante added inline comments.Jul 20 2021, 10:14 AM
libcxx/include/__format/formatter_bool.h
52
Mordante planned changes to this revision.Jul 30 2021, 4:22 AM

Needs updates due to changes in D103368.

Mordante updated this revision to Diff 364511.Aug 5 2021, 9:35 AM

Rebased and adjusted for chandges in main
Retarget for LLVM 14.
s/_LIBCPP_INLINE_VISIBILITY/_LIBCPP_HIDE_FROM_ABI/
Generate private module tests

Two minor comments inline, otherwise LGTM.

libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
257

This line is the same as above. Did you mean to test false here?

273–275

Maybe also test that the default alignment is left?

Mordante marked 2 inline comments as done.Aug 8 2021, 2:09 AM

Thanks for the review!

libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
257

Indeed, seems a copy-paste error.

Mordante updated this revision to Diff 365008.Aug 8 2021, 2:09 AM
Mordante marked an inline comment as done.

Addresses review comments.

Mordante updated this revision to Diff 370739.Sep 4 2021, 7:33 AM

Rebased and adjusted for changes in main
s/_LIBCPP_INLINE_VISIBILITY/_LIBCPP_HIDE_FROM_ABI/

Mordante updated this revision to Diff 372974.Sep 16 2021, 9:18 AM

Remove the unneeded _LIBCPP_PUSH_MACROS.
Updated code to changes earlier in the patch series.

ldionne accepted this revision.Oct 6 2021, 12:58 PM
This revision is now accepted and ready to land.Oct 6 2021, 12:58 PM
This revision was automatically updated to reflect the committed changes.