[PATCH] D144331: [libc++][format] Implements formatter thread::id.
manojgupta added a comment. Thanks, sent a patch to gdb at https://sourceware.org/pipermail/gdb-patches/2023-April/198870.html Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
tahonermann added a comment. > It adds an include of #include <__format/formatter_integral.h> which ends up > including which has internal definitions of isupper/islower causing > clang to complain. > > Any suggestions on what would be the right fix here? It sounds like `safe-ctype.h` should also add a `#include` of `` (when compiling as C++) to avoid interfering with the `std::locale` variants of those functions. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
manojgupta added a comment. Hmm, looking deeper, gdb (actually binutils), is doing something weird. https://github.com/bminor/binutils-gdb/blob/master/include/safe-ctype.h /* Prevent the users of safe-ctype.h from accidently using the routines from ctype.h. Initially, the approach was to produce an error when detecting that ctype.h has been included. But this was causing trouble as ctype.h might get indirectly included as a result of including another system header (for instance gnulib's stdint.h). So we include ctype.h here and then immediately redefine its macros. */ #include #undef isalpha #define isalpha(c) do_not_use_isalpha_with_safe_ctype #undef isalnum #define isalnum(c) do_not_use_isalnum_with_safe_ctype So any use of isupper/islower etc will cause an error. Why this patch is triggering it: It adds an include of #include <__format/formatter_integral.h> which ends up including which has internal definitions of isupper/islower causing clang to complain. Any suggestions on what would be the right fix here? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
tahonermann added subscribers: cor3ntin, tahonermann. tahonermann added a comment. Adding Corentin for awareness. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
manojgupta added a comment. I have opened a bug at issuetracker.google.com/issues/277967395 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
manojgupta added a comment. Just a heads up, with this change, we are hitting issues in building gdb. Appreciate any ideas on what is wrong. aarch64-cros-linux-gnu-clang++ -x c++-I. -I. -I./config -DLOCALEDIR="\"/usr/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber -I./../gnulib/import -I../gnulib/import -I./.. -I.. -DTUI=1-I./.. -pthread -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-error=maybe-uninitialized -Wno-mismatched-tags -Wno-error=deprecated-register -Wsuggest-override -Wimplicit-fallthrough=3 -Wduplicated-cond -Wshadow=local -Wdeprecated-copy -Wdeprecated-copy-dtor -Wredundant-move -Wmissing-declarations -Wmissing-prototypes -Wstrict-null-sentinel -Wformat -Wformat-nonliteral -Os -pipe -march=armv8-a+crc+crypto -ftree-vectorize -g -ffunction-sections -fdata-sections -c -o minsyms.o -MT minsyms.o -MMD -MP -MF ./.deps/minsyms.Tpo minsyms.c In file included from minsyms.c:56: In file included from ./../gdbsupport/parallel-for.h:25: In file included from /usr/bin/../include/c++/v1/thread:100: In file included from /usr/bin/../include/c++/v1/__format/formatter_integral.h:32: In file included from /usr/bin/../include/c++/v1/locale:203: /usr/bin/../include/c++/v1/__locale:600:5: error: '__abi_tag__' attribute only applies to structs, variables, functions, and namespaces _LIBCPP_INLINE_VISIBILITY ^ /usr/bin/../include/c++/v1/__config:668:37: note: expanded from macro '_LIBCPP_INLINE_VISIBILITY' # define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI ^ /usr/bin/../include/c++/v1/__config:647:26: note: expanded from macro '_LIBCPP_HIDE_FROM_ABI' __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER ^ In file included from minsyms.c:56: In file included from ./../gdbsupport/parallel-for.h:25: In file included from /usr/bin/../include/c++/v1/thread:100: In file included from /usr/bin/../include/c++/v1/__format/formatter_integral.h:32: In file included from /usr/bin/../include/c++/v1/locale:203: /usr/bin/../include/c++/v1/__locale:601:37: error: expected ';' at end of declaration list char_type toupper(char_type __c) const ^ /usr/bin/../include/c++/v1/__locale:607:48: error: too many arguments provided to function-like macro invocation const char_type* toupper(char_type* __low, const char_type* __high) const ^ ./../include/safe-ctype.h:146:9: note: macro 'toupper' defined here #define toupper(c) do_not_use_toupper_with_safe_ctype ^ In file included from minsyms.c:56: In file included from ./../gdbsupport/parallel-for.h:25: In file included from /usr/bin/../include/c++/v1/thread:100: In file included from /usr/bin/../include/c++/v1/__format/formatter_integral.h:32: In file included from /usr/bin/../include/c++/v1/locale:203: /usr/bin/../include/c++/v1/__locale:619:48: error: too many arguments provided to function-like macro invocation const char_type* tolower(char_type* __low, const char_type* __high) const ^ ./../include/safe-ctype.h:148:9: note: macro 'tolower' defined here #define tolower(c) do_not_use_tolower_with_safe_ctype ^ Contents of __locale at line 600: _LIBCPP_INLINE_VISIBILITY char_type toupper(char_type __c) const { return do_toupper(__c); } Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
Mordante marked an inline comment as done. Mordante added inline comments. Comment at: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp:49 + std::same_as auto it = formatter.parse(parse_ctx); + assert(it == fmt.end() - (!fmt.empty() && fmt.back() == '}')); +} ldionne wrote: > This seems a bit clever to me. Can we pass the expected end position as a > parameter to the function explicitly? So this would look like `it == > fmt.begin() + offset`. If you have this pattern in other places, I'm OK to > land the patch as-is but we could have a simple patch to change all of them. See D147885 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG88622aabf107: [libc++][format] Implements formatter thread::id. (authored by Mordante). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 Files: libcxx/docs/FeatureTestMacroTable.rst libcxx/docs/ReleaseNotes.rst libcxx/docs/Status/Cxx2b.rst libcxx/docs/Status/Cxx2bPapers.csv libcxx/docs/Status/FormatPaper.csv libcxx/include/__format/parser_std_format_spec.h libcxx/include/__threading_support libcxx/include/thread libcxx/include/version libcxx/test/libcxx/transitive_includes/cxx03.csv libcxx/test/libcxx/transitive_includes/cxx11.csv libcxx/test/libcxx/transitive_includes/cxx14.csv libcxx/test/libcxx/transitive_includes/cxx17.csv libcxx/test/libcxx/transitive_includes/cxx20.csv libcxx/test/libcxx/transitive_includes/cxx2b.csv libcxx/test/std/language.support/support.limits/support.limits.general/thread.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.format.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.tests.h libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.vformat.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp libcxx/utils/generate_feature_test_macro_components.py Index: libcxx/utils/generate_feature_test_macro_components.py === --- libcxx/utils/generate_feature_test_macro_components.py +++ libcxx/utils/generate_feature_test_macro_components.py @@ -327,6 +327,13 @@ "test_suite_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", "libcxx_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", "unimplemented": True, + }, { +"name": "__cpp_lib_formatters", +"values": { "c++2b": 202302 }, +"headers": ["stacktrace", "thread"], +"test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", +"libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", +"unimplemented": True, }, { "name": "__cpp_lib_forward_like", "values": { "c++2b": 202207 }, Index: libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp === --- libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp +++ libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp @@ -175,7 +175,8 @@ // Tests for P1636 Formatters for library types // // The paper hasn't been voted in so currently all formatters are disabled. -// TODO validate whether the test is correct after the paper has been accepted. +// Note the paper has been abandoned, the types are kept since other papers may +// introduce these formatters. template void test_P1636() { assert_is_not_formattable, CharT>(); @@ -191,7 +192,7 @@ assert_is_not_formattable, CharT>(); #endif #ifndef TEST_HAS_NO_THREADS - assert_is_not_formattable(); + assert_is_formattable(); #endif assert_is_not_formattable, CharT>(); } Index: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp === --- libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp +++ libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp @@ -9,6 +9,9 @@ // UNSUPPORTED: no-threads // UNSUPPORTED: no-localization +// TODO FMT This test should not require std::to_chars(floating-point) +// XFAIL: availability-fp_to_chars-missing + // // class thread::id @@ -18,16 +21,38 @@ // operator<<(basic_ostream& out, thread::id id); #include +#include #include #include +#include "make_string.h" #include "test_macros.h" -int main(int, char**) -{ -std::thread::id id0 = std::this_thread::get_id(); -std::ostringstream os; -os << id0; +template +static void test() { + std::thread::id id0 = std::this_thread::get_id(); + std::basic_ostringstream os; + os << id0; + +#if TEST_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) + // C++23 added a formatter
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
Mordante updated this revision to Diff 511875. Mordante added a comment. CI fixes Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 Files: libcxx/docs/FeatureTestMacroTable.rst libcxx/docs/ReleaseNotes.rst libcxx/docs/Status/Cxx2b.rst libcxx/docs/Status/Cxx2bPapers.csv libcxx/docs/Status/FormatPaper.csv libcxx/include/__format/parser_std_format_spec.h libcxx/include/__threading_support libcxx/include/thread libcxx/include/version libcxx/test/libcxx/transitive_includes/cxx03.csv libcxx/test/libcxx/transitive_includes/cxx11.csv libcxx/test/libcxx/transitive_includes/cxx14.csv libcxx/test/libcxx/transitive_includes/cxx17.csv libcxx/test/libcxx/transitive_includes/cxx20.csv libcxx/test/libcxx/transitive_includes/cxx2b.csv libcxx/test/std/language.support/support.limits/support.limits.general/thread.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.format.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.tests.h libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.vformat.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp libcxx/utils/generate_feature_test_macro_components.py Index: libcxx/utils/generate_feature_test_macro_components.py === --- libcxx/utils/generate_feature_test_macro_components.py +++ libcxx/utils/generate_feature_test_macro_components.py @@ -327,6 +327,13 @@ "test_suite_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", "libcxx_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", "unimplemented": True, + }, { +"name": "__cpp_lib_formatters", +"values": { "c++2b": 202302 }, +"headers": ["stacktrace", "thread"], +"test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", +"libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", +"unimplemented": True, }, { "name": "__cpp_lib_forward_like", "values": { "c++2b": 202207 }, Index: libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp === --- libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp +++ libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp @@ -175,7 +175,8 @@ // Tests for P1636 Formatters for library types // // The paper hasn't been voted in so currently all formatters are disabled. -// TODO validate whether the test is correct after the paper has been accepted. +// Note the paper has been abandoned, the types are kept since other papers may +// introduce these formatters. template void test_P1636() { assert_is_not_formattable, CharT>(); @@ -191,7 +192,7 @@ assert_is_not_formattable, CharT>(); #endif #ifndef TEST_HAS_NO_THREADS - assert_is_not_formattable(); + assert_is_formattable(); #endif assert_is_not_formattable, CharT>(); } Index: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp === --- libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp +++ libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp @@ -9,6 +9,9 @@ // UNSUPPORTED: no-threads // UNSUPPORTED: no-localization +// TODO FMT This test should not require std::to_chars(floating-point) +// XFAIL: availability-fp_to_chars-missing + // // class thread::id @@ -18,16 +21,38 @@ // operator<<(basic_ostream& out, thread::id id); #include +#include #include #include +#include "make_string.h" #include "test_macros.h" -int main(int, char**) -{ -std::thread::id id0 = std::this_thread::get_id(); -std::ostringstream os; -os << id0; +template +static void test() { + std::thread::id id0 = std::this_thread::get_id(); + std::basic_ostringstream os; + os << id0; + +#if TEST_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) + // C++23 added a formatter specialization for thread::id. + // This changed the requirement of ostream to have a + // [thread.thread.id]/2 + // The text representation for the
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
Mordante updated this revision to Diff 511865. Mordante added a comment. Herald added a subscriber: krytarowski. CI fixes. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 Files: libcxx/docs/FeatureTestMacroTable.rst libcxx/docs/ReleaseNotes.rst libcxx/docs/Status/Cxx2b.rst libcxx/docs/Status/Cxx2bPapers.csv libcxx/docs/Status/FormatPaper.csv libcxx/include/__format/parser_std_format_spec.h libcxx/include/__threading_support libcxx/include/thread libcxx/include/version libcxx/test/libcxx/transitive_includes/cxx03.csv libcxx/test/libcxx/transitive_includes/cxx11.csv libcxx/test/libcxx/transitive_includes/cxx14.csv libcxx/test/libcxx/transitive_includes/cxx17.csv libcxx/test/libcxx/transitive_includes/cxx20.csv libcxx/test/libcxx/transitive_includes/cxx2b.csv libcxx/test/std/language.support/support.limits/support.limits.general/thread.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.format.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.tests.h libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.vformat.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp libcxx/utils/generate_feature_test_macro_components.py Index: libcxx/utils/generate_feature_test_macro_components.py === --- libcxx/utils/generate_feature_test_macro_components.py +++ libcxx/utils/generate_feature_test_macro_components.py @@ -327,6 +327,13 @@ "test_suite_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", "libcxx_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", "unimplemented": True, + }, { +"name": "__cpp_lib_formatters", +"values": { "c++2b": 202302 }, +"headers": ["stacktrace", "thread"], +"test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", +"libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", +"unimplemented": True, }, { "name": "__cpp_lib_forward_like", "values": { "c++2b": 202207 }, Index: libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp === --- libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp +++ libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp @@ -175,7 +175,8 @@ // Tests for P1636 Formatters for library types // // The paper hasn't been voted in so currently all formatters are disabled. -// TODO validate whether the test is correct after the paper has been accepted. +// Note the paper has been abandoned, the types are kept since other papers may +// introduce these formatters. template void test_P1636() { assert_is_not_formattable, CharT>(); @@ -191,7 +192,7 @@ assert_is_not_formattable, CharT>(); #endif #ifndef TEST_HAS_NO_THREADS - assert_is_not_formattable(); + assert_is_formattable(); #endif assert_is_not_formattable, CharT>(); } Index: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp === --- libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp +++ libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp @@ -9,6 +9,10 @@ // UNSUPPORTED: no-threads // UNSUPPORTED: no-localization +// TODO FMT This test should not require std::to_chars(floating-point) +// This test requires std::to_chars(floating-point), which is in the dylib +// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0}} + // // class thread::id @@ -18,16 +22,38 @@ // operator<<(basic_ostream& out, thread::id id); #include +#include #include #include +#include "make_string.h" #include "test_macros.h" -int main(int, char**) -{ -std::thread::id id0 = std::this_thread::get_id(); -std::ostringstream os; -os << id0; +template +static void test() { + std::thread::id id0 = std::this_thread::get_id(); + std::basic_ostringstream os; + os << id0; + +#if TEST_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) +
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
Mordante updated this revision to Diff 511715. Mordante added a comment. CI fixes Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 Files: libcxx/docs/FeatureTestMacroTable.rst libcxx/docs/ReleaseNotes.rst libcxx/docs/Status/Cxx2b.rst libcxx/docs/Status/Cxx2bPapers.csv libcxx/docs/Status/FormatPaper.csv libcxx/include/__format/parser_std_format_spec.h libcxx/include/__threading_support libcxx/include/thread libcxx/include/version libcxx/test/libcxx/transitive_includes/cxx03.csv libcxx/test/libcxx/transitive_includes/cxx11.csv libcxx/test/libcxx/transitive_includes/cxx14.csv libcxx/test/libcxx/transitive_includes/cxx17.csv libcxx/test/libcxx/transitive_includes/cxx20.csv libcxx/test/libcxx/transitive_includes/cxx2b.csv libcxx/test/std/language.support/support.limits/support.limits.general/thread.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.format.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.tests.h libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.vformat.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp libcxx/utils/generate_feature_test_macro_components.py Index: libcxx/utils/generate_feature_test_macro_components.py === --- libcxx/utils/generate_feature_test_macro_components.py +++ libcxx/utils/generate_feature_test_macro_components.py @@ -327,6 +327,13 @@ "test_suite_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", "libcxx_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", "unimplemented": True, + }, { +"name": "__cpp_lib_formatters", +"values": { "c++2b": 202302 }, +"headers": ["stacktrace", "thread"], +"test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", +"libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", +"unimplemented": True, }, { "name": "__cpp_lib_forward_like", "values": { "c++2b": 202207 }, Index: libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp === --- libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp +++ libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp @@ -175,7 +175,8 @@ // Tests for P1636 Formatters for library types // // The paper hasn't been voted in so currently all formatters are disabled. -// TODO validate whether the test is correct after the paper has been accepted. +// Note the paper has been abandoned, the types are kept since other papers may +// introduce these formatters. template void test_P1636() { assert_is_not_formattable, CharT>(); @@ -191,7 +192,7 @@ assert_is_not_formattable, CharT>(); #endif #ifndef TEST_HAS_NO_THREADS - assert_is_not_formattable(); + assert_is_formattable(); #endif assert_is_not_formattable, CharT>(); } Index: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp === --- libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp +++ libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp @@ -18,16 +18,38 @@ // operator<<(basic_ostream& out, thread::id id); #include +#include #include #include +#include "make_string.h" #include "test_macros.h" -int main(int, char**) -{ -std::thread::id id0 = std::this_thread::get_id(); -std::ostringstream os; -os << id0; +template +static void test() { + std::thread::id id0 = std::this_thread::get_id(); + std::basic_ostringstream os; + os << id0; + +#if TEST_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) + // C++23 added a formatter specialization for thread::id. + // This changed the requirement of ostream to have a + // [thread.thread.id]/2 + // The text representation for the character type charT of an object of + // type thread::id is an unspecified sequence of charT ... + // This definition is used for both streaming and formatting. + // + // Test whether the output is identical. +
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
Mordante updated this revision to Diff 511709. Mordante added a comment. CI fixes. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 Files: libcxx/docs/FeatureTestMacroTable.rst libcxx/docs/ReleaseNotes.rst libcxx/docs/Status/Cxx2b.rst libcxx/docs/Status/Cxx2bPapers.csv libcxx/docs/Status/FormatPaper.csv libcxx/include/__format/parser_std_format_spec.h libcxx/include/__threading_support libcxx/include/thread libcxx/include/version libcxx/test/libcxx/transitive_includes/cxx03.csv libcxx/test/libcxx/transitive_includes/cxx11.csv libcxx/test/libcxx/transitive_includes/cxx14.csv libcxx/test/libcxx/transitive_includes/cxx17.csv libcxx/test/libcxx/transitive_includes/cxx20.csv libcxx/test/libcxx/transitive_includes/cxx2b.csv libcxx/test/std/language.support/support.limits/support.limits.general/thread.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.format.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.tests.h libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.vformat.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp libcxx/utils/generate_feature_test_macro_components.py Index: libcxx/utils/generate_feature_test_macro_components.py === --- libcxx/utils/generate_feature_test_macro_components.py +++ libcxx/utils/generate_feature_test_macro_components.py @@ -327,6 +327,13 @@ "test_suite_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", "libcxx_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", "unimplemented": True, + }, { +"name": "__cpp_lib_formatters", +"values": { "c++2b": 202302 }, +"headers": ["stacktrace", "thread"], +"test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", +"libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", +"unimplemented": True, }, { "name": "__cpp_lib_forward_like", "values": { "c++2b": 202207 }, Index: libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp === --- libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp +++ libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp @@ -175,7 +175,8 @@ // Tests for P1636 Formatters for library types // // The paper hasn't been voted in so currently all formatters are disabled. -// TODO validate whether the test is correct after the paper has been accepted. +// Note the paper has been abandoned, the types are kept since other papers may +// introduce these formatters. template void test_P1636() { assert_is_not_formattable, CharT>(); @@ -191,7 +192,7 @@ assert_is_not_formattable, CharT>(); #endif #ifndef TEST_HAS_NO_THREADS - assert_is_not_formattable(); + assert_is_formattable(); #endif assert_is_not_formattable, CharT>(); } Index: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp === --- libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp +++ libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp @@ -18,16 +18,38 @@ // operator<<(basic_ostream& out, thread::id id); #include +#include #include #include +#include "make_string.h" #include "test_macros.h" -int main(int, char**) -{ -std::thread::id id0 = std::this_thread::get_id(); -std::ostringstream os; -os << id0; +template +static void test() { + std::thread::id id0 = std::this_thread::get_id(); + std::basic_ostringstream os; + os << id0; + +#if TEST_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) + // C++23 added a formatter specialization for thread::id. + // This changed the requirement of ostream to have a + // [thread.thread.id]/2 + // The text representation for the character type charT of an object of + // type thread::id is an unspecified sequence of charT ... + // This definition is used for both streaming and formatting. + // + // Test whether the output is identical. +
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
Mordante updated this revision to Diff 511705. Mordante marked 2 inline comments as done. Mordante added a comment. Rebased, addresses review comment, and get a CI run. Herald added a comment. NOTE: Clang-Format Team Automated Review Comment It looks like your clang-format review does not contain any unit tests, please try to ensure all code changes have a unit test (unless this is an `NFC` or refactoring, adding documentation etc..) Add your unit tests in `clang/unittests/Format` and you can build with `ninja FormatTests`. We recommend using the `verifyFormat(xxx)` format of unit tests rather than `EXPECT_EQ` as this will ensure you change is tolerant to random whitespace changes (see FormatTest.cpp as an example) For situations where your change is altering the TokenAnnotator.cpp which can happen if you are trying to improve the annotation phase to ensure we are correctly identifying the type of a token, please add a token annotator test in `TokenAnnotatorTest.cpp` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 Files: libcxx/docs/FeatureTestMacroTable.rst libcxx/docs/ReleaseNotes.rst libcxx/docs/Status/Cxx2b.rst libcxx/docs/Status/Cxx2bPapers.csv libcxx/docs/Status/FormatPaper.csv libcxx/include/__format/parser_std_format_spec.h libcxx/include/__threading_support libcxx/include/thread libcxx/include/version libcxx/test/libcxx/transitive_includes/cxx03.csv libcxx/test/libcxx/transitive_includes/cxx11.csv libcxx/test/libcxx/transitive_includes/cxx14.csv libcxx/test/libcxx/transitive_includes/cxx17.csv libcxx/test/libcxx/transitive_includes/cxx20.csv libcxx/test/libcxx/transitive_includes/cxx2b.csv libcxx/test/std/language.support/support.limits/support.limits.general/thread.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.format.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.tests.h libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.vformat.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp libcxx/utils/generate_feature_test_macro_components.py Index: libcxx/utils/generate_feature_test_macro_components.py === --- libcxx/utils/generate_feature_test_macro_components.py +++ libcxx/utils/generate_feature_test_macro_components.py @@ -327,6 +327,13 @@ "test_suite_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", "libcxx_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", "unimplemented": True, + }, { +"name": "__cpp_lib_formatters", +"values": { "c++2b": 202302 }, +"headers": ["stacktrace", "thread"], +"test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", +"libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)", +"unimplemented": True, }, { "name": "__cpp_lib_forward_like", "values": { "c++2b": 202207 }, Index: libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp === --- libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp +++ libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp @@ -175,7 +175,8 @@ // Tests for P1636 Formatters for library types // // The paper hasn't been voted in so currently all formatters are disabled. -// TODO validate whether the test is correct after the paper has been accepted. +// Note the paper has been abandoned, the types are kept since other papers may +// introduce these formatters. template void test_P1636() { assert_is_not_formattable, CharT>(); @@ -191,7 +192,7 @@ assert_is_not_formattable, CharT>(); #endif #ifndef TEST_HAS_NO_THREADS - assert_is_not_formattable(); + assert_is_formattable(); #endif assert_is_not_formattable, CharT>(); } Index: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp === --- libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp +++
[PATCH] D144331: [libc++][format] Implements formatter thread::id.
Mordante marked 4 inline comments as done. Mordante added a comment. Herald added projects: clang, clang-format. Herald added a subscriber: cfe-commits. Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay. Thanks for the review! Comment at: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.tests.h:17 +template +void format_tests(TestFunction check, ExceptionTest check_exception) { + // Note the output of std::thread::id is unspecified. The output text is the ldionne wrote: > ``` > std::stringstream s; s << id; > assert(s.str() == std::format("{}", id); > ``` As discussed this change is already done in `stream.pass.cpp`. Comment at: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp:27 #include "test_macros.h" +template ldionne wrote: > While we're at it, can we also test the output stream version on an empty > `std::thread::id`? Based on [thread.thread.id]/1 ``` An object of type thread::id provides a unique identifier for each thread of execution and a single distinct value for all thread objects that do not represent a thread of execution ([thread.thread.class]). Each thread of execution has an associated thread::id object that is not equal to the thread::id object of any other thread of execution and that is not equal to the thread::id object of any thread object that does not represent threads of execution. ``` That value is unspecified and may differ between implementations; I expect it will be different. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144331/new/ https://reviews.llvm.org/D144331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits