This is an archive of the discontinued LLVM Phabricator instance.

[libc++][format] Improve pointer formatters.
ClosedPublic

Authored by Mordante on Jun 27 2022, 10:39 AM.

Details

Reviewers
ldionne
Group Reviewers
Restricted Project
Commits
rGffe262a198a9: [libc++][format] Improve pointer formatters.
Summary

This changes the implementation of the formatter. Instead of inheriting
from a specialized parser all formatters will use the same generic
parser. This reduces the binary size.

The new parser contains some additional fields only used in the chrono
formatting. Since this doesn't change the size of the parser the fields
are in the generic parser. The parser is designed to fit in 128-bit,
making it cheap to pass by value.

The new format function is a const member function. This isn't required
by the Standard yet, but it will be after LWG-3636 is accepted.
Additionally P2286 adds a formattable concept which requires the member
function to be const qualified in C++23. This paper is likely to be
accepted in the 2022 July plenary.

This is based on D125606. That commit did the groundwork and did similar
changes for the string formatters.

Depends on D128139.

Diff Detail

Event Timeline

Mordante created this revision.Jun 27 2022, 10:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2022, 10:39 AM
Mordante requested review of this revision.Jun 27 2022, 10:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2022, 10:39 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Jun 28 2022, 9:00 AM
ldionne added a subscriber: ldionne.

LGTM, I don't have much to add here.

This revision is now accepted and ready to land.Jun 28 2022, 9:00 AM
Mordante updated this revision to Diff 440854.Jun 28 2022, 10:25 PM

Rebased to test CI.

This revision was automatically updated to reflect the committed changes.
libcxx/include/__format/parser_std_format_spec.h