This is an archive of the discontinued LLVM Phabricator instance.

[libc++][format] Fixes visit_format_arg.
ClosedPublic

Authored by Mordante on Nov 15 2022, 11:38 AM.

Details

Reviewers
ldionne
vitaut
Group Reviewers
Restricted Project
Commits
rGe948cab07d68: [libc++][format] Fixes visit_format_arg.
Summary

The Standard specifies which types are stored in the basic_format_arg
"variant" and which types are stored as a handle. Libc++ stores
additional types in the "variant". During a reflector discussion
@jwakely mention this is user observable; visit_format_arg uses the type
instead of a handle as argument.

This optimization is useful and will probably be used for other small
types in the future. To be conferment the visitor creates a handle and
uses that as argument. There is a second visitor so the formatter can
still directly access the 128-bit integrals.

The test for the visitor and get has been made public too, there is no
reason not too. The 128-bit integral types are required by the Standard,
when they are available.

Diff Detail

Event Timeline

Mordante created this revision.Nov 15 2022, 11:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 15 2022, 11:38 AM
Mordante requested review of this revision.Nov 15 2022, 11:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 15 2022, 11:38 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Nov 15 2022, 11:44 AM
ldionne added inline comments.
libcxx/include/__format/format_arg.h
277–278
282–294

That would reduce duplication below?

libcxx/include/__format/format_functions.h
187
libcxx/include/__format/parser_std_format_spec.h
77

Qualify the call for ADL?

This revision is now accepted and ready to land.Nov 15 2022, 11:44 AM
Mordante marked 4 inline comments as done.Nov 21 2022, 11:06 AM

Thanks for the review!

libcxx/include/__format/format_arg.h
282–294

I was considering something similar, but was doubting whether it would be a good idea.

Mordante updated this revision to Diff 476954.Nov 21 2022, 11:13 AM
Mordante marked an inline comment as done.

Rebased and addresses review comments.

This revision was automatically updated to reflect the committed changes.