[libc++][format] Fixes visit_format_arg.
authorMark de Wever <koraq@xs4all.nl>
Tue, 15 Nov 2022 18:53:30 +0000 (19:53 +0100)
committerMark de Wever <koraq@xs4all.nl>
Tue, 22 Nov 2022 16:48:33 +0000 (17:48 +0100)
commite948cab07d68c240723a12cdc151d09c5cef87ba
tree3fe315a7dc6a863d0f8859560c2bd1d05a9c92e5
parent6052b17aabec2db8ad255eca5632cb128363c604
[libc++][format] Fixes visit_format_arg.

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.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D138052
libcxx/include/__format/format_arg.h
libcxx/include/__format/format_functions.h
libcxx/include/__format/parser_std_format_spec.h
libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.pass.cpp [moved from libcxx/test/libcxx/utilities/format/format.arguments/format.arg/visit_format_arg.pass.cpp with 87% similarity]
libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp [moved from libcxx/test/libcxx/utilities/format/format.arguments/format.args/get.pass.cpp with 86% similarity]