[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-06-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/95010

Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept 
zoned_time

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones

>From 5fd96e63fab22b5d809c837eaaa5f0db0ae5449b Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time constructors.

Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept 
zoned_time

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/include/__chrono/zoned_time.h  |  67 +-
 .../string_view_local_time.pass.cpp   |  82 
 .../string_view_local_time_choose.pass.cpp| 107 ++
 .../string_view_sys_time.pass.cpp |  82 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 180 +
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 191 ++
 .../time_zone_pointer_local_time.pass.cpp |  80 
 ...me_zone_pointer_local_time_choose.pass.cpp | 109 ++
 .../time_zone_pointer_sys_time.pass.cpp   |  86 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 113 +++
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 121 +++
 .../zoned_time_duration2.pass.cpp |  92 +
 libcxx/test/support/test_offset_time_zone.h   |   9 +
 14 files changed, 1318 insertions(+), 5 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/zoned_time_duration2.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index d4db7876cb2ef..5051a2089c98e 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -162,7 +162,7 @@
 "`3209 `__","Expression in ``year::ok()``\  returns 
clause is ill-formed","Cologne","|Complete|",""
 "","","","","",""
 "`3231 `__","``year_month_day_last::day``\  
specification does not cover ``!ok()``\  values","Belfast","|Nothing To Do|",""
-"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ ","Belfast","","","|chrono|"
+"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ 
","Belfast","|Complete|","19.0","|chrono|"
 "`3190 `__","``std::allocator::allocate``\  
sometimes returns too little storage","Belfast","|Complete|","14.0"
 "`3218 `__","Modifier for ``%d``\  parse flag does 
not match POSIX and ``format``\  specification","Belfast","","","|chrono| 
|format|"
 "`3224 `__","``zoned_time``\  constructor from 
``TimeZonePtr``\  does not specify initialization of ``tp_``\ 
","Belfast","|Complete|","19.0","|chrono|"
@@ -199,7 +199,7 @@
 "`3194 `__","``ConvertibleTo``\  prose does not 
match code","Prague","|Complete|","13.0"
 "`3200 `__","``midpoint``\  should not constrain 
``T``\  is complete","Prague","|Nothing To Do|",""
 "`3201 `__","``lerp``\  should be marked as 
``noexcept``\ ","Prague","|Complete|",""
-"`3226 `__","``zoned_time``\  const

[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-06-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95010

>From fc3076706f093903ab298fc934d848e9dd58bf51 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time constructors.

Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept 
zoned_time

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/include/__chrono/zoned_time.h  |  70 ++-
 .../string_view_local_time.pass.cpp   |  82 
 .../string_view_local_time_choose.pass.cpp| 105 ++
 .../string_view_sys_time.pass.cpp |  82 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 177 +
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 188 ++
 .../time_zone_pointer_local_time.pass.cpp |  80 
 ...me_zone_pointer_local_time_choose.pass.cpp | 109 ++
 .../time_zone_pointer_sys_time.pass.cpp   |  86 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 112 +++
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 118 +++
 .../zoned_time_duration2.pass.cpp |  89 +
 libcxx/test/support/test_offset_time_zone.h   |   9 +
 14 files changed, 1306 insertions(+), 5 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/zoned_time_duration2.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index d4db7876cb2ef..5051a2089c98e 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -162,7 +162,7 @@
 "`3209 `__","Expression in ``year::ok()``\  returns 
clause is ill-formed","Cologne","|Complete|",""
 "","","","","",""
 "`3231 `__","``year_month_day_last::day``\  
specification does not cover ``!ok()``\  values","Belfast","|Nothing To Do|",""
-"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ ","Belfast","","","|chrono|"
+"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ 
","Belfast","|Complete|","19.0","|chrono|"
 "`3190 `__","``std::allocator::allocate``\  
sometimes returns too little storage","Belfast","|Complete|","14.0"
 "`3218 `__","Modifier for ``%d``\  parse flag does 
not match POSIX and ``format``\  specification","Belfast","","","|chrono| 
|format|"
 "`3224 `__","``zoned_time``\  constructor from 
``TimeZonePtr``\  does not specify initialization of ``tp_``\ 
","Belfast","|Complete|","19.0","|chrono|"
@@ -199,7 +199,7 @@
 "`3194 `__","``ConvertibleTo``\  prose does not 
match code","Prague","|Complete|","13.0"
 "`3200 `__","``midpoint``\  should not constrain 
``T``\  is complete","Prague","|Nothing To Do|",""
 "`3201 `__","``lerp``\  should be marked as 
``noexcept``\ ","Prague","|Complete|",""
-"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","","","|chrono|"
+"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","

[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-06-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95010

>From edac5048367b80622007cbd199483cc2eda29efb Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time constructors.

Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept 
zoned_time

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/include/__chrono/zoned_time.h  |  70 ++-
 .../string_view_local_time.pass.cpp   |  82 
 .../string_view_local_time_choose.pass.cpp| 105 ++
 .../string_view_sys_time.pass.cpp |  82 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 177 +
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 188 ++
 .../time_zone_pointer_local_time.pass.cpp |  80 
 ...me_zone_pointer_local_time_choose.pass.cpp | 109 ++
 .../time_zone_pointer_sys_time.pass.cpp   |  86 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 112 +++
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 118 +++
 .../zoned_time_duration2.pass.cpp |  89 +
 libcxx/test/support/test_offset_time_zone.h   |  10 +
 14 files changed, 1307 insertions(+), 5 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/zoned_time_duration2.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index d4db7876cb2ef..5051a2089c98e 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -162,7 +162,7 @@
 "`3209 `__","Expression in ``year::ok()``\  returns 
clause is ill-formed","Cologne","|Complete|",""
 "","","","","",""
 "`3231 `__","``year_month_day_last::day``\  
specification does not cover ``!ok()``\  values","Belfast","|Nothing To Do|",""
-"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ ","Belfast","","","|chrono|"
+"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ 
","Belfast","|Complete|","19.0","|chrono|"
 "`3190 `__","``std::allocator::allocate``\  
sometimes returns too little storage","Belfast","|Complete|","14.0"
 "`3218 `__","Modifier for ``%d``\  parse flag does 
not match POSIX and ``format``\  specification","Belfast","","","|chrono| 
|format|"
 "`3224 `__","``zoned_time``\  constructor from 
``TimeZonePtr``\  does not specify initialization of ``tp_``\ 
","Belfast","|Complete|","19.0","|chrono|"
@@ -199,7 +199,7 @@
 "`3194 `__","``ConvertibleTo``\  prose does not 
match code","Prague","|Complete|","13.0"
 "`3200 `__","``midpoint``\  should not constrain 
``T``\  is complete","Prague","|Nothing To Do|",""
 "`3201 `__","``lerp``\  should be marked as 
``noexcept``\ ","Prague","|Complete|",""
-"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","","","|chrono|"
+"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","

[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-06-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95010

>From e374d900e2b3524b466013d61b9c3911c862c8fa Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time constructors.

Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept 
zoned_time

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/include/__chrono/zoned_time.h  |  70 ++-
 .../string_view_local_time.pass.cpp   |  82 
 .../string_view_local_time_choose.pass.cpp| 105 ++
 .../string_view_sys_time.pass.cpp |  82 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 174 
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 185 ++
 .../time_zone_pointer_local_time.pass.cpp |  80 
 ...me_zone_pointer_local_time_choose.pass.cpp | 109 +++
 .../time_zone_pointer_sys_time.pass.cpp   |  86 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 109 +++
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 115 +++
 .../zoned_time_duration2.pass.cpp |  86 
 libcxx/test/support/test_offset_time_zone.h   |  10 +
 14 files changed, 1292 insertions(+), 5 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/zoned_time_duration2.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index d4db7876cb2ef..5051a2089c98e 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -162,7 +162,7 @@
 "`3209 `__","Expression in ``year::ok()``\  returns 
clause is ill-formed","Cologne","|Complete|",""
 "","","","","",""
 "`3231 `__","``year_month_day_last::day``\  
specification does not cover ``!ok()``\  values","Belfast","|Nothing To Do|",""
-"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ ","Belfast","","","|chrono|"
+"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ 
","Belfast","|Complete|","19.0","|chrono|"
 "`3190 `__","``std::allocator::allocate``\  
sometimes returns too little storage","Belfast","|Complete|","14.0"
 "`3218 `__","Modifier for ``%d``\  parse flag does 
not match POSIX and ``format``\  specification","Belfast","","","|chrono| 
|format|"
 "`3224 `__","``zoned_time``\  constructor from 
``TimeZonePtr``\  does not specify initialization of ``tp_``\ 
","Belfast","|Complete|","19.0","|chrono|"
@@ -199,7 +199,7 @@
 "`3194 `__","``ConvertibleTo``\  prose does not 
match code","Prague","|Complete|","13.0"
 "`3200 `__","``midpoint``\  should not constrain 
``T``\  is complete","Prague","|Nothing To Do|",""
 "`3201 `__","``lerp``\  should be marked as 
``noexcept``\ ","Prague","|Complete|",""
-"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","","","|chrono|"
+"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","|

[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time member functions. (PR #95026)

2024-06-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/95026

Note the implementation of
  zoned_time& operator=(const local_time& lt);
is not correct; however the wording cannot be easily implemented. It could be 
if the object caches the local_time assigned. However this does not seem to 
intended. The current implementation matches MSVC STL and libstdc++.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones

>From 368f0d443a91c6671fd913e1e475a43fe1a84f1d Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time member functions.

Note the implementation of
  zoned_time& operator=(const local_time& lt);
is not correct; however the wording cannot be easily implemented. It could
be if the object caches the local_time assigned. However this does not
seem to intended. The current implementation matches MSVC STL and
libstdc++.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/include/__chrono/zoned_time.h  |  21 ++
 .../diagnostics/chrono.nodiscard.verify.cpp   |  12 +-
 .../assign.local_time.pass.cpp| 245 ++
 .../assign.sys_time.pass.cpp  | 134 ++
 .../get_info.pass.cpp |  49 
 .../get_local_time.pass.cpp   | 131 ++
 .../operator_local_time.pass.cpp  | 133 ++
 .../operator_sys_time.pass.cpp| 123 +
 8 files changed, 846 insertions(+), 2 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_sys_time.pass.cpp

diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index bf8e04b6407ef..e59f527f4d825 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -146,8 +146,29 @@ class zoned_time {
 } && is_convertible_v, sys_time<_Duration>>)
   : zoned_time{__traits::locate_zone(__name), __zt, __c} {}
 
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const sys_time<_Duration>& __tp) 
{
+__tp_ = __tp;
+return *this;
+  }
+
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const local_time<_Duration>& 
__tp) {
+// TODO TZDB This seems wrong.
+// Assigning a non-existant or abiguous time will throw and not satisfy
+// the post condition. This seems quite odd; I constructed an object with
+// choose::earliest and that choice is not respected.
+// what did LEWG do with this.
+// MSVC STL and libstdc++ behave the same
+__tp_ = __zone_->to_sys(__tp);
+return *this;
+  }
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI operator sys_time() const { 
return get_sys_time(); }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit operator local_time() 
const { return get_local_time(); }
+
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _TimeZonePtr get_time_zone() const { 
return __zone_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time get_local_time() 
const { return __zone_->to_local(__tp_); }
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time get_sys_time() const 
{ return __tp_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_info get_info() const { return 
__zone_->get_info(__tp_); }
 
 private:
   _TimeZonePtr __zone_;
diff --git a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp 
b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
index e8337cb33822e..32a67dc4dc9c4 100644
--- a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
@@ -81,7 +81,15 @@ void test() {
 
   {
 std::chrono::zoned_time zt;
-zt.get_time_zone(); // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
-zt.get_sys_time();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+
+zt.get_time_zone();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_local_time(); // expected-warning 

[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time member functions. (PR #95026)

2024-06-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95026

>From ad83e31016100fede20971e7ac16dbdd8137504d Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time member functions.

Note the implementation of
  zoned_time& operator=(const local_time& lt);
is not correct; however the wording cannot be easily implemented. It could
be if the object caches the local_time assigned. However this does not
seem to intended. The current implementation matches MSVC STL and
libstdc++.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/include/__chrono/zoned_time.h  |  22 ++
 .../diagnostics/chrono.nodiscard.verify.cpp   |  12 +-
 .../assign.local_time.pass.cpp| 245 ++
 .../assign.sys_time.pass.cpp  | 134 ++
 .../get_info.pass.cpp |  49 
 .../get_local_time.pass.cpp   | 131 ++
 .../operator_local_time.pass.cpp  | 133 ++
 .../operator_sys_time.pass.cpp| 123 +
 8 files changed, 847 insertions(+), 2 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_sys_time.pass.cpp

diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index bf8e04b6407ef..169efb8e9d6f3 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -18,6 +18,7 @@
 
 #  include <__chrono/calendar.h>
 #  include <__chrono/duration.h>
+#  include <__chrono/sys_info.h>
 #  include <__chrono/system_clock.h>
 #  include <__chrono/time_zone.h>
 #  include <__chrono/tzdb_list.h>
@@ -146,8 +147,29 @@ class zoned_time {
 } && is_convertible_v, sys_time<_Duration>>)
   : zoned_time{__traits::locate_zone(__name), __zt, __c} {}
 
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const sys_time<_Duration>& __tp) 
{
+__tp_ = __tp;
+return *this;
+  }
+
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const local_time<_Duration>& 
__tp) {
+// TODO TZDB This seems wrong.
+// Assigning a non-existant or abiguous time will throw and not satisfy
+// the post condition. This seems quite odd; I constructed an object with
+// choose::earliest and that choice is not respected.
+// what did LEWG do with this.
+// MSVC STL and libstdc++ behave the same
+__tp_ = __zone_->to_sys(__tp);
+return *this;
+  }
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI operator sys_time() const { 
return get_sys_time(); }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit operator local_time() 
const { return get_local_time(); }
+
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _TimeZonePtr get_time_zone() const { 
return __zone_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time get_local_time() 
const { return __zone_->to_local(__tp_); }
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time get_sys_time() const 
{ return __tp_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_info get_info() const { return 
__zone_->get_info(__tp_); }
 
 private:
   _TimeZonePtr __zone_;
diff --git a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp 
b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
index e8337cb33822e..32a67dc4dc9c4 100644
--- a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
@@ -81,7 +81,15 @@ void test() {
 
   {
 std::chrono::zoned_time zt;
-zt.get_time_zone(); // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
-zt.get_sys_time();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+
+zt.get_time_zone();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_local_time(); // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_sys_time();   // expected-warning {{ignoring return value 

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds zoned_time deduction guides. (PR #95139)

2024-06-11 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/95139

Completes
- LWG3232 Inconsistency in zoned_time  deduction guides
- LWG3294 zoned_time  deduction guides misinterprets stringchar*

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones

>From 2d255301fcb3ade2b4a39810355c070b659f3b21 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Adds zoned_time deduction guides.

Completes
- LWG3232 Inconsistency in zoned_time  deduction guides
- LWG3294 zoned_time  deduction guides misinterprets stringchar*

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/include/__chrono/zoned_time.h  |  28 ++
 .../time.zone.zonedtime/deduction.pass.cpp| 285 ++
 3 files changed, 315 insertions(+), 2 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/deduction.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index 5051a2089c98e..a288d1add33e2 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -167,7 +167,7 @@
 "`3218 `__","Modifier for ``%d``\  parse flag does 
not match POSIX and ``format``\  specification","Belfast","","","|chrono| 
|format|"
 "`3224 `__","``zoned_time``\  constructor from 
``TimeZonePtr``\  does not specify initialization of ``tp_``\ 
","Belfast","|Complete|","19.0","|chrono|"
 "`3230 `__","Format specifier ``%y/%Y``\  is 
missing locale alternative versions","Belfast","|Complete|","16.0","|chrono| 
|format|"
-"`3232 `__","Inconsistency in ``zoned_time``\  
deduction guides","Belfast","","","|chrono|"
+"`3232 `__","Inconsistency in ``zoned_time``\  
deduction guides","Belfast","|Complete|","19.0","|chrono|"
 "`3222 `__","P0574R1 introduced preconditions on 
non-existent parameters","Belfast","",""
 "`3221 `__","Result of ``year_month``\  arithmetic 
with ``months``\  is ambiguous","Belfast","|Complete|","8.0"
 "`3235 `__","``parse``\  manipulator without 
abbreviation is not callable","Belfast","",""
@@ -225,7 +225,7 @@
 "`3286 `__","``ranges::size``\  is not required to 
be valid after a call to ``ranges::begin``\  on an input 
range","Prague","|Complete|","15.0","|ranges|"
 "`3291 `__","``iota_view::iterator``\  has the 
wrong ``iterator_category``\ ","Prague","|Complete|","15.0","|ranges|"
 "`3292 `__","``iota_view``\  is 
under-constrained","Prague","|Complete|","15.0","|ranges|"
-"`3294 `__","``zoned_time``\  deduction guides 
misinterprets ``string``\ /``char*``\ ","Prague","","","|chrono|"
+"`3294 `__","``zoned_time``\  deduction guides 
misinterprets ``string``\ /``char*``\ ","Prague","|Complete|","19.0","|chrono|"
 "`3296 `__","Inconsistent default argument for 
``basic_regex<>::assign``\ ","Prague","|Complete|",""
 "`3299 `__","Pointers don't need customized 
iterator behavior","Prague","|Complete|","15.0","|ranges|"
 "`3300 `__","Non-array ``ssize``\  overload is 
underconstrained","Prague","|Nothing To Do|",""
diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index 169efb8e9d6f3..33e0ac0603a6e 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -25,6 +25,8 @@
 #  include <__config>
 #  include <__fwd/string_view.h>
 #  include <__type_traits/common_type.h>
+#  include <__type_traits/conditional.h>
+#  include <__type_traits/remove_cvref.h>
 #  include <__utility/move.h>
 
 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -176,6 +178,32 @@ class zoned_time {
   sys_time __tp_;
 };
 
+zoned_time() -> zoned_time;
+
+template 
+zoned_time(sys_time<_Duration>) -> zoned_time>;
+
+template 
+using __time_zone_representation =
+conditional_t,
+  const time_zone*,
+  remove_cvref_t<_TimeZonePtrOrName>>;
+
+template 
+zoned_time(_TimeZonePtrOrName&&) -> zoned_time>;
+
+template 
+zoned_time(_TimeZonePtrOrName&&, sys_time<_Duration>)
+-> zoned_time, 
__time_zone_representation<_TimeZonePtrOrName>>;
+
+template 
+zoned_time(_TimeZonePtrOrName&&, local_time<_Duration>, choose = 
choose::earliest)
+-> zoned_time, 
__time_zone_representation<_TimeZonePtrOrName>>;
+
+template 
+zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, TimeZonePtr2>, choose = 
choose::earliest)
+-> zoned_time, 
__time_zone_representation<_TimeZonePtrOrName>>;
+
 } // namespace chrono
 
 #  endif // _LIBCPP_STD_VER >= 20 &

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements zoned_time's operator==. (PR #95140)

2024-06-11 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/95140

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
- P1614R2 The Mothership has Landed

>From 86dc932d92a960a102a60801419c8d0624f197aa Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Implements zoned_time's operator==.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
- P1614R2 The Mothership has Landed
---
 libcxx/docs/Status/SpaceshipProjects.csv  |  4 +-
 libcxx/include/__chrono/zoned_time.h  |  6 ++
 libcxx/include/chrono |  4 ++
 .../eq.pass.cpp   | 71 +++
 4 files changed, 83 insertions(+), 2 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/eq.pass.cpp

diff --git a/libcxx/docs/Status/SpaceshipProjects.csv 
b/libcxx/docs/Status/SpaceshipProjects.csv
index 128b23b0c2c74..74441dcdea496 100644
--- a/libcxx/docs/Status/SpaceshipProjects.csv
+++ b/libcxx/docs/Status/SpaceshipProjects.csv
@@ -140,7 +140,7 @@ Section,Description,Dependencies,Assignee,Complete
 "| `[class.slice.overview] `_
 | `[slice.ops] `_",| `slice 
`_,None,Hristo Hristov,|Complete|
 - `5.12 Clause 27: Time library 
`_
-| `[time.syn] `_,|,None,Mark de Wever,|In Progress|
+| `[time.syn] `_,|,None,Mark de Wever,|Complete|
 | `[time.duration.comparisons] 
`_, `chrono::duration 
`_, None, Hristo Hristov, |Complete|
 | `[time.point.comparisons] `_, 
`chrono::time_point `_, None, Hristo Hristov, 
|Complete|
 "| `[time.cal.day.nonmembers] `_
@@ -172,7 +172,7 @@ Section,Description,Dependencies,Assignee,Complete
 | `year_month_weekday `_
 | `year_month_weekday_last `_",None,Hristo 
Hristov,|Complete|
 `[time.zone.nonmembers] 
`_,"`chrono::time_zone`",,Mark de 
Wever,|Complete|
-`[time.zone.zonedtime.nonmembers] 
`_,"`chrono::zoned_time`",A 
 implementation,Mark de Wever,|In Progress|
+`[time.zone.zonedtime.nonmembers] 
`_,"`chrono::zoned_time`",,Mark
 de Wever,|Complete|
 `[time.zone.leap.nonmembers] 
`_,"`chrono::time_leap_seconds`",,Mark
 de Wever,|Complete|
 `[time.zone.link.nonmembers] 
`_,"`chrono::time_zone_link`",,Mark
 de Wever,|Complete|
 - `5.13 Clause 28: Localization library 
`_
diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index 33e0ac0603a6e..db5e67135d844 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -204,6 +204,12 @@ template 
 zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, TimeZonePtr2>, choose = 
choose::earliest)
 -> zoned_time, 
__time_zone_representation<_TimeZonePtrOrName>>;
 
+template 
+_LIBCPP_HIDE_FROM_ABI bool
+operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const 
zoned_time<_Duration2, _TimeZonePtr>& __rhs) {
+  return __lhs.get_time_zone() == __rhs.get_time_zone() && 
__lhs.get_sys_time() == __rhs.get_sys_time();
+}
+
 } // namespace chrono
 
 #  endif // _LIBCPP_STD_VER >= 20 && 
!defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && 
!defined(_LIBCPP_HAS_NO_FILESYSTEM)
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 026e920342e1e..df7ebf45bd907 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -793,6 +793,10 @@ template struct zoned_traits;
 template 
  // C++20
 class zoned_time;
 
+template  
  // C++20
+  bool operator==(const zoned_time& x,
+  const zoned_time& y);
+
 // [time.zone.leap], leap second support
 class leap_second {
  // C++20
 public:
diff --git 
a/libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/eq.pass.cpp
 
b/libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/eq.pass.cpp
new file mode 100644
index 0..2ccb060d24ee6
--- /dev/null
+++ 
b/libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/eq.pass.cpp
@@ -0,0 +1,71 @@
+//===--===//
+//
+// Part of the LLVM Project, under the 

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements zoned_seconds typedef. (PR #95141)

2024-06-11 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/95141

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones

>From e12d4507b0cad67dec69aa8d683fb0c5aca82939 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Implements zoned_seconds typedef.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/include/__chrono/zoned_time.h | 2 ++
 libcxx/include/chrono| 2 ++
 libcxx/modules/std/chrono.inc| 2 --
 .../time.zone/time.zone.zonedtime/types.compile.pass.cpp | 5 +
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index db5e67135d844..d9518ce0a8313 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -204,6 +204,8 @@ template 
 zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, TimeZonePtr2>, choose = 
choose::earliest)
 -> zoned_time, 
__time_zone_representation<_TimeZonePtrOrName>>;
 
+using zoned_seconds = zoned_time;
+
 template 
 _LIBCPP_HIDE_FROM_ABI bool
 operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const 
zoned_time<_Duration2, _TimeZonePtr>& __rhs) {
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index df7ebf45bd907..9a6159cf2c4ab 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -793,6 +793,8 @@ template struct zoned_traits;
 template 
  // C++20
 class zoned_time;
 
+using zoned_seconds = zoned_time; 
  // C++20
+
 template  
  // C++20
   bool operator==(const zoned_time& x,
   const zoned_time& y);
diff --git a/libcxx/modules/std/chrono.inc b/libcxx/modules/std/chrono.inc
index 89fe7284eb694..3ba3c46150c9c 100644
--- a/libcxx/modules/std/chrono.inc
+++ b/libcxx/modules/std/chrono.inc
@@ -233,9 +233,7 @@ export namespace std {
 // [time.zone.zonedtime], class template zoned_time
 using std::chrono::zoned_time;
 
-#if 0
 using std::chrono::zoned_seconds;
-#endif // if 0
 
 // [time.zone.leap], leap second support
 using std::chrono::leap_second;
diff --git 
a/libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp 
b/libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp
index f2b198249e73d..91e37d0d02897 100644
--- a/libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp
+++ b/libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp
@@ -23,6 +23,8 @@
 //zoned_time& operator=(const zoned_time&) = default;
 //
 //  };
+//
+// using zoned_seconds = zoned_time;
 
 #include 
 #include 
@@ -57,3 +59,6 @@ 
static_assert(!std::is_copy_constructible_v>>);
 static_assert(!std::is_copy_assignable_v>>);
 static_assert(!std::is_move_assignable_v>>);
+
+// using zoned_seconds = zoned_time;
+static_assert(std::same_as>);

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] Mark test as long_tests (PR #95266)

2024-06-12 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante commented:

This looks like a duplicate of #95170.

https://github.com/llvm/llvm-project/pull/95266
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-07-07 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante edited 
https://github.com/llvm/llvm-project/pull/95010
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-07-07 Thread Mark de Wever via llvm-branch-commits


@@ -76,12 +81,71 @@ class zoned_time {
 
   _LIBCPP_HIDE_FROM_ABI explicit zoned_time(string_view __name)
 requires(requires { __traits::locate_zone(string_view{}); } &&
- // constructible_from
- // would create a dependency on itself. Instead depend on the fact
- // a constructor taking a _TimeZonePtr exists.
  constructible_from<_TimeZonePtr, 
decltype(__traits::locate_zone(string_view{}))>)
   : __zone_{__traits::locate_zone(__name)}, __tp_{} {}
 
+  template 
+  _LIBCPP_HIDE_FROM_ABI zoned_time(const zoned_time<_Duration2, _TimeZonePtr>& 
__zt)
+requires is_convertible_v, sys_time<_Duration>>
+  : __zone_{__zt.get_time_zone()}, __tp_{__zt.get_sys_time()} {}
+
+  _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const 
sys_time<_Duration>& __tp)
+  : __zone_{std::move(__zone)}, __tp_{__tp} {}
+
+  _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const 
sys_time<_Duration>& __tp)
+requires requires { _TimeZonePtr{__traits::locate_zone(string_view{})}; }
+  : zoned_time{__traits::locate_zone(__name), __tp} {}
+
+  _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const 
local_time<_Duration>& __tp)
+requires(is_convertible_v() -> 
to_sys(local_time<_Duration>{})),
+  sys_time>)
+  : __zone_{std::move(__zone)}, __tp_{__zone_->to_sys(__tp)} {}
+
+  _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const 
local_time<_Duration>& __tp)
+requires(requires {
+  _TimeZonePtr{__traits::locate_zone(string_view{})};
+} && is_convertible_v() -> 
to_sys(local_time<_Duration>{})),

mordante wrote:

See the comment about this in the parent patch. I'll mark the similar comments 
as resolved.

https://github.com/llvm/llvm-project/pull/95010
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-07-07 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante commented:

> Peanut gallery comment: it would be very cool if `zoned_time` could make it 
> for libcxx 19; 🤞 It's IMO one of the most useful classes in ``.

I hope to get `zoned_time` and the missing clocks ready before LLVM-19. However 
it will be closer to the deadline than I hoped.

https://github.com/llvm/llvm-project/pull/95010
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-07-07 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95010

>From 6d6dade0997a414431bf852742cd68c24d274e27 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time constructors.

Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept 
zoned_time

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/include/__chrono/zoned_time.h  |  73 ++-
 .../test_offset_time_zone.h   |  10 +
 .../string_view_local_time.pass.cpp   |  74 +++
 .../string_view_local_time_choose.pass.cpp| 100 ++
 .../string_view_sys_time.pass.cpp |  74 +++
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 159 +++
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 181 ++
 .../time_zone_pointer_local_time.pass.cpp |  82 
 ...me_zone_pointer_local_time_choose.pass.cpp | 104 ++
 .../time_zone_pointer_sys_time.pass.cpp   |  88 +
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 105 ++
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 117 +++
 .../zoned_time_duration2.pass.cpp |  88 +
 14 files changed, 1252 insertions(+), 7 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/zoned_time_duration2.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index 5732d5b5dd0564..faae05d3380cc3 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -162,7 +162,7 @@
 "`3209 `__","Expression in ``year::ok()``\  returns 
clause is ill-formed","Cologne","|Complete|",""
 "","","","","",""
 "`3231 `__","``year_month_day_last::day``\  
specification does not cover ``!ok()``\  values","Belfast","|Nothing To Do|",""
-"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ ","Belfast","","","|chrono|"
+"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ 
","Belfast","|Complete|","19.0","|chrono|"
 "`3190 `__","``std::allocator::allocate``\  
sometimes returns too little storage","Belfast","|Complete|","14.0"
 "`3218 `__","Modifier for ``%d``\  parse flag does 
not match POSIX and ``format``\  specification","Belfast","","","|chrono| 
|format|"
 "`3224 `__","``zoned_time``\  constructor from 
``TimeZonePtr``\  does not specify initialization of ``tp_``\ 
","Belfast","|Complete|","19.0","|chrono|"
@@ -199,7 +199,7 @@
 "`3194 `__","``ConvertibleTo``\  prose does not 
match code","Prague","|Complete|","13.0"
 "`3200 `__","``midpoint``\  should not constrain 
``T``\  is complete","Prague","|Nothing To Do|",""
 "`3201 `__","``lerp``\  should be marked as 
``noexcept``\ ","Prague","|Complete|",""
-"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","","","|chrono|"
+"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","|C

[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time member functions. (PR #95026)

2024-07-07 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95026

>From 3dcb1871f7c4281cc0adfd61f4005c686614c307 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time member functions.

Note the implementation of
  zoned_time& operator=(const local_time& lt);
is not correct; however the wording cannot be easily implemented. It could
be if the object caches the local_time assigned. However this does not
seem to intended. The current implementation matches MSVC STL and
libstdc++.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/include/__chrono/zoned_time.h  |  22 ++
 .../diagnostics/chrono.nodiscard.verify.cpp   |  12 +-
 .../assign.local_time.pass.cpp| 245 ++
 .../assign.sys_time.pass.cpp  | 136 ++
 .../get_info.pass.cpp |  51 
 .../get_local_time.pass.cpp   | 133 ++
 .../operator_local_time.pass.cpp  | 135 ++
 .../operator_sys_time.pass.cpp| 125 +
 8 files changed, 857 insertions(+), 2 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_sys_time.pass.cpp

diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index 08f7f37603920..101a9f52966ad 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -18,6 +18,7 @@
 
 #  include <__chrono/calendar.h>
 #  include <__chrono/duration.h>
+#  include <__chrono/sys_info.h>
 #  include <__chrono/system_clock.h>
 #  include <__chrono/time_zone.h>
 #  include <__chrono/tzdb_list.h>
@@ -147,8 +148,29 @@ class zoned_time {
 } && is_convertible_v, sys_time<_Duration>>)
   : zoned_time{__traits::locate_zone(__name), __zt, __c} {}
 
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const sys_time<_Duration>& __tp) 
{
+__tp_ = __tp;
+return *this;
+  }
+
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const local_time<_Duration>& 
__tp) {
+// TODO TZDB This seems wrong.
+// Assigning a non-existant or abiguous time will throw and not satisfy
+// the post condition. This seems quite odd; I constructed an object with
+// choose::earliest and that choice is not respected.
+// what did LEWG do with this.
+// MSVC STL and libstdc++ behave the same
+__tp_ = __zone_->to_sys(__tp);
+return *this;
+  }
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI operator sys_time() const { 
return get_sys_time(); }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit operator local_time() 
const { return get_local_time(); }
+
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _TimeZonePtr get_time_zone() const { 
return __zone_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time get_local_time() 
const { return __zone_->to_local(__tp_); }
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time get_sys_time() const 
{ return __tp_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_info get_info() const { return 
__zone_->get_info(__tp_); }
 
 private:
   _TimeZonePtr __zone_;
diff --git a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp 
b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
index e8337cb33822e..32a67dc4dc9c4 100644
--- a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
@@ -81,7 +81,15 @@ void test() {
 
   {
 std::chrono::zoned_time zt;
-zt.get_time_zone(); // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
-zt.get_sys_time();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+
+zt.get_time_zone();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_local_time(); // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_sys_time();   // expected-warning {{ignoring return value 

[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time member functions. (PR #95026)

2024-07-07 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95026

>From 5195d3905de900a09a9c78ee843c28f0939cdf62 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time member functions.

Note the implementation of
  zoned_time& operator=(const local_time& lt);
is not correct; however the wording cannot be easily implemented. It could
be if the object caches the local_time assigned. However this does not
seem to intended. The current implementation matches MSVC STL and
libstdc++.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/include/__chrono/zoned_time.h  |  22 ++
 .../diagnostics/chrono.nodiscard.verify.cpp   |  12 +-
 .../assign.local_time.pass.cpp| 243 ++
 .../assign.sys_time.pass.cpp  | 136 ++
 .../get_info.pass.cpp |  51 
 .../get_local_time.pass.cpp   | 133 ++
 .../operator_local_time.pass.cpp  | 135 ++
 .../operator_sys_time.pass.cpp| 125 +
 8 files changed, 855 insertions(+), 2 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_sys_time.pass.cpp

diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index 08f7f37603920..101a9f52966ad 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -18,6 +18,7 @@
 
 #  include <__chrono/calendar.h>
 #  include <__chrono/duration.h>
+#  include <__chrono/sys_info.h>
 #  include <__chrono/system_clock.h>
 #  include <__chrono/time_zone.h>
 #  include <__chrono/tzdb_list.h>
@@ -147,8 +148,29 @@ class zoned_time {
 } && is_convertible_v, sys_time<_Duration>>)
   : zoned_time{__traits::locate_zone(__name), __zt, __c} {}
 
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const sys_time<_Duration>& __tp) 
{
+__tp_ = __tp;
+return *this;
+  }
+
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const local_time<_Duration>& 
__tp) {
+// TODO TZDB This seems wrong.
+// Assigning a non-existant or abiguous time will throw and not satisfy
+// the post condition. This seems quite odd; I constructed an object with
+// choose::earliest and that choice is not respected.
+// what did LEWG do with this.
+// MSVC STL and libstdc++ behave the same
+__tp_ = __zone_->to_sys(__tp);
+return *this;
+  }
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI operator sys_time() const { 
return get_sys_time(); }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit operator local_time() 
const { return get_local_time(); }
+
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _TimeZonePtr get_time_zone() const { 
return __zone_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time get_local_time() 
const { return __zone_->to_local(__tp_); }
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time get_sys_time() const 
{ return __tp_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_info get_info() const { return 
__zone_->get_info(__tp_); }
 
 private:
   _TimeZonePtr __zone_;
diff --git a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp 
b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
index e8337cb33822e..32a67dc4dc9c4 100644
--- a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
@@ -81,7 +81,15 @@ void test() {
 
   {
 std::chrono::zoned_time zt;
-zt.get_time_zone(); // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
-zt.get_sys_time();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+
+zt.get_time_zone();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_local_time(); // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_sys_time();   // expected-warning {{ignoring return value 

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds zoned_time deduction guides. (PR #95139)

2024-07-07 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95139

>From 072f4561a2ee3a48dc0754f50ecdec4dbba59421 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Adds zoned_time deduction guides.

Completes
- LWG3232 Inconsistency in zoned_time  deduction guides
- LWG3294 zoned_time  deduction guides misinterprets stringchar*

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/include/__chrono/zoned_time.h  |  28 ++
 .../time.zone.zonedtime/deduction.pass.cpp| 248 ++
 3 files changed, 278 insertions(+), 2 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/deduction.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index faae05d3380cc..1a40a4472a405 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -167,7 +167,7 @@
 "`3218 `__","Modifier for ``%d``\  parse flag does 
not match POSIX and ``format``\  specification","Belfast","","","|chrono| 
|format|"
 "`3224 `__","``zoned_time``\  constructor from 
``TimeZonePtr``\  does not specify initialization of ``tp_``\ 
","Belfast","|Complete|","19.0","|chrono|"
 "`3230 `__","Format specifier ``%y/%Y``\  is 
missing locale alternative versions","Belfast","|Complete|","16.0","|chrono| 
|format|"
-"`3232 `__","Inconsistency in ``zoned_time``\  
deduction guides","Belfast","","","|chrono|"
+"`3232 `__","Inconsistency in ``zoned_time``\  
deduction guides","Belfast","|Complete|","19.0","|chrono|"
 "`3222 `__","P0574R1 introduced preconditions on 
non-existent parameters","Belfast","",""
 "`3221 `__","Result of ``year_month``\  arithmetic 
with ``months``\  is ambiguous","Belfast","|Complete|","8.0"
 "`3235 `__","``parse``\  manipulator without 
abbreviation is not callable","Belfast","",""
@@ -225,7 +225,7 @@
 "`3286 `__","``ranges::size``\  is not required to 
be valid after a call to ``ranges::begin``\  on an input 
range","Prague","|Complete|","15.0","|ranges|"
 "`3291 `__","``iota_view::iterator``\  has the 
wrong ``iterator_category``\ ","Prague","|Complete|","15.0","|ranges|"
 "`3292 `__","``iota_view``\  is 
under-constrained","Prague","|Complete|","15.0","|ranges|"
-"`3294 `__","``zoned_time``\  deduction guides 
misinterprets ``string``\ /``char*``\ ","Prague","","","|chrono|"
+"`3294 `__","``zoned_time``\  deduction guides 
misinterprets ``string``\ /``char*``\ ","Prague","|Complete|","19.0","|chrono|"
 "`3296 `__","Inconsistent default argument for 
``basic_regex<>::assign``\ ","Prague","|Complete|",""
 "`3299 `__","Pointers don't need customized 
iterator behavior","Prague","|Complete|","15.0","|ranges|"
 "`3300 `__","Non-array ``ssize``\  overload is 
underconstrained","Prague","|Nothing To Do|",""
diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index 101a9f52966ad..7a13c4e3a3dee 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -25,6 +25,8 @@
 #  include <__config>
 #  include <__fwd/string_view.h>
 #  include <__type_traits/common_type.h>
+#  include <__type_traits/conditional.h>
+#  include <__type_traits/remove_cvref.h>
 #  include <__utility/move.h>
 
 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -177,6 +179,32 @@ class zoned_time {
   sys_time __tp_;
 };
 
+zoned_time() -> zoned_time;
+
+template 
+zoned_time(sys_time<_Duration>) -> zoned_time>;
+
+template 
+using __time_zone_representation =
+conditional_t,
+  const time_zone*,
+  remove_cvref_t<_TimeZonePtrOrName>>;
+
+template 
+zoned_time(_TimeZonePtrOrName&&) -> zoned_time>;
+
+template 
+zoned_time(_TimeZonePtrOrName&&, sys_time<_Duration>)
+-> zoned_time, 
__time_zone_representation<_TimeZonePtrOrName>>;
+
+template 
+zoned_time(_TimeZonePtrOrName&&, local_time<_Duration>, choose = 
choose::earliest)
+-> zoned_time, 
__time_zone_representation<_TimeZonePtrOrName>>;
+
+template 
+zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, TimeZonePtr2>, choose = 
choose::earliest)
+-> zoned_time, 
__time_zone_representation<_TimeZonePtrOrName>>;
+
 } // namespace chrono
 
 #  endif // _LIBCPP_STD_VER >= 20 && 
!defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && 
!defined(_LIBCPP_HAS_NO_FILESYSTEM)
diff --git 
a/libcxx/test/std/time/time.zone/time.zone.zonedtime/deduction.pass.cpp 
b/libcxx/test/std/time/time.zone/ti

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements zoned_time's operator==. (PR #95140)

2024-07-07 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95140

>From 24e1151d23ba3b6b72461498ababb8b0821422ae Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Implements zoned_time's operator==.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
- P1614R2 The Mothership has Landed
---
 libcxx/docs/Status/SpaceshipProjects.csv  |  4 +-
 libcxx/include/__chrono/zoned_time.h  |  6 ++
 libcxx/include/chrono |  4 ++
 .../eq.pass.cpp   | 71 +++
 4 files changed, 83 insertions(+), 2 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/eq.pass.cpp

diff --git a/libcxx/docs/Status/SpaceshipProjects.csv 
b/libcxx/docs/Status/SpaceshipProjects.csv
index 128b23b0c2c74f..74441dcdea4966 100644
--- a/libcxx/docs/Status/SpaceshipProjects.csv
+++ b/libcxx/docs/Status/SpaceshipProjects.csv
@@ -140,7 +140,7 @@ Section,Description,Dependencies,Assignee,Complete
 "| `[class.slice.overview] `_
 | `[slice.ops] `_",| `slice 
`_,None,Hristo Hristov,|Complete|
 - `5.12 Clause 27: Time library 
`_
-| `[time.syn] `_,|,None,Mark de Wever,|In Progress|
+| `[time.syn] `_,|,None,Mark de Wever,|Complete|
 | `[time.duration.comparisons] 
`_, `chrono::duration 
`_, None, Hristo Hristov, |Complete|
 | `[time.point.comparisons] `_, 
`chrono::time_point `_, None, Hristo Hristov, 
|Complete|
 "| `[time.cal.day.nonmembers] `_
@@ -172,7 +172,7 @@ Section,Description,Dependencies,Assignee,Complete
 | `year_month_weekday `_
 | `year_month_weekday_last `_",None,Hristo 
Hristov,|Complete|
 `[time.zone.nonmembers] 
`_,"`chrono::time_zone`",,Mark de 
Wever,|Complete|
-`[time.zone.zonedtime.nonmembers] 
`_,"`chrono::zoned_time`",A 
 implementation,Mark de Wever,|In Progress|
+`[time.zone.zonedtime.nonmembers] 
`_,"`chrono::zoned_time`",,Mark
 de Wever,|Complete|
 `[time.zone.leap.nonmembers] 
`_,"`chrono::time_leap_seconds`",,Mark
 de Wever,|Complete|
 `[time.zone.link.nonmembers] 
`_,"`chrono::time_zone_link`",,Mark
 de Wever,|Complete|
 - `5.13 Clause 28: Localization library 
`_
diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index 7a13c4e3a3dee6..9be206db75931c 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -205,6 +205,12 @@ template 
 zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, TimeZonePtr2>, choose = 
choose::earliest)
 -> zoned_time, 
__time_zone_representation<_TimeZonePtrOrName>>;
 
+template 
+_LIBCPP_HIDE_FROM_ABI bool
+operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const 
zoned_time<_Duration2, _TimeZonePtr>& __rhs) {
+  return __lhs.get_time_zone() == __rhs.get_time_zone() && 
__lhs.get_sys_time() == __rhs.get_sys_time();
+}
+
 } // namespace chrono
 
 #  endif // _LIBCPP_STD_VER >= 20 && 
!defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && 
!defined(_LIBCPP_HAS_NO_FILESYSTEM)
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index f377a57a024975..68a7fe3cc09b3d 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -793,6 +793,10 @@ template struct zoned_traits;
 template 
  // C++20
 class zoned_time;
 
+template  
  // C++20
+  bool operator==(const zoned_time& x,
+  const zoned_time& y);
+
 // [time.zone.leap], leap second support
 class leap_second {
  // C++20
 public:
diff --git 
a/libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/eq.pass.cpp
 
b/libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/eq.pass.cpp
new file mode 100644
index 00..2ccb060d24ee68
--- /dev/null
+++ 
b/libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/eq.pass.cpp
@@ -0,0 +1,71 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements zoned_seconds typedef. (PR #95141)

2024-07-08 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95141

>From 711d47efd989a4422e61fd400a422182868c514e Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Implements zoned_seconds typedef.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/include/__chrono/zoned_time.h | 2 ++
 libcxx/include/chrono| 2 ++
 libcxx/modules/std/chrono.inc| 2 --
 .../time.zone/time.zone.zonedtime/types.compile.pass.cpp | 5 +
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index 9be206db75931..30c7fe05c0b20 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -205,6 +205,8 @@ template 
 zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, TimeZonePtr2>, choose = 
choose::earliest)
 -> zoned_time, 
__time_zone_representation<_TimeZonePtrOrName>>;
 
+using zoned_seconds = zoned_time;
+
 template 
 _LIBCPP_HIDE_FROM_ABI bool
 operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const 
zoned_time<_Duration2, _TimeZonePtr>& __rhs) {
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 68a7fe3cc09b3..d6faa6f8baf88 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -793,6 +793,8 @@ template struct zoned_traits;
 template 
  // C++20
 class zoned_time;
 
+using zoned_seconds = zoned_time; 
  // C++20
+
 template  
  // C++20
   bool operator==(const zoned_time& x,
   const zoned_time& y);
diff --git a/libcxx/modules/std/chrono.inc b/libcxx/modules/std/chrono.inc
index 89fe7284eb694..3ba3c46150c9c 100644
--- a/libcxx/modules/std/chrono.inc
+++ b/libcxx/modules/std/chrono.inc
@@ -233,9 +233,7 @@ export namespace std {
 // [time.zone.zonedtime], class template zoned_time
 using std::chrono::zoned_time;
 
-#if 0
 using std::chrono::zoned_seconds;
-#endif // if 0
 
 // [time.zone.leap], leap second support
 using std::chrono::leap_second;
diff --git 
a/libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp 
b/libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp
index 96903b761b218..497da859265c2 100644
--- a/libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp
+++ b/libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp
@@ -23,6 +23,8 @@
 //zoned_time& operator=(const zoned_time&) = default;
 //
 //  };
+//
+// using zoned_seconds = zoned_time;
 
 #include 
 #include 
@@ -61,3 +63,6 @@ 
static_assert(!std::is_copy_constructible_v>>);
 static_assert(!std::is_copy_assignable_v>>);
 static_assert(!std::is_move_assignable_v>>);
+
+// using zoned_seconds = zoned_time;
+static_assert(std::same_as>);

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][spaceship] Marks P1614 as complete. (PR #99375)

2024-07-17 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/99375

Implements parts of:
- P1902R1 Missing feature-test macros 2017-2019

Completes:
- P1614R2 The Mothership has Landed

>From b71feb3626ccbda30d6ec8e2788c7442cf4679f9 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Mon, 15 Jul 2024 07:45:02 +0200
Subject: [PATCH] [libc++][spaceship] Marks P1614 as complete.

Implements parts of:
- P1902R1 Missing feature-test macros 2017-2019

Completes:
- P1614R2 The Mothership has Landed
---
 libcxx/docs/FeatureTestMacroTable.rst  |  2 +-
 libcxx/docs/ReleaseNotes/19.rst|  1 +
 libcxx/docs/Status/Cxx20.rst   |  1 +
 libcxx/docs/Status/Cxx20Papers.csv |  2 +-
 libcxx/docs/Status/SpaceshipPapers.csv |  2 +-
 libcxx/include/version |  4 ++--
 .../compare.version.compile.pass.cpp   | 14 +++---
 .../version.version.compile.pass.cpp   | 14 +++---
 .../generate_feature_test_macro_components.py  |  3 +--
 9 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index 1e347d043ef69..6a2ef514d2c93 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -290,7 +290,7 @@ Status
 -- 
-
 ``__cpp_lib_syncbuf``  ``201803L``
 -- 
-
-``__cpp_lib_three_way_comparison`` ``201711L``
+``__cpp_lib_three_way_comparison`` ``201907L``
 -- 
-
 ``__cpp_lib_to_address``   ``201711L``
 -- 
-
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index e6d8acb74aeb2..2bfb67c838108 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -38,6 +38,7 @@ What's New in Libc++ 19.0.0?
 Implemented Papers
 --
 
+- P1614R2 - The Mothership has Landed
 - P2637R3 - Member ``visit``
 - P2652R2 - Disallow User Specialization of ``allocator_traits``
 - P2819R2 - Add ``tuple`` protocol to ``complex``
diff --git a/libcxx/docs/Status/Cxx20.rst b/libcxx/docs/Status/Cxx20.rst
index c00d6fb237286..b76e30fbb3712 100644
--- a/libcxx/docs/Status/Cxx20.rst
+++ b/libcxx/docs/Status/Cxx20.rst
@@ -48,6 +48,7 @@ Paper Status
.. [#note-P0883.1] P0883: shared_ptr and floating-point changes weren't 
applied as they themselves aren't implemented yet.
.. [#note-P0883.2] P0883: ``ATOMIC_FLAG_INIT`` was marked deprecated in 
version 14.0, but was undeprecated with the implementation of LWG3659 in 
version 15.0.
.. [#note-P0660] P0660: The paper is implemented but the features are 
experimental and can be enabled via ``-fexperimental-library``.
+   .. [#note-P1614] P1614: ``std::strong_order(long double, long double)`` is 
partly implemented.
.. [#note-P0355] P0355: The implementation status is:
 
   * ``Calendars`` mostly done in Clang 7
diff --git a/libcxx/docs/Status/Cxx20Papers.csv 
b/libcxx/docs/Status/Cxx20Papers.csv
index 34fc5586f74d9..4015d7ad48b06 100644
--- a/libcxx/docs/Status/Cxx20Papers.csv
+++ b/libcxx/docs/Status/Cxx20Papers.csv
@@ -123,7 +123,7 @@
 "`P1522R1 `__","LWG","Iterator Difference Type and 
Integer Overflow","Cologne","|Complete|","15.0","|ranges|"
 "`P1523R1 `__","LWG","Views and Size 
Types","Cologne","|Complete|","15.0","|ranges|"
 "`P1612R1 `__","LWG","Relocate Endian's 
Specification","Cologne","|Complete|","10.0"
-"`P1614R2 `__","LWG","The Mothership has 
Landed","Cologne","|In Progress|",""
+"`P1614R2 `__","LWG","The Mothership has 
Landed","Cologne","|Complete| [#note-P1614]_","19.0"
 "`P1638R1 `__","LWG","basic_istream_view::iterator 
should not be copyable","Cologne","|Complete|","16.0","|ranges|"
 "`P1643R1 `__","LWG","Add wait/notify to 
atomic_ref","Cologne","|Complete|","19.0"
 "`P1644R0 `__","LWG","Add wait/notify to 
atomic","Cologne","",""
diff --git a/libcxx/docs/Status/SpaceshipPapers.csv 
b/libcxx/docs/Status/SpaceshipPapers.csv
index 39e1f968c1754..1ab64a9caf86a 100644
--- a/libcxx/docs/Status/SpaceshipPapers.csv
+++ b/libcxx/docs/Status/SpaceshipPapers.csv
@@ -1,5 +1,5 @@
 "Number","Name","Status","First released version"
-`P1614R2 `_,The Mothership has Landed,|In Progress|,
+`P1614R2 `_,The Mothership has 
Landed,|Complete|,19.0
 `P2404R3 

[llvm-branch-commits] [libcxx] [libc++][spaceship] Marks P1614 as complete. (PR #99375)

2024-07-17 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante milestoned 
https://github.com/llvm/llvm-project/pull/99375
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][spaceship] Marks P1614 as complete. (PR #99375)

2024-07-20 Thread Mark de Wever via llvm-branch-commits


@@ -1,5 +1,5 @@
 "Number","Name","Status","First released version"

mordante wrote:

This page has been shipped in several libc++ releases. I strongly like to have 
it shipped in one release where P1614 is finished. I already have a TODO on my 
private list to remove it after branching LLVM 20.

https://github.com/llvm/llvm-project/pull/99375
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][spaceship] Marks P1614 as complete. (PR #99375)

2024-07-22 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/99375

>From be0f12219752be987ca6674fe384281e890520a2 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Mon, 15 Jul 2024 07:45:02 +0200
Subject: [PATCH] [libc++][spaceship] Marks P1614 as complete.

Implements parts of:
- P1902R1 Missing feature-test macros 2017-2019

Completes:
- P1614R2 The Mothership has Landed
---
 libcxx/docs/FeatureTestMacroTable.rst  |  2 +-
 libcxx/docs/ReleaseNotes/19.rst|  1 +
 libcxx/docs/Status/Cxx20.rst   |  1 +
 libcxx/docs/Status/Cxx20Papers.csv |  2 +-
 libcxx/docs/Status/SpaceshipPapers.csv |  2 +-
 libcxx/include/version |  4 ++--
 .../compare.version.compile.pass.cpp   | 14 +++---
 .../version.version.compile.pass.cpp   | 14 +++---
 .../generate_feature_test_macro_components.py  |  3 +--
 9 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index 262da3f8937d2..a1506e115fe70 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -290,7 +290,7 @@ Status
 -- 
-
 ``__cpp_lib_syncbuf``  ``201803L``
 -- 
-
-``__cpp_lib_three_way_comparison`` ``201711L``
+``__cpp_lib_three_way_comparison`` ``201907L``
 -- 
-
 ``__cpp_lib_to_address``   ``201711L``
 -- 
-
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index 43767552960e4..aeef79ebfe765 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -39,6 +39,7 @@ Implemented Papers
 --
 
 - P1132R8 - ``out_ptr`` - a scalable output pointer abstraction
+- P1614R2 - The Mothership has Landed
 - P2637R3 - Member ``visit``
 - P2652R2 - Disallow User Specialization of ``allocator_traits``
 - P2819R2 - Add ``tuple`` protocol to ``complex``
diff --git a/libcxx/docs/Status/Cxx20.rst b/libcxx/docs/Status/Cxx20.rst
index c00d6fb237286..b76e30fbb3712 100644
--- a/libcxx/docs/Status/Cxx20.rst
+++ b/libcxx/docs/Status/Cxx20.rst
@@ -48,6 +48,7 @@ Paper Status
.. [#note-P0883.1] P0883: shared_ptr and floating-point changes weren't 
applied as they themselves aren't implemented yet.
.. [#note-P0883.2] P0883: ``ATOMIC_FLAG_INIT`` was marked deprecated in 
version 14.0, but was undeprecated with the implementation of LWG3659 in 
version 15.0.
.. [#note-P0660] P0660: The paper is implemented but the features are 
experimental and can be enabled via ``-fexperimental-library``.
+   .. [#note-P1614] P1614: ``std::strong_order(long double, long double)`` is 
partly implemented.
.. [#note-P0355] P0355: The implementation status is:
 
   * ``Calendars`` mostly done in Clang 7
diff --git a/libcxx/docs/Status/Cxx20Papers.csv 
b/libcxx/docs/Status/Cxx20Papers.csv
index 34fc5586f74d9..4015d7ad48b06 100644
--- a/libcxx/docs/Status/Cxx20Papers.csv
+++ b/libcxx/docs/Status/Cxx20Papers.csv
@@ -123,7 +123,7 @@
 "`P1522R1 `__","LWG","Iterator Difference Type and 
Integer Overflow","Cologne","|Complete|","15.0","|ranges|"
 "`P1523R1 `__","LWG","Views and Size 
Types","Cologne","|Complete|","15.0","|ranges|"
 "`P1612R1 `__","LWG","Relocate Endian's 
Specification","Cologne","|Complete|","10.0"
-"`P1614R2 `__","LWG","The Mothership has 
Landed","Cologne","|In Progress|",""
+"`P1614R2 `__","LWG","The Mothership has 
Landed","Cologne","|Complete| [#note-P1614]_","19.0"
 "`P1638R1 `__","LWG","basic_istream_view::iterator 
should not be copyable","Cologne","|Complete|","16.0","|ranges|"
 "`P1643R1 `__","LWG","Add wait/notify to 
atomic_ref","Cologne","|Complete|","19.0"
 "`P1644R0 `__","LWG","Add wait/notify to 
atomic","Cologne","",""
diff --git a/libcxx/docs/Status/SpaceshipPapers.csv 
b/libcxx/docs/Status/SpaceshipPapers.csv
index 39e1f968c1754..1ab64a9caf86a 100644
--- a/libcxx/docs/Status/SpaceshipPapers.csv
+++ b/libcxx/docs/Status/SpaceshipPapers.csv
@@ -1,5 +1,5 @@
 "Number","Name","Status","First released version"
-`P1614R2 `_,The Mothership has Landed,|In Progress|,
+`P1614R2 `_,The Mothership has 
Landed,|Complete|,19.0
 `P2404R3 `_,"Relaxing 
``equality_comparable_with``'s, ``totally_order

[llvm-branch-commits] [libcxx] [libc++][spaceship] Implements X::iterator container requirements. (#… (PR #100440)

2024-07-24 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante milestoned 
https://github.com/llvm/llvm-project/pull/100440
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][spaceship] Implements X::iterator container requirements. (#… (PR #100440)

2024-07-24 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/100440

…99343)

This implements the requirements for the container iterator requirements for 
array, deque, vector, and `vector`.

Implements:
- LWG3352 strong_equality isn't a thing

Implements parts of:
- P1614R2 The Mothership has Landed

Fixes: https://github.com/llvm/llvm-project/issues/62486

>From 456668e8290bb5aca2d8e7a2c49246407c72ab19 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 24 Jul 2024 19:42:48 +0200
Subject: [PATCH] [libc++][spaceship] Implements X::iterator container
 requirements. (#99343)

This implements the requirements for the container iterator requirements
for array, deque, vector, and `vector`.

Implements:
- LWG3352 strong_equality isn't a thing

Implements parts of:
- P1614R2 The Mothership has Landed

Fixes: https://github.com/llvm/llvm-project/issues/62486
---
 libcxx/docs/Status/Cxx20Issues.csv|  2 +-
 libcxx/docs/Status/SpaceshipProjects.csv  |  2 +-
 libcxx/include/__bit_reference| 14 +++
 libcxx/include/__iterator/bounded_iter.h  | 24 +
 libcxx/include/__iterator/wrap_iter.h | 23 +
 libcxx/include/deque  | 29 +-
 .../bounded_iter/comparison.pass.cpp  | 14 ++-
 .../sequences/array/iterators.pass.cpp| 18 
 .../sequences/deque/iterators.pass.cpp| 29 ++
 .../sequences/vector.bool/iterators.pass.cpp  | 37 
 .../sequences/vector/iterators.pass.cpp   | 49 +-
 .../span.iterators/iterator.pass.cpp  | 92 +++
 .../string.view.iterators/iterators.pass.cpp  | 85 +
 libcxx/test/support/test_iterators.h  |  2 +
 14 files changed, 413 insertions(+), 7 deletions(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.iterators/iterator.pass.cpp
 create mode 100644 
libcxx/test/std/strings/string.view/string.view.iterators/iterators.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index 1a40a4472a405..8a431c922a2d9 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -264,7 +264,7 @@
 "`3349 `__","Missing 
``__cpp_lib_constexpr_complex``\  for P0415R1","Prague","|Complete|","16.0"
 "`3350 `__","Simplify return type of 
``lexicographical_compare_three_way``\ 
","Prague","|Complete|","17.0","|spaceship|"
 "`3351 `__","``ranges::enable_safe_range``\  should 
not be constrained","Prague","|Complete|","15.0","|ranges|"
-"`3352 `__","``strong_equality``\  isn't a 
thing","Prague","|Nothing To Do|","","|spaceship|"
+"`3352 `__","``strong_equality``\  isn't a 
thing","Prague","|Complete|","19.0","|spaceship|"
 "`3354 `__","``has_strong_structural_equality``\  
has a meaningless definition","Prague","|Nothing To Do|","","|spaceship|"
 "`3355 `__","The memory algorithms should support 
move-only input iterators introduced by 
P1207","Prague","|Complete|","15.0","|ranges|"
 "`3356 `__","``__cpp_lib_nothrow_convertible``\  
should be ``__cpp_lib_is_nothrow_convertible``\ ","Prague","|Complete|","12.0"
diff --git a/libcxx/docs/Status/SpaceshipProjects.csv 
b/libcxx/docs/Status/SpaceshipProjects.csv
index e1cf2044cfd78..4dc43cdbbd08f 100644
--- a/libcxx/docs/Status/SpaceshipProjects.csv
+++ b/libcxx/docs/Status/SpaceshipProjects.csv
@@ -83,7 +83,7 @@ Section,Description,Dependencies,Assignee,Complete
 "| `[string.view.synop] `_
 | `[string.view.comparison] `_",| 
`basic_string_view `_,None,Mark de 
Wever,|Complete|
 - `5.7 Clause 22: Containers library 
`_
-| `[container.requirements.general] 
`_,|,None,Unassigned,|Not 
Started|
+| `[container.requirements.general] 
`_,|,None,Mark de 
Wever,|Complete|
 | `[array.syn] `_ (`general 
`_),| `array 
`_,[expos.only.func],"| Adrian Vogelsgesang
 | Hristo Hristov",|Complete|
 | `[deque.syn] `_ (`general 
`_),| `deque 
`_,[expos.only.func],Hristo Hristov,|Complete|
diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference
index 606069d98be72..22637d4397412 100644
--- a/libcxx/include/__bit_reference
+++ b/libcxx/include/__bit_reference
@@ -16,6 +16,7 @@
 #include <__bit/countr.h>
 #include <__bit/invert_if.h>
 #include <__bit/popcount.h>
+#include <__compare/ordering.h>
 #include <__config>
 #in

[llvm-branch-commits] [libcxx] [libc++][spaceship] Implements X::iterator container requirements. (#… (PR #100440)

2024-07-24 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante edited 
https://github.com/llvm/llvm-project/pull/100440
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][spaceship] Implements X::iterator container requirements. (#… (PR #100440)

2024-07-24 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

Cherry-picking https://github.com/llvm/llvm-project/pull/99343 failed.

https://github.com/llvm/llvm-project/pull/100440
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][spaceship] Marks P1614 as complete. (#99375) (PR #100770)

2024-07-26 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante milestoned 
https://github.com/llvm/llvm-project/pull/100770
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][spaceship] Marks P1614 as complete. (#99375) (PR #100770)

2024-07-26 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/100770

Implements parts of:
- P1902R1 Missing feature-test macros 2017-2019

Completes:
- P1614R2 The Mothership has Landed

Fixes #100018

>From c47152b720a81c67e186b383fa856164af265890 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Thu, 25 Jul 2024 18:37:36 +0200
Subject: [PATCH] [libc++][spaceship] Marks P1614 as complete. (#99375)

Implements parts of:
- P1902R1 Missing feature-test macros 2017-2019

Completes:
- P1614R2 The Mothership has Landed

Fixes #100018
---
 libcxx/docs/FeatureTestMacroTable.rst  |  2 +-
 libcxx/docs/ReleaseNotes/19.rst|  1 +
 libcxx/docs/Status/Cxx20.rst   |  1 +
 libcxx/docs/Status/Cxx20Papers.csv |  2 +-
 libcxx/docs/Status/SpaceshipPapers.csv |  2 +-
 libcxx/include/version |  4 ++--
 .../compare.version.compile.pass.cpp   | 14 +++---
 .../version.version.compile.pass.cpp   | 14 +++---
 .../generate_feature_test_macro_components.py  |  3 +--
 9 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index 262da3f8937d2..a1506e115fe70 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -290,7 +290,7 @@ Status
 -- 
-
 ``__cpp_lib_syncbuf``  ``201803L``
 -- 
-
-``__cpp_lib_three_way_comparison`` ``201711L``
+``__cpp_lib_three_way_comparison`` ``201907L``
 -- 
-
 ``__cpp_lib_to_address``   ``201711L``
 -- 
-
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index c2c2bfbed4ac3..92896f6b0d11e 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -53,6 +53,7 @@ Implemented Papers
 --
 
 - P1132R8 - ``out_ptr`` - a scalable output pointer abstraction
+- P1614R2 - The Mothership has Landed
 - P2637R3 - Member ``visit``
 - P2652R2 - Disallow User Specialization of ``allocator_traits``
 - P2819R2 - Add ``tuple`` protocol to ``complex``
diff --git a/libcxx/docs/Status/Cxx20.rst b/libcxx/docs/Status/Cxx20.rst
index c00d6fb237286..b76e30fbb3712 100644
--- a/libcxx/docs/Status/Cxx20.rst
+++ b/libcxx/docs/Status/Cxx20.rst
@@ -48,6 +48,7 @@ Paper Status
.. [#note-P0883.1] P0883: shared_ptr and floating-point changes weren't 
applied as they themselves aren't implemented yet.
.. [#note-P0883.2] P0883: ``ATOMIC_FLAG_INIT`` was marked deprecated in 
version 14.0, but was undeprecated with the implementation of LWG3659 in 
version 15.0.
.. [#note-P0660] P0660: The paper is implemented but the features are 
experimental and can be enabled via ``-fexperimental-library``.
+   .. [#note-P1614] P1614: ``std::strong_order(long double, long double)`` is 
partly implemented.
.. [#note-P0355] P0355: The implementation status is:
 
   * ``Calendars`` mostly done in Clang 7
diff --git a/libcxx/docs/Status/Cxx20Papers.csv 
b/libcxx/docs/Status/Cxx20Papers.csv
index 34fc5586f74d9..4015d7ad48b06 100644
--- a/libcxx/docs/Status/Cxx20Papers.csv
+++ b/libcxx/docs/Status/Cxx20Papers.csv
@@ -123,7 +123,7 @@
 "`P1522R1 `__","LWG","Iterator Difference Type and 
Integer Overflow","Cologne","|Complete|","15.0","|ranges|"
 "`P1523R1 `__","LWG","Views and Size 
Types","Cologne","|Complete|","15.0","|ranges|"
 "`P1612R1 `__","LWG","Relocate Endian's 
Specification","Cologne","|Complete|","10.0"
-"`P1614R2 `__","LWG","The Mothership has 
Landed","Cologne","|In Progress|",""
+"`P1614R2 `__","LWG","The Mothership has 
Landed","Cologne","|Complete| [#note-P1614]_","19.0"
 "`P1638R1 `__","LWG","basic_istream_view::iterator 
should not be copyable","Cologne","|Complete|","16.0","|ranges|"
 "`P1643R1 `__","LWG","Add wait/notify to 
atomic_ref","Cologne","|Complete|","19.0"
 "`P1644R0 `__","LWG","Add wait/notify to 
atomic","Cologne","",""
diff --git a/libcxx/docs/Status/SpaceshipPapers.csv 
b/libcxx/docs/Status/SpaceshipPapers.csv
index 39e1f968c1754..1ab64a9caf86a 100644
--- a/libcxx/docs/Status/SpaceshipPapers.csv
+++ b/libcxx/docs/Status/SpaceshipPapers.csv
@@ -1,5 +1,5 @@
 "Number","Name","Status","First released version"
-`P1614R2 `_,The Mothership has Landed,|In Progress|,
+`P1614R2 

[llvm-branch-commits] [libcxx] [libc++][spaceship] Marks P1614 as complete. (#99375) (PR #100770)

2024-07-26 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante edited 
https://github.com/llvm/llvm-project/pull/100770
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][spaceship] Marks P1614 as complete. (#99375) (PR #100770)

2024-07-26 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

This is the failed cherry-pick of 
https://github.com/llvm/llvm-project/pull/99375

https://github.com/llvm/llvm-project/pull/100770
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][format][2/7] Optimizes c-string arguments. (PR #101805)

2024-08-03 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/101805

The formatter specializations for _CharT* and const _CharT* typically write all 
elements in a loop. This format's internal functions are optimized for larger 
writes.

Instead of writing one element at a time conversion the range to a 
basic_string_view and write that instead.

For C string of 6 characters this is a bit slower, but for 60 characters it's 
faster. The improvements for back_inserter> are not as great 
as the others; it just gets as slow as basic_string_view<_CharT>.

Before
---
Benchmark 
Time CPU   Iterations
---
BM_sprintf/C string len = 64.81 
ns 4.80 ns145890280
BM_format/C string len = 6 52.6 
ns 52.4 ns 13252327
BM_format_to_back_inserter/C string len = 6   53.0 
ns 52.8 ns 13262680
BM_format_to_back_inserter>/C string len = 6 69.7 
ns 69.6 ns 10045636
BM_format_to_back_inserter>/C string len = 6   148 
ns  148 ns  4729368
BM_format_to_back_inserter>/C string len = 6127 
ns  126 ns  5538441
BM_format_to_iterator/ C string len = 642.9 
ns 42.8 ns 16367158
BM_format_to_iterator/ C string len = 6   43.5 
ns 43.4 ns 16141644
BM_format_to_iterator/ C string len = 6   42.9 
ns 42.8 ns 16366718
BM_format_to_iterator/ C string len = 647.8 
ns 47.7 ns 14686488
BM_format/string len = 6   55.3 
ns 55.2 ns 12696889
BM_format_to_back_inserter/string len = 6 55.4 
ns 55.2 ns 12660731
BM_format_to_back_inserter>/string len = 6   70.7 
ns 70.5 ns  9927313
BM_format_to_back_inserter>/string len = 6 153 
ns  153 ns  4573936
BM_format_to_back_inserter>/string len = 6  128 
ns  128 ns  5486033
BM_format_to_iterator/ string len = 6  44.6 
ns 44.5 ns 15758122
BM_format_to_iterator/ string len = 6 44.7 
ns 44.6 ns 15690226
BM_format_to_iterator/ string len = 6 44.3 
ns 44.2 ns 15715898
BM_format_to_iterator/ string len = 6  50.3 
ns 50.1 ns 13958635
BM_format/string_view len = 6  54.2 
ns 54.1 ns 12929525
BM_format_to_back_inserter/string_view len = 654.3 
ns 54.1 ns 12929219
BM_format_to_back_inserter>/string_view len = 6  70.0 
ns 69.8 ns 10022355
BM_format_to_back_inserter>/string_view len = 6153 
ns  152 ns  4585749
BM_format_to_back_inserter>/string_view len = 6 128 
ns  128 ns  5489760
BM_format_to_iterator/ string_view len = 6 44.2 
ns 44.1 ns 15884839
BM_format_to_iterator/ string_view len = 644.8 
ns 44.6 ns 15664278
BM_format_to_iterator/ string_view len = 644.7 
ns 44.6 ns 15716983
BM_format_to_iterator/ string_view len = 6 50.3 
ns 50.2 ns 13936091
BM_sprintf/C string len = 60   4.16 
ns 4.15 ns168764227
BM_format/C string len = 60 169 
ns  169 ns  4144060
BM_format_to_back_inserter/C string len = 60   167 
ns  167 ns  4203915
BM_format_to_back_inserter>/C string len = 60 177 
ns  176 ns  3965619
BM_format_to_back_inserter>/C string len = 60  383 
ns  382 ns  1832531
BM_format_to_back_inserter>/C string len = 60  1270 
ns 1267 ns   552686
BM_format_to_iterator/ C string len = 60141 
ns  140 ns  4988441
BM_format_to_iterator/ C string len = 60   141 
ns  141 ns  4956101
BM_format_to_iterator/ C string len = 60   141 
ns  141 ns  4963443
BM_format_to_iterator/ C string len = 60144 
ns  143 ns  4893139
BM_format/string len = 60  73.4 
ns 73.2 ns  9548455
BM_format_to_back_inserter/string len = 6073.2 
ns 73.0 ns  9524524
BM_format_to_back_inserter>/

[llvm-branch-commits] [libcxx] [libc++][format][3/7] Improves std::format performance. (PR #101817)

2024-08-03 Thread Mark de Wever via llvm-branch-commits


@@ -58,23 +58,156 @@ namespace __format {
 /// This helper is used together with the @ref back_insert_iterator to offer
 /// type-erasure for the formatting functions. This reduces the number to
 /// template instantiations.
+///
+/// The design of the class is being changed to improve performance and do some
+/// code cleanups.
+/// The original design (as shipped up to LLVM-19) uses the following design:
+/// - There is an external object that connects the buffer to the output.
+/// - The class constructor stores a function pointer to a grow function and a
+///   type-erased pointer to the object that does the grow.
+/// - When writing data to the buffer would exceed the external buffer's
+///   capacity it requests the external buffer to flush its contents.

mordante wrote:

Note the last patch in the series will remove this comment.
The implementation itself is in a transition state too, this also will be 
cleaned in the final patch of the series.

https://github.com/llvm/llvm-project/pull/101817
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][format][3/7] Improves std::format performance. (PR #101817)

2024-08-03 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/101817

>From a3acb85e3fd8dd9bb4320bf028d9773d018f27b4 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sat, 30 Mar 2024 17:35:56 +0100
Subject: [PATCH] [libc++][format][3/7] Improves std::format performance.

This changes the __output_buffer to a new structure. Since the other
formatting fucntions std::format_to, std::format_to_n, and
std::formatted_size still use the old codepaths the class is in a
transition state. At the end of the series the class should be in its
final state.

write_double_comparison:

Before

Benchmark  Time CPU   
Iterations

BM_sprintf   197 ns  196 ns 
 355
BM_to_string 218 ns  218 ns 
 3214000
BM_to_chars 42.4 ns 42.3 ns 
16575000
BM_to_chars_as_string   48.2 ns 48.1 ns 
14542000
BM_format175 ns  175 ns 
 400
BM_format_to_back_inserter  175 ns  175 ns 
 3995000
BM_format_to_back_inserter>207 ns  206 ns 
 3393000
BM_format_to_back_inserter>  752 ns  750 ns 
  931000
BM_format_to_iterator/   161 ns  161 ns 
 4345000
BM_format_to_iterator/  161 ns  161 ns 
 4344000
BM_format_to_iterator/  162 ns  161 ns 
 4344000

After

Benchmark  Time CPU   
Iterations

BM_sprintf   197 ns  197 ns 
 355
BM_to_string 219 ns  219 ns 
 3199000
BM_to_chars 42.4 ns 42.4 ns 
16554000
BM_to_chars_as_string   48.1 ns 48.1 ns 
14569000
BM_format167 ns  167 ns 
 4203000
BM_format_to_back_inserter  179 ns  179 ns 
 392
BM_format_to_back_inserter>214 ns  214 ns 
 3274000
BM_format_to_back_inserter>  751 ns  751 ns 
  93
BM_format_to_iterator/   164 ns  164 ns 
 4258000
BM_format_to_iterator/  165 ns  164 ns 
 4247000
BM_format_to_iterator/  165 ns  165 ns 
 4248000

Comparison
Benchmark   Time
 CPU  Time Old  Time New   CPU Old   CPU New

BM_sprintf   +0.0013 
+0.0028   197   197   196   197
BM_to_string +0.0023 
+0.0038   218   219   218   219
BM_to_chars  +0.0014 
+0.003042424242
BM_to_chars_as_string-0.0025 
-0.001048484848
BM_format-0.0476 
-0.0462   175   167   175   167
BM_format_to_back_inserter  +0.0190 
+0.0205   175   179   175   179
BM_format_to_back_inserter>+0.0348 
+0.0363   207   214   206   214
BM_format_to_back_inserter>  -0.0013 
+0.0005   752   751   750   751
BM_format_to_iterator/   +0.0188 
+0.0203   161   164   161   164
BM_format_to_iterator/  +0.0207 
+0.0226   161   165   161   164
BM_format_to_iterator/  +0.0197 
+0.0212   162   165   161   165
OVERALL_GEOMEAN  +0.0058 
+0.0074 0 0 0 0

write_int_comparison:

Before

Benchmar

[llvm-branch-commits] [libcxx] [libc++][format][6/7] Optimizes formatted_size. (PR #101835)

2024-08-03 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/101835

__formatted_size_buffer is not used in the public library interface so the 
changes are not an ABI break.

Before

Benchmark  Time CPU   
Iterations UserCounters...

BM_formatted_size_string/147.6 ns 47.6 ns 
14729701 bytes_per_second=20.055Mi/s
BM_formatted_size_string/223.8 ns 23.8 ns 
29445832 bytes_per_second=80.1657Mi/s
BM_formatted_size_string/411.9 ns 11.9 ns 
58813944 bytes_per_second=320.771Mi/s
BM_formatted_size_string/85.95 ns 5.95 ns
117601928 bytes_per_second=1.25307Gi/s
BM_formatted_size_string/16   2.97 ns 2.97 ns
235800528 bytes_per_second=5.02342Gi/s
BM_formatted_size_string/32   1.49 ns 1.49 ns
471177152 bytes_per_second=20.0428Gi/s
BM_formatted_size_string/64  0.745 ns0.744 ns
942161408 bytes_per_second=80.1172Gi/s
BM_formatted_size_string/128 0.377 ns0.376 ns   
1861005568 bytes_per_second=316.85Gi/s
BM_formatted_size_string/256 0.200 ns0.200 ns   
3503415296 bytes_per_second=1.16508Ti/s
BM_formatted_size_string/512 0.111 ns0.110 ns   
6351184384 bytes_per_second=4.21671Ti/s
BM_formatted_size_string/10240.067 ns0.067 ns   
10441098240 bytes_per_second=13.9409Ti/s
BM_formatted_size_string/20480.045 ns0.045 ns   
15404886016 bytes_per_second=41.0182Ti/s
BM_formatted_size_string/40960.036 ns0.036 ns   
19634089984 bytes_per_second=104.431Ti/s
BM_formatted_size_string/81920.030 ns0.030 ns   
23265501184 bytes_per_second=247.504Ti/s
BM_formatted_size_string/16384   0.027 ns0.027 ns   
25556238336 bytes_per_second=545.066Ti/s
BM_formatted_size_string/32768   0.027 ns0.027 ns   
26036731904 bytes_per_second=1.08282Pi/s
BM_formatted_size_string/65536   0.027 ns0.027 ns   
26192379904 bytes_per_second=2.17753Pi/s
BM_formatted_size_string/131072  0.026 ns0.026 ns   
26622033920 bytes_per_second=4.4243Pi/s
BM_formatted_size_string/262144  0.027 ns0.027 ns   
25452085248 bytes_per_second=8.48295Pi/s
BM_formatted_size_string/524288  0.028 ns0.028 ns   
24593825792 bytes_per_second=16.3639Pi/s
BM_formatted_size_string/1048576 0.028 ns0.028 ns   
24775753728 bytes_per_second=32.8865Pi/s
BM_formatted_size_string/1 47.0 ns 46.9 ns 
14912646 bytes_per_second=81.3132Mi/s
BM_formatted_size_string/2 23.4 ns 23.3 ns 
29964298 bytes_per_second=326.845Mi/s
BM_formatted_size_string/4 11.7 ns 11.7 ns 
59734380 bytes_per_second=1.26993Gi/s
BM_formatted_size_string/8 5.84 ns 5.84 ns
120131824 bytes_per_second=5.10665Gi/s
BM_formatted_size_string/162.92 ns 2.92 ns
239874128 bytes_per_second=20.4273Gi/s
BM_formatted_size_string/321.48 ns 1.48 ns
473672928 bytes_per_second=80.6502Gi/s
BM_formatted_size_string/64   0.797 ns0.796 ns
877660480 bytes_per_second=299.351Gi/s
BM_formatted_size_string/128  0.450 ns0.449 ns   
1568318336 bytes_per_second=1.03679Ti/s
BM_formatted_size_string/256  0.273 ns0.273 ns   
2571588096 bytes_per_second=3.41553Ti/s
BM_formatted_size_string/512  0.181 ns0.181 ns   
3868106240 bytes_per_second=10.2834Ti/s
BM_formatted_size_string/1024 0.143 ns0.143 ns   
4902914048 bytes_per_second=26.0513Ti/s
BM_formatted_size_string/2048 0.121 ns0.121 ns   
5801660416 bytes_per_second=61.775Ti/s
BM_formatted_size_string/4096 0.110 ns0.110 ns   
6380191744 bytes_per_second=135.763Ti/s
BM_formatted_size_string/8192 0.107 ns0.107 ns   
6531432448 bytes_per_second=278.051Ti/s
BM_formatted_size_string/163840.107 ns0.107 ns   
6531842048 bytes_per_second=556.731Ti/s
BM_formatted_size_string/327680.106 ns0.105 ns   
6648430592 bytes_per_second=1.10374Pi/s
BM_formatted_size_string/655360.110 ns0.110 ns   
6352273408 bytes_per_second=2.11267Pi/s
BM_formatted_size_string/131072   0.114 ns0.114 ns   
6139805696 bytes_per_second=4.07511Pi/s
BM_formatted_size_string/262144   0.114 ns0.114 ns   
6169821184 bytes_per_second=8.20475Pi/s
BM_formatted_size_string/524288   0.114 ns0.113 ns   
6168248320 bytes_per_second=16.4288Pi/s
BM_formatted_size_string/1048576  0.120 ns0.120 ns   
5817499648 

[llvm-branch-commits] [libcxx] [libc++][format][7/7] Cleans up the buffer code. (PR #101876)

2024-08-04 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/101876

The internal format buffer code shipped with LLVM 19 is no longer used and 
removed. This also updates parts of the documentation to reflect its proper 
state.

>From 821eb283cd5909143511ca485cdd1eebb60246b0 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sat, 30 Mar 2024 17:35:56 +0100
Subject: [PATCH] [libc++][format][7/7] Cleans up the buffer code.

The internal format buffer code shipped with LLVM 19 is no longer used and
removed. This also updates parts of the documentation to reflect its proper
state.
---
 libcxx/include/__format/buffer.h  | 318 ++
 .../test/libcxx/transitive_includes/cxx03.csv |   1 -
 .../test/libcxx/transitive_includes/cxx11.csv |   1 -
 .../test/libcxx/transitive_includes/cxx14.csv |   1 -
 .../test/libcxx/transitive_includes/cxx17.csv |   1 -
 .../test/libcxx/transitive_includes/cxx20.csv |   2 -
 .../test/libcxx/transitive_includes/cxx23.csv |   2 -
 .../test/libcxx/transitive_includes/cxx26.csv |   2 -
 .../format/format.functions/format_tests.h|   2 +-
 9 files changed, 33 insertions(+), 297 deletions(-)

diff --git a/libcxx/include/__format/buffer.h b/libcxx/include/__format/buffer.h
index ca2334f93fd04..b0722535c6d87 100644
--- a/libcxx/include/__format/buffer.h
+++ b/libcxx/include/__format/buffer.h
@@ -39,7 +39,6 @@
 #include <__type_traits/conditional.h>
 #include <__utility/exception_guard.h>
 #include <__utility/move.h>
-#include  // LLVM-20 remove
 #include 
 #include 
 #include 
@@ -63,7 +62,7 @@ class _LIBCPP_HIDE_FROM_ABI __max_output_size {
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __max_output_size(size_t 
__max_size) : __max_size_{__max_size} {}
 
   // This function adjusts the size of a (bulk) write operations. It ensures 
the
-  // number of code units written by a __output_buffer never exceed
+  // number of code units written by a __output_buffer never exceeds
   // __max_size_ code units.
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __write_request(size_t 
__code_units) {
 size_t __result =
@@ -87,26 +86,7 @@ class _LIBCPP_HIDE_FROM_ABI __max_output_size {
 /// type-erasure for the formatting functions. This reduces the number to
 /// template instantiations.
 ///
-/// The design of the class is being changed to improve performance and do some
-/// code cleanups.
-/// The original design (as shipped up to LLVM-19) uses the following design:
-/// - There is an external object that connects the buffer to the output.
-/// - The class constructor stores a function pointer to a grow function and a
-///   type-erased pointer to the object that does the grow.
-/// - When writing data to the buffer would exceed the external buffer's
-///   capacity it requests the external buffer to flush its contents.
-///
-/// The new design tries to solve some issues with the current design:
-/// - The buffer used is a fixed-size buffer, benchmarking shows that using a
-///   dynamic allocated buffer has performance benefits.
-/// - Implementing P3107R5 "Permit an efficient implementation of std::print"
-///   is not trivial with the current buffers. Using the code from this series
-///   makes it trivial.
-///
-/// This class is ABI-tagged, still the new design does not change the size of
-/// objects of this class.
-///
-/// The new design is the following.
+/// The design is the following:
 /// - There is an external object that connects the buffer to the output.
 /// - This buffer object:
 ///   - inherits publicly from this class.
@@ -206,37 +186,19 @@ class _LIBCPP_TEMPLATE_VIS __output_buffer {
   using value_type   = _CharT;
   using __prepare_write_type = void (*)(__output_buffer<_CharT>&, size_t);
 
-  template  // Deprecated LLVM-19 function.
-  _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t 
__capacity, _Tp* __obj)
-  : __ptr_(__ptr),
-__capacity_(__capacity),
-__flush_([](_CharT* __p, size_t __n, void* __o) { 
static_cast<_Tp*>(__o)->__flush(__p, __n); }),
-__data_{.__version_llvm_20__ = false, .__obj_ = 
reinterpret_cast(__obj) >> 1} {}
-
-  // New LLVM-20 function.
   [[nodiscard]]
   _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t 
__capacity, __prepare_write_type __prepare_write)
   : __output_buffer{__ptr, __capacity, __prepare_write, nullptr} {}
 
-  // New LLVM-20 function.
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(
   _CharT* __ptr, size_t __capacity, __prepare_write_type __prepare_write, 
__max_output_size* __max_output_size)
   : __ptr_(__ptr),
 __capacity_(__capacity),
 __prepare_write_(__prepare_write),
-__data_{.__version_llvm_20_ = true, .__max_output_size_ = 
reinterpret_cast(__max_output_size) >> 1} {
-  }
-
-  // Deprecated LLVM-19 function.
-  _LIBCPP_HIDE_FROM_ABI void __reset(_CharT* __ptr, size_t __capacity) {
-__ptr_  = __ptr;
-__capacity_ = __capacity;
-  }
+ 

[llvm-branch-commits] [libcxx] [libc++][format][7/7] Cleans up the buffer code. (PR #101876)

2024-08-04 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/101876

>From ab3ed920539794cae7ade2b4ae91f21e547517dc Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sat, 30 Mar 2024 17:35:56 +0100
Subject: [PATCH] [libc++][format][7/7] Cleans up the buffer code.

The internal format buffer code shipped with LLVM 19 is no longer used and
removed. This also updates parts of the documentation to reflect its proper
state.
---
 libcxx/include/__format/buffer.h  | 327 ++
 .../test/libcxx/transitive_includes/cxx03.csv |   1 -
 .../test/libcxx/transitive_includes/cxx11.csv |   1 -
 .../test/libcxx/transitive_includes/cxx14.csv |   1 -
 .../test/libcxx/transitive_includes/cxx17.csv |   1 -
 .../test/libcxx/transitive_includes/cxx20.csv |   2 -
 .../test/libcxx/transitive_includes/cxx23.csv |   2 -
 .../test/libcxx/transitive_includes/cxx26.csv |   2 -
 .../format/format.functions/format_tests.h|   2 +-
 9 files changed, 36 insertions(+), 303 deletions(-)

diff --git a/libcxx/include/__format/buffer.h b/libcxx/include/__format/buffer.h
index ca2334f93fd04..e60cbe245eeca 100644
--- a/libcxx/include/__format/buffer.h
+++ b/libcxx/include/__format/buffer.h
@@ -39,7 +39,6 @@
 #include <__type_traits/conditional.h>
 #include <__utility/exception_guard.h>
 #include <__utility/move.h>
-#include  // LLVM-20 remove
 #include 
 #include 
 #include 
@@ -63,7 +62,7 @@ class _LIBCPP_HIDE_FROM_ABI __max_output_size {
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __max_output_size(size_t 
__max_size) : __max_size_{__max_size} {}
 
   // This function adjusts the size of a (bulk) write operations. It ensures 
the
-  // number of code units written by a __output_buffer never exceed
+  // number of code units written by a __output_buffer never exceeds
   // __max_size_ code units.
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __write_request(size_t 
__code_units) {
 size_t __result =
@@ -87,26 +86,7 @@ class _LIBCPP_HIDE_FROM_ABI __max_output_size {
 /// type-erasure for the formatting functions. This reduces the number to
 /// template instantiations.
 ///
-/// The design of the class is being changed to improve performance and do some
-/// code cleanups.
-/// The original design (as shipped up to LLVM-19) uses the following design:
-/// - There is an external object that connects the buffer to the output.
-/// - The class constructor stores a function pointer to a grow function and a
-///   type-erased pointer to the object that does the grow.
-/// - When writing data to the buffer would exceed the external buffer's
-///   capacity it requests the external buffer to flush its contents.
-///
-/// The new design tries to solve some issues with the current design:
-/// - The buffer used is a fixed-size buffer, benchmarking shows that using a
-///   dynamic allocated buffer has performance benefits.
-/// - Implementing P3107R5 "Permit an efficient implementation of std::print"
-///   is not trivial with the current buffers. Using the code from this series
-///   makes it trivial.
-///
-/// This class is ABI-tagged, still the new design does not change the size of
-/// objects of this class.
-///
-/// The new design is the following.
+/// The design is the following:
 /// - There is an external object that connects the buffer to the output.
 /// - This buffer object:
 ///   - inherits publicly from this class.
@@ -206,37 +186,16 @@ class _LIBCPP_TEMPLATE_VIS __output_buffer {
   using value_type   = _CharT;
   using __prepare_write_type = void (*)(__output_buffer<_CharT>&, size_t);
 
-  template  // Deprecated LLVM-19 function.
-  _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t 
__capacity, _Tp* __obj)
-  : __ptr_(__ptr),
-__capacity_(__capacity),
-__flush_([](_CharT* __p, size_t __n, void* __o) { 
static_cast<_Tp*>(__o)->__flush(__p, __n); }),
-__data_{.__version_llvm_20__ = false, .__obj_ = 
reinterpret_cast(__obj) >> 1} {}
-
-  // New LLVM-20 function.
   [[nodiscard]]
-  _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t 
__capacity, __prepare_write_type __prepare_write)
-  : __output_buffer{__ptr, __capacity, __prepare_write, nullptr} {}
+  _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t 
__capacity, __prepare_write_type __function)
+  : __output_buffer{__ptr, __capacity, __function, nullptr} {}
 
-  // New LLVM-20 function.
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(
-  _CharT* __ptr, size_t __capacity, __prepare_write_type __prepare_write, 
__max_output_size* __max_output_size)
-  : __ptr_(__ptr),
-__capacity_(__capacity),
-__prepare_write_(__prepare_write),
-__data_{.__version_llvm_20_ = true, .__max_output_size_ = 
reinterpret_cast(__max_output_size) >> 1} {
-  }
+  _CharT* __ptr, size_t __capacity, __prepare_write_type __function, 
__max_output_size* __max_output_size)
+  : __ptr_(__ptr), __capacity_(__cap

[llvm-branch-commits] [libcxx] [libc++][bit] Improves rotate functions. (#98032) (PR #101892)

2024-08-04 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/101892

Investigating #96612 shows our implementation was different from the Standard 
and could cause UB. Testing the codegen showed quite a bit of assembly 
generated for these functions. The functions have been written differently 
which allows Clang to optimize the code to use simple CPU rotate instructions.

Fixes: https://github.com/llvm/llvm-project/issues/96612

>From 5af85ec5d84eef768642080ad8360f5f1aad4182 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sat, 3 Aug 2024 11:19:00 +0200
Subject: [PATCH] [libc++][bit] Improves rotate functions. (#98032)

Investigating #96612 shows our implementation was different from the
Standard and could cause UB. Testing the codegen showed quite a bit of
assembly generated for these functions. The functions have been written
differently which allows Clang to optimize the code to use simple CPU
rotate instructions.

Fixes: https://github.com/llvm/llvm-project/issues/96612
---
 libcxx/include/__bit/rotate.h | 37 +--
 .../std/numerics/bit/bitops.rot/rotl.pass.cpp |  4 ++
 .../std/numerics/bit/bitops.rot/rotr.pass.cpp |  4 ++
 3 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/libcxx/include/__bit/rotate.h b/libcxx/include/__bit/rotate.h
index d848056c3350d0..90e430e9d04256 100644
--- a/libcxx/include/__bit/rotate.h
+++ b/libcxx/include/__bit/rotate.h
@@ -20,24 +20,37 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+// Writing two full functions for rotl and rotr makes it easier for the 
compiler
+// to optimize the code. On x86 this function becomes the ROL instruction and
+// the rotr function becomes the ROR instruction.
 template 
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __t, int 
__cnt) _NOEXCEPT {
-  static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an 
unsigned integer type");
-  const unsigned int __dig = numeric_limits<_Tp>::digits;
-  if ((__cnt % __dig) == 0)
-return __t;
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int 
__s) _NOEXCEPT {
+  static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an 
unsigned integer type");
+  const int __N = numeric_limits<_Tp>::digits;
+  int __r   = __s % __N;
+
+  if (__r == 0)
+return __x;
 
-  if (__cnt < 0) {
-__cnt *= -1;
-return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig))); // 
rotr with negative __cnt is similar to rotl
-  }
+  if (__r > 0)
+return (__x << __r) | (__x >> (__N - __r));
 
-  return (__t >> (__cnt % __dig)) | (__t << (__dig - (__cnt % __dig)));
+  return (__x >> -__r) | (__x << (__N + __r));
 }
 
 template 
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __t, int 
__cnt) _NOEXCEPT {
-  return std::__rotr(__t, -__cnt);
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int 
__s) _NOEXCEPT {
+  static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an 
unsigned integer type");
+  const int __N = numeric_limits<_Tp>::digits;
+  int __r   = __s % __N;
+
+  if (__r == 0)
+return __x;
+
+  if (__r > 0)
+return (__x >> __r) | (__x << (__N - __r));
+
+  return (__x << -__r) | (__x >> (__N + __r));
 }
 
 #if _LIBCPP_STD_VER >= 20
diff --git a/libcxx/test/std/numerics/bit/bitops.rot/rotl.pass.cpp 
b/libcxx/test/std/numerics/bit/bitops.rot/rotl.pass.cpp
index 50e498b5761e54..16eabbd2a5a4de 100644
--- a/libcxx/test/std/numerics/bit/bitops.rot/rotl.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bitops.rot/rotl.pass.cpp
@@ -41,6 +41,8 @@ constexpr bool test()
 assert(std::rotl(T(max - 1), 5) == T(max - 32));
 assert(std::rotl(T(max - 1), 6) == T(max - 64));
 assert(std::rotl(T(max - 1), 7) == T(max - 128));
+assert(std::rotl(T(max - 1), std::numeric_limits::max()) ==
+   std::rotl(T(max - 1), std::numeric_limits::max() % 
std::numeric_limits::digits));
 
 assert(std::rotl(T(max - 1), -1) == T(max - highbit));
 assert(std::rotl(T(max - 1), -2) == T(max - (highbit >> 1)));
@@ -49,6 +51,8 @@ constexpr bool test()
 assert(std::rotl(T(max - 1), -5) == T(max - (highbit >> 4)));
 assert(std::rotl(T(max - 1), -6) == T(max - (highbit >> 5)));
 assert(std::rotl(T(max - 1), -7) == T(max - (highbit >> 6)));
+assert(std::rotl(T(max - 1), std::numeric_limits::min()) ==
+   std::rotl(T(max - 1), std::numeric_limits::min() % 
std::numeric_limits::digits));
 
 assert(std::rotl(T(1), 0) == T(1));
 assert(std::rotl(T(1), 1) == T(2));
diff --git a/libcxx/test/std/numerics/bit/bitops.rot/rotr.pass.cpp 
b/libcxx/test/std/numerics/bit/bitops.rot/rotr.pass.cpp
index 00c9e617d2edf3..53405588266f74 100644
--- a/libcxx/test/std/numerics/bit/bitops.rot/rotr.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bitops.rot/rotr.pass.cpp
@@ -41,6 +41,8 @@ constexpr bool test()
 assert(std::rotr(T(max - 1), 5) == T(max - (highbit >> 4)));
 assert(std::rotr(T(max - 1)

[llvm-branch-commits] [libcxx] [libc++][bit] Improves rotate functions. (#98032) (PR #101892)

2024-08-04 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante milestoned 
https://github.com/llvm/llvm-project/pull/101892
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][bit] Improves rotate functions. (#98032) (PR #101892)

2024-08-04 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante edited 
https://github.com/llvm/llvm-project/pull/101892
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][bit] Improves rotate functions. (#98032) (PR #101892)

2024-08-04 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

This is the cherry-pick of https://github.com/llvm/llvm-project/pull/98032

https://github.com/llvm/llvm-project/pull/101892
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] Cherry-pick fixes to std::hypot for PowerPC (PR #102052)

2024-08-12 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

> @ldionne this has some suspect CI failures, can you double check and approve 
> if this is ready to go?

I just restarted the bootstrap build.
AIX's `std/re/re.traits/transform.pass.cpp` seems now to magically pass. I 
recently fixed this by removing XFAIL in main.

https://github.com/llvm/llvm-project/pull/102052
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][format][2/7] Optimizes c-string arguments. (PR #101805)

2024-08-13 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante edited 
https://github.com/llvm/llvm-project/pull/101805
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/18.x: [libc++][modules] Fix disabling Unicode (#81294) (PR #81361)

2024-02-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante approved this pull request.


https://github.com/llvm/llvm-project/pull/81361
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/18.x: [libc++] Only include from the C library if it exists (#81887) (PR #82045)

2024-02-17 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante approved this pull request.

It looks like the Buildkite failures are due to the known Windows bot issues.

https://github.com/llvm/llvm-project/pull/82045
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)

2024-02-17 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/82113

This implements the loading of the leap-seconds.list file and store its 
contents in the tzdb struct.

This adds the required `leap_seconds` member.

The class leap_seconds is fully implemented including its non-member functions.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1614 The Mothership has Landed

Implements:
- P1981 Rename leap to leap_second
- LWG3359  leap second support should allow for negative leap seconds
- LWG3383 §[time.zone.leap.nonmembers] sys_seconds should be replaced with 
seconds

>From 3c588bde050451bc8cf3a934b101585b8519abd5 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Fri, 23 Sep 2022 18:33:20 +0200
Subject: [PATCH] [libc++][chrono] Loads leap-seconds.list in tzdb.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This implements the loading of the leap-seconds.list file and store its
contents in the tzdb struct.

This adds the required `leap_seconds` member.

The class leap_seconds is fully implemented including its non-member
functions.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1614 The Mothership has Landed

Implements:
- P1981 Rename leap to leap_second
- LWG3359  leap second support should allow for negative leap seconds
- LWG3383 §[time.zone.leap.nonmembers] sys_seconds should be replaced with 
seconds
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/docs/Status/Cxx20Papers.csv|   2 +-
 libcxx/docs/Status/SpaceshipProjects.csv  |   2 +-
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/leap_second.h | 112 ++
 libcxx/include/__chrono/tzdb.h|   3 +
 libcxx/include/chrono |  39 ++
 libcxx/include/libcxx.imp |   1 +
 libcxx/include/module.modulemap.in|   1 +
 libcxx/modules/std/chrono.inc |  28 ++---
 libcxx/src/CMakeLists.txt |   1 +
 libcxx/src/include/tzdb/leap_second_private.h |  27 +
 libcxx/src/tzdb.cpp   |  41 +++
 ...rono.nodiscard_extensions.compile.pass.cpp |   6 +
 .../chrono.nodiscard_extensions.verify.cpp|   6 +
 .../time.zone.db/leap_seconds.pass.cpp| 102 
 .../time.zone.db.access/get_tzdb.pass.cpp |   3 +
 .../time.zone.leap/assign.copy.pass.cpp   |  56 +
 .../time.zone.leap/cons.copy.pass.cpp |  51 
 .../time.zone.leap/members/date.pass.cpp  |  48 
 .../time.zone.leap/members/value.pass.cpp |  48 
 .../nonmembers/comparison.pass.cpp|  77 
 libcxx/test/support/test_chrono_leap_second.h |  53 +
 23 files changed, 693 insertions(+), 19 deletions(-)
 create mode 100644 libcxx/include/__chrono/leap_second.h
 create mode 100644 libcxx/src/include/tzdb/leap_second_private.h
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.db/leap_seconds.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.leap/assign.copy.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.leap/cons.copy.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.leap/members/date.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.leap/members/value.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.leap/nonmembers/comparison.pass.cpp
 create mode 100644 libcxx/test/support/test_chrono_leap_second.h

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index f0e9c4090f9cf6..db57b15256a62f 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -269,7 +269,7 @@
 "`3355 `__","The memory algorithms should support 
move-only input iterators introduced by 
P1207","Prague","|Complete|","15.0","|ranges|"
 "`3356 `__","``__cpp_lib_nothrow_convertible``\  
should be ``__cpp_lib_is_nothrow_convertible``\ ","Prague","|Complete|","12.0"
 "`3358 `__","|sect|\ [span.cons] is mistaken that 
``to_address``\  can throw","Prague","|Complete|","17.0"
-"`3359 `__","\  leap second support 
should allow for negative leap seconds","Prague","","","|chrono|"
+"`3359 `__","\  leap second support 
should allow for negative leap seconds","Prague","|Complete|","19.0","|chrono|"
 "`3360 `__","``three_way_comparable_with``\  is 
inconsistent with similar concepts","Prague","|Nothing To Do|","","|spaceship|"
 "`3362 `__","Strike ``stop_source``\ 's 
``operator!=``\ ","Prague","",""
 "`3363 `__","``drop_while_view``\  should opt-out 
of ``sized_range``\ ","Prague","|Nothing To Do|","","|ranges|"
@@ -286,7 +286,7 @@

[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)

2024-02-17 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/82113

>From 3710cf0f9e8fa6065b25123e9b2158079e10805c Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Fri, 23 Sep 2022 18:33:20 +0200
Subject: [PATCH] [libc++][chrono] Loads leap-seconds.list in tzdb.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This implements the loading of the leap-seconds.list file and store its
contents in the tzdb struct.

This adds the required `leap_seconds` member.

The class leap_seconds is fully implemented including its non-member
functions.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1614 The Mothership has Landed

Implements:
- P1981 Rename leap to leap_second
- LWG3359  leap second support should allow for negative leap seconds
- LWG3383 §[time.zone.leap.nonmembers] sys_seconds should be replaced with 
seconds
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/docs/Status/Cxx20Papers.csv|   2 +-
 libcxx/docs/Status/SpaceshipProjects.csv  |   2 +-
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/leap_second.h | 112 ++
 libcxx/include/__chrono/tzdb.h|   3 +
 libcxx/include/chrono |  39 ++
 libcxx/include/libcxx.imp |   1 +
 libcxx/include/module.modulemap.in|   1 +
 libcxx/modules/std/chrono.inc |  28 ++---
 libcxx/src/CMakeLists.txt |   1 +
 libcxx/src/include/tzdb/leap_second_private.h |  27 +
 libcxx/src/tzdb.cpp   |  41 +++
 ...rono.nodiscard_extensions.compile.pass.cpp |   6 +
 .../chrono.nodiscard_extensions.verify.cpp|   6 +
 .../time.zone.db/leap_seconds.pass.cpp| 102 
 .../time.zone.db.access/get_tzdb.pass.cpp |   3 +
 .../time.zone.leap/assign.copy.pass.cpp   |  56 +
 .../time.zone.leap/cons.copy.pass.cpp |  51 
 .../time.zone.leap/members/date.pass.cpp  |  48 
 .../time.zone.leap/members/value.pass.cpp |  48 
 .../nonmembers/comparison.pass.cpp|  77 
 libcxx/test/support/test_chrono_leap_second.h |  53 +
 23 files changed, 693 insertions(+), 19 deletions(-)
 create mode 100644 libcxx/include/__chrono/leap_second.h
 create mode 100644 libcxx/src/include/tzdb/leap_second_private.h
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.db/leap_seconds.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.leap/assign.copy.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.leap/cons.copy.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.leap/members/date.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.leap/members/value.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.leap/nonmembers/comparison.pass.cpp
 create mode 100644 libcxx/test/support/test_chrono_leap_second.h

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index f0e9c4090f9cf6..db57b15256a62f 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -269,7 +269,7 @@
 "`3355 `__","The memory algorithms should support 
move-only input iterators introduced by 
P1207","Prague","|Complete|","15.0","|ranges|"
 "`3356 `__","``__cpp_lib_nothrow_convertible``\  
should be ``__cpp_lib_is_nothrow_convertible``\ ","Prague","|Complete|","12.0"
 "`3358 `__","|sect|\ [span.cons] is mistaken that 
``to_address``\  can throw","Prague","|Complete|","17.0"
-"`3359 `__","\  leap second support 
should allow for negative leap seconds","Prague","","","|chrono|"
+"`3359 `__","\  leap second support 
should allow for negative leap seconds","Prague","|Complete|","19.0","|chrono|"
 "`3360 `__","``three_way_comparable_with``\  is 
inconsistent with similar concepts","Prague","|Nothing To Do|","","|spaceship|"
 "`3362 `__","Strike ``stop_source``\ 's 
``operator!=``\ ","Prague","",""
 "`3363 `__","``drop_while_view``\  should opt-out 
of ``sized_range``\ ","Prague","|Nothing To Do|","","|ranges|"
@@ -286,7 +286,7 @@
 "`3380 `__","``common_type``\  and comparison 
categories","Prague","|Complete|","15.0","|spaceship|"
 "`3381 `__","``begin``\  and ``data``\  must agree 
for ``contiguous_range``\ ","Prague","|Nothing To Do|","","|ranges|"
 "`3382 `__","NTTP for ``pair``\  and ``array``\ 
","Prague","",""
-"`3383 `__","|sect|\ [time.zone.leap.nonmembers] 
``sys_seconds``\  should be replaced with ``seconds``\ 
","Prague","","","|chrono|"

[llvm-branch-commits] [libcxx] [libc++][chrono] Completes the tzdb class. (PR #82157)

2024-02-18 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/82157

It adds the missing member functions of the tzdb class and adds the free 
functions that use these member functions.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones

>From fa05466984bcd3a73a81994e352892fd609effbf Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Fri, 23 Sep 2022 18:33:20 +0200
Subject: [PATCH] [libc++][chrono] Completes the tzdb class.

It adds the missing member functions of the tzdb class and adds the free
functions that use these member functions.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
---
 libcxx/include/__chrono/tzdb.h| 35 
 libcxx/include/__chrono/tzdb_list.h   | 10 +++
 libcxx/include/chrono |  5 ++
 libcxx/modules/std/chrono.inc |  4 +-
 libcxx/src/tzdb.cpp   | 59 ++
 ...rono.nodiscard_extensions.compile.pass.cpp |  8 ++
 .../chrono.nodiscard_extensions.verify.cpp|  8 ++
 .../time.zone.db.access/current_zone.pass.cpp | 77 ++
 .../time.zone.db.access/locate_zone.pass.cpp  | 62 +++
 .../time.zone.db.tzdb/current_zone.pass.cpp   | 79 +++
 .../time.zone.db.tzdb/locate_zone.pass.cpp| 64 +++
 11 files changed, 409 insertions(+), 2 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.db/time.zone.db.access/current_zone.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.db/time.zone.db.access/locate_zone.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.db/time.zone.db.tzdb/current_zone.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.db/time.zone.db.tzdb/locate_zone.pass.cpp

diff --git a/libcxx/include/__chrono/tzdb.h b/libcxx/include/__chrono/tzdb.h
index 45c20f279f9c96..667d2406645658 100644
--- a/libcxx/include/__chrono/tzdb.h
+++ b/libcxx/include/__chrono/tzdb.h
@@ -16,6 +16,7 @@
 // Enable the contents of the header only when libc++ was built with 
experimental features enabled.
 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
 
+#  include <__algorithm/ranges_lower_bound.h>
 #  include <__chrono/leap_second.h>
 #  include <__chrono/time_zone.h>
 #  include <__chrono/time_zone_link.h>
@@ -43,6 +44,40 @@ struct tzdb {
   vector links;
 
   vector leap_seconds;
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* 
__locate_zone(string_view __name) const {
+if (const time_zone* __result = __find_in_zone(__name); __result)
+  return __result;
+
+if (auto __it = ranges::lower_bound(links, __name, {}, 
&time_zone_link::name);
+__it != links.end() && __it->name() == __name)
+  if (const time_zone* __result = __find_in_zone(__it->target()); __result)
+return __result;
+
+return nullptr;
+  }
+
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI const time_zone* 
locate_zone(string_view __name) const {
+if (const time_zone* __result = __locate_zone(__name))
+  return __result;
+
+std::__throw_runtime_error("tzdb: requested time zone not found");
+  }
+
+  _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI const 
time_zone* current_zone() const {
+return __current_zone();
+  }
+
+private:
+  _LIBCPP_HIDE_FROM_ABI const time_zone* __find_in_zone(string_view __name) 
const noexcept {
+if (auto __it = ranges::lower_bound(zones, __name, {}, &time_zone::name);
+__it != zones.end() && __it->name() == __name)
+  return std::addressof(*__it);
+
+return nullptr;
+  }
+
+  [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const 
time_zone* __current_zone() const;
 };
 
 } // namespace chrono
diff --git a/libcxx/include/__chrono/tzdb_list.h 
b/libcxx/include/__chrono/tzdb_list.h
index 112e04ff2ee6ac..d812312287f16e 100644
--- a/libcxx/include/__chrono/tzdb_list.h
+++ b/libcxx/include/__chrono/tzdb_list.h
@@ -17,6 +17,7 @@
 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
 
 #  include <__availability>
+#  include <__chrono/time_zone.h>
 #  include <__chrono/tzdb.h>
 #  include <__config>
 #  include <__fwd/string.h>
@@ -74,6 +75,15 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB 
_LIBCPP_HIDE_FROM_ABI inline con
   return get_tzdb_list().front();
 }
 
+_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline 
const time_zone*
+locate_zone(string_view __name) {
+  return get_tzdb().locate_zone(__name);
+}
+
+_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline 
const time_zone* current_zone() {
+  return get_tzdb().current_zone();
+}
+
 _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb();
 
 _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI 
string remote_version();
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 01ba15d97f3d20..e115e7a3831339 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono

[llvm-branch-commits] [libcxx] release/18.x: [libc++][modules] Fixes naming inconsistency. (#83036) (PR #83156)

2024-03-08 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

I assume it will then be in 18.1.1 in a few weeks.

https://github.com/llvm/llvm-project/pull/83156
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++] Cherry-pick the disabling of modules tests onto release/18.x (PR #85247)

2024-03-14 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

I'd rather fix the clang-tidy integration. I'm quite sure we have ODR 
violations since we use clang-tidy 18 with clang 17 libraries. These violations 
break the modules, but other clang-tidy checks may also have issues. Changing 
https://github.com/llvm/llvm-project/blob/release/18.x/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt#L8
 to 18.1 likely fixes the issue.

I forgot about the release branch when I fixed this in main.

https://github.com/llvm/llvm-project/pull/85247
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++] Cherry-pick the disabling of modules tests onto release/18.x (PR #85247)

2024-03-14 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

> @mordante So should I close this PR?

I see you already did. Do you want to make a fix for the release branch or do 
you want me to pick that up?

https://github.com/llvm/llvm-project/pull/85247
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++] Cherry-pick the disabling of modules tests onto release/18.x (PR #85247)

2024-03-14 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

> Is the fix only to switch to 18.1 in the cmake? I can do that if that's it, I 
> just don't fully understand the situation w/ clang tidy ODR violations since 
> you were the one to make these changes

That should be all. I'm also happy to do it, but that will be tomorrow.

https://github.com/llvm/llvm-project/pull/85247
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++] Use clang-tidy version that matches the compiler we use in the CI (PR #85305)

2024-03-15 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante approved this pull request.

@tstellar due to the new LLVM version number scheme this code would mix LLVM 17 
and LLVM 18. (LLVM 18.1 is not considered to be LLVM 18.) Since these are 
expected not to be ABI stable it seems we ran into ODR violations. For main I 
landed a different fix that has other improvements. These improvements should 
not be backported to LLVM-18. This is the minimal fix needed for LLVM-18.

LGTM!

https://github.com/llvm/llvm-project/pull/85305
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][chrono] Completes the tzdb class. (PR #82157)

2024-03-17 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/82157

>From 7a742c0e564ffa37ad299cf6186faadd61e34d29 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Fri, 23 Sep 2022 18:33:20 +0200
Subject: [PATCH] [libc++][chrono] Completes the tzdb class.

It adds the missing member functions of the tzdb class and adds the free
functions that use these member functions.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
---
 libcxx/include/__chrono/tzdb.h| 35 
 libcxx/include/__chrono/tzdb_list.h   | 10 +++
 libcxx/include/chrono |  5 ++
 libcxx/modules/std/chrono.inc |  4 +-
 libcxx/src/tzdb.cpp   | 59 ++
 ...rono.nodiscard_extensions.compile.pass.cpp |  8 ++
 .../chrono.nodiscard_extensions.verify.cpp|  8 ++
 .../time.zone.db.access/current_zone.pass.cpp | 77 ++
 .../time.zone.db.access/locate_zone.pass.cpp  | 62 +++
 .../time.zone.db.tzdb/current_zone.pass.cpp   | 79 +++
 .../time.zone.db.tzdb/locate_zone.pass.cpp| 64 +++
 11 files changed, 409 insertions(+), 2 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.db/time.zone.db.access/current_zone.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.db/time.zone.db.access/locate_zone.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.db/time.zone.db.tzdb/current_zone.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.db/time.zone.db.tzdb/locate_zone.pass.cpp

diff --git a/libcxx/include/__chrono/tzdb.h b/libcxx/include/__chrono/tzdb.h
index 45c20f279f9c96..667d2406645658 100644
--- a/libcxx/include/__chrono/tzdb.h
+++ b/libcxx/include/__chrono/tzdb.h
@@ -16,6 +16,7 @@
 // Enable the contents of the header only when libc++ was built with 
experimental features enabled.
 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
 
+#  include <__algorithm/ranges_lower_bound.h>
 #  include <__chrono/leap_second.h>
 #  include <__chrono/time_zone.h>
 #  include <__chrono/time_zone_link.h>
@@ -43,6 +44,40 @@ struct tzdb {
   vector links;
 
   vector leap_seconds;
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* 
__locate_zone(string_view __name) const {
+if (const time_zone* __result = __find_in_zone(__name); __result)
+  return __result;
+
+if (auto __it = ranges::lower_bound(links, __name, {}, 
&time_zone_link::name);
+__it != links.end() && __it->name() == __name)
+  if (const time_zone* __result = __find_in_zone(__it->target()); __result)
+return __result;
+
+return nullptr;
+  }
+
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI const time_zone* 
locate_zone(string_view __name) const {
+if (const time_zone* __result = __locate_zone(__name))
+  return __result;
+
+std::__throw_runtime_error("tzdb: requested time zone not found");
+  }
+
+  _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI const 
time_zone* current_zone() const {
+return __current_zone();
+  }
+
+private:
+  _LIBCPP_HIDE_FROM_ABI const time_zone* __find_in_zone(string_view __name) 
const noexcept {
+if (auto __it = ranges::lower_bound(zones, __name, {}, &time_zone::name);
+__it != zones.end() && __it->name() == __name)
+  return std::addressof(*__it);
+
+return nullptr;
+  }
+
+  [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const 
time_zone* __current_zone() const;
 };
 
 } // namespace chrono
diff --git a/libcxx/include/__chrono/tzdb_list.h 
b/libcxx/include/__chrono/tzdb_list.h
index 112e04ff2ee6ac..d812312287f16e 100644
--- a/libcxx/include/__chrono/tzdb_list.h
+++ b/libcxx/include/__chrono/tzdb_list.h
@@ -17,6 +17,7 @@
 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
 
 #  include <__availability>
+#  include <__chrono/time_zone.h>
 #  include <__chrono/tzdb.h>
 #  include <__config>
 #  include <__fwd/string.h>
@@ -74,6 +75,15 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB 
_LIBCPP_HIDE_FROM_ABI inline con
   return get_tzdb_list().front();
 }
 
+_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline 
const time_zone*
+locate_zone(string_view __name) {
+  return get_tzdb().locate_zone(__name);
+}
+
+_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline 
const time_zone* current_zone() {
+  return get_tzdb().current_zone();
+}
+
 _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb();
 
 _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI 
string remote_version();
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 4dd43137b71820..8fdc30a3624dfc 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -689,6 +689,9 @@ struct tzdb {
   vector  zones;
   vector links;
   vectorleap_seconds;
+
+  const time_zone* locate_zone(string_view tz_name) const;
+  const time_zone* curr

[llvm-branch-commits] [libcxx] [libc++][chrono] Adds the sys_info class. (PR #85619)

2024-03-18 Thread Mark de Wever via llvm-branch-commits


@@ -41,4 +41,5 @@
 "`4001 `__","``iota_view`` should provide 
``empty``","Kona November 2023","","","|ranges|"
 "","","","","",""
 "`3343 `__","Ordering of calls to ``unlock()`` and 
``notify_all()`` in Effects element of ``notify_all_at_thread_exit()`` should 
be reversed","Not Yet Adopted","|Complete|","16.0",""
+"","","The sys_info range should be affected by save","Not Yet 
Adopted","|Complete|","19.0"

mordante wrote:

This has been discussed with Howard and I'll file an LWG issue.

https://github.com/llvm/llvm-project/pull/85619
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [NFC] Refactors argument order. (PR #85781)

2024-03-19 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/85781

Putting the output reference argument first looks more sensible.

>From 1af98d79952669b1ce05b42aeeae32bd4ea83ee7 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [NFC] Refactors argument order.

Putting the output reference argument first looks more sensible.
---
 libcxx/include/__chrono/formatter.h | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 4ad59382a4148a..b64cae529a294d 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -79,7 +79,7 @@ namespace __formatter {
 // small). Therefore a duration uses its own conversion.
 template 
 _LIBCPP_HIDE_FROM_ABI void
-__format_sub_seconds(const chrono::duration<_Rep, _Period>& __value, 
basic_stringstream<_CharT>& __sstr) {
+__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const 
chrono::duration<_Rep, _Period>& __value) {
   __sstr << std::use_facet>(__sstr.getloc()).decimal_point();
 
   using __duration = chrono::duration<_Rep, _Period>;
@@ -110,13 +110,13 @@ __format_sub_seconds(const chrono::duration<_Rep, 
_Period>& __value, basic_strin
 }
 
 template 
-_LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(const _Tp& __value, 
basic_stringstream<_CharT>& __sstr) {
-  __formatter::__format_sub_seconds(__value.time_since_epoch(), __sstr);
+_LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(basic_stringstream<_CharT>& 
__sstr, const _Tp& __value) {
+  __formatter::__format_sub_seconds(__sstr, __value.time_since_epoch());
 }
 
 template 
 _LIBCPP_HIDE_FROM_ABI void
-__format_sub_seconds(const chrono::hh_mm_ss<_Duration>& __value, 
basic_stringstream<_CharT>& __sstr) {
+__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const 
chrono::hh_mm_ss<_Duration>& __value) {
   __sstr << std::use_facet>(__sstr.getloc()).decimal_point();
   if constexpr (chrono::treat_as_floating_point_v)
 std::format_to(std::ostreambuf_iterator<_CharT>{__sstr},
@@ -143,7 +143,7 @@ consteval bool __use_fraction() {
 }
 
 template 
-_LIBCPP_HIDE_FROM_ABI void __format_year(int __year, 
basic_stringstream<_CharT>& __sstr) {
+_LIBCPP_HIDE_FROM_ABI void __format_year(basic_stringstream<_CharT>& __sstr, 
int __year) {
   if (__year < 0) {
 __sstr << _CharT('-');
 __year = -__year;
@@ -159,7 +159,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_year(int __year, 
basic_stringstream<_CharT>&
 }
 
 template 
-_LIBCPP_HIDE_FROM_ABI void __format_century(int __year, 
basic_stringstream<_CharT>& __sstr) {
+_LIBCPP_HIDE_FROM_ABI void __format_century(basic_stringstream<_CharT>& 
__sstr, int __year) {
   // TODO FMT Write an issue
   // [tab:time.format.spec]
   //   %C The year divided by 100 using floored division. If the result is a
@@ -172,7 +172,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_century(int __year, 
basic_stringstream<_Char
 
 template 
 _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
-const _Tp& __value, basic_stringstream<_CharT>& __sstr, 
basic_string_view<_CharT> __chrono_specs) {
+basic_stringstream<_CharT>& __sstr, const _Tp& __value, 
basic_string_view<_CharT> __chrono_specs) {
   tm __t  = std::__convert_to_tm(__value);
   const auto& __facet = std::use_facet>(__sstr.getloc());
   for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); 
++__it) {
@@ -196,7 +196,7 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 // strftime's output is only defined in the range [00, 99].
 int __year = __t.tm_year + 1900;
 if (__year < 1000 || __year > )
-  __formatter::__format_century(__year, __sstr);
+  __formatter::__format_century(__sstr, __year);
 else
   __facet.put(
   {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
@@ -242,7 +242,7 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 __facet.put(
 {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
 if constexpr (__use_fraction<_Tp>())
-  __formatter::__format_sub_seconds(__value, __sstr);
+  __formatter::__format_sub_seconds(__sstr, __value);
 break;
 
 // Unlike time_put and strftime the formatting library requires %Y
@@ -283,13 +283,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 // Depending on the platform's libc the range of supported years is
 // limited. Intead of of testing all conditions use the internal
 // implementation unconditionally.
-__formatter::__format_year(__t.tm_year + 1900, __sstr);
+__formatter::__format_year(__sstr, __t.tm_year + 1900);
 break;
 
   case _CharT('F'): {
 int __year = __t.tm_year + 1900;
 

[llvm-branch-commits] [libcxx] [NFC][libc++][TZDB] Refactors argument order. (PR #85781)

2024-03-19 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante edited 
https://github.com/llvm/llvm-project/pull/85781
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][TZDB] Improves time zone format specifiers. (PR #85797)

2024-03-19 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/85797

Per [tab:time.format.spec]
%z  The offset from UTC as specified in ISO 8601-1:2019, subclause
5.3.4.1. For example -0430 refers to 4 hours 30 minutes behind UTC.
If the offset is zero, + is used. The modified commands %Ez and
%Oz insert a : between the hours and minutes: -04:30. If the offset
information is not available, an exception of type format_error is
thrown.

Typically the modified versions Oz or Ez would have wording like

  The modified command %OS produces the locale's alternative
  representation.

In this case the modified version does not depend on the locale.

This change is a preparation for formatting sys_info which has time zone 
information. The function time_put<_CharT>::put() does not have proper time 
zone support, therefore it's a manual implementation.

Fixes https://github.com/llvm/llvm-project/issues/78184

>From 6327aeec1a6adfb1be3dcb95aa1f0ad6204213f4 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Improves time zone format specifiers.

Per [tab:time.format.spec]
%z  The offset from UTC as specified in ISO 8601-1:2019, subclause
5.3.4.1. For example -0430 refers to 4 hours 30 minutes behind UTC.
If the offset is zero, + is used. The modified commands %Ez and
%Oz insert a : between the hours and minutes: -04:30. If the offset
information is not available, an exception of type format_error is
thrown.

Typically the modified versions Oz or Ez would have wording like

  The modified command %OS produces the locale's alternative
  representation.

In this case the modified version does not depend on the locale.

This change is a preparation for formatting sys_info which has time zone
information. The function time_put<_CharT>::put() does not have proper
time zone support, therefore it's a manual implementation.

Fixes https://github.com/llvm/llvm-project/issues/78184
---
 libcxx/include/__chrono/formatter.h   | 50 ++-
 .../time.syn/formatter.file_time.pass.cpp | 39 ++-
 .../time/time.syn/formatter.sys_time.pass.cpp | 39 ++-
 3 files changed, 56 insertions(+), 72 deletions(-)

diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index b64cae529a294d..8b8592041a1fb9 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -10,6 +10,7 @@
 #ifndef _LIBCPP___CHRONO_FORMATTER_H
 #define _LIBCPP___CHRONO_FORMATTER_H
 
+#include <__algorithm/ranges_copy.h>
 #include <__chrono/calendar.h>
 #include <__chrono/concepts.h>
 #include <__chrono/convert_to_tm.h>
@@ -170,10 +171,45 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_century(basic_stringstream<_CharT>& __sstr,
   __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __century);
 }
 
+// Implements the %z format specifier according to [tab:time.format.spec], 
where
+// '__modifier' signals %Oz or %Ez were used. (Both modifiers behave the same,
+// so there is no need to distinguish between them.)
+template 
+_LIBCPP_HIDE_FROM_ABI void
+__format_zone_offset(basic_stringstream<_CharT>& __sstr, chrono::seconds 
__offset, bool __modifier) {
+  if (__offset < 0s) {
+__sstr << _CharT('-');
+__offset = -__offset;
+  } else
+__sstr << _CharT('+');
+
+  chrono::hh_mm_ss __hms{__offset};
+  std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  if (__modifier)
+std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
+  else
+std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+}
+
+// Helper to store the time zone information needed for formatting.
+struct _LIBCPP_HIDE_FROM_ABI __time_zone {
+  // Typically these abbreviations as short and fit in the string's internal
+  // buffer.
+  string __abbrev{"UTC"};
+  chrono::seconds __offset{0};
+};
+
+template 
+_LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
+  __time_zone __result;
+  return __result;
+}
+
 template 
 _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
 basic_stringstream<_CharT>& __sstr, const _Tp& __value, 
basic_string_view<_CharT> __chrono_specs) {
   tm __t  = std::__convert_to_tm(__value);
+  __time_zone __z = __formatter::__convert_to_time_zone(__value);
   const auto& __facet = std::use_facet>(__sstr.getloc());
   for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); 
++__it) {
 if (*__it == _CharT('%')) {
@@ -296,9 +332,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
   {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
   } break;
 
+  case _CharT('z'):
+__formatter::__format_zone_offset(__sstr, __z.__offset, false);
+break;
+
   case _CharT('Z'):
-// TODO FMT Add

[llvm-branch-commits] [clang] release/18.x: Reland Print library module manifest path again (#84881) (PR #85637)

2024-03-19 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

Based on the [post review comments 
](https://github.com/llvm/llvm-project/pull/84881#issuecomment-2003793001) on 
the original PR I feel I need to do additional work. The feature originally 
landed shortly before branching. Based on the number of issues we had with I 
feel we should not backport it.

https://github.com/llvm/llvm-project/pull/85637
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-19 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/85896

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting

>From 5597a07ac32a21d05b674d767395ee7583d11073 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Adds sys_info formatter.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/__chrono/convert_to_tm.h   |   5 +
 libcxx/include/__chrono/formatter.h   |  37 +
 libcxx/include/__chrono/ostream.h |  20 +++
 libcxx/include/chrono |   5 +
 .../time.zone.info.sys/ostream.pass.cpp   |  71 +
 .../time/time.syn/formatter.sys_info.pass.cpp | 138 ++
 .../time.zone.info.sys/ostream.pass.cpp   |  48 ++
 8 files changed, 325 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 82da54284c7386..32166ec72da753 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..f5474e3ea6d078 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -202,6 +203,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone __result;
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  if constexpr (same_as<_Tp, chrono::sys_info>) {
+__result.__offset = __value.offset;
+__result.__abbrev = __value.abbrev;
+  }
+#  endif
   return __result;
 }
 
@@ -411,6 +418,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const 
_Tp& __value) {
 return __value.weekday().ok();
   else if constexpr (__is_hh_mm_ss<_Tp>)
 return true;
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  else if constexpr (same_as<_Tp, chrono::sys_info>)
+return true;
+#  endif
   else
 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
 }
@@ -451,6 +462,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool 
__weekday_name_ok(const _Tp& __value) {
 return __value.weekday().ok();
   else if constexpr (__is_hh_mm_ss<_Tp>)
 return true;
+

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-20 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/85896

>From 7372394c21017fe3840a6c7a6c92ff9b66f0d13d Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Adds sys_info formatter.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/__chrono/convert_to_tm.h   |   5 +
 libcxx/include/__chrono/formatter.h   |  37 +
 libcxx/include/__chrono/ostream.h |  20 +++
 libcxx/include/__chrono/sys_info.h|   6 +-
 libcxx/include/chrono |   5 +
 .../time.zone.info.sys/ostream.pass.cpp   |  71 +
 .../test/libcxx/transitive_includes/cxx23.csv |   1 -
 .../test/libcxx/transitive_includes/cxx26.csv |   1 -
 .../time/time.syn/formatter.sys_info.pass.cpp | 137 ++
 .../time.zone.info.sys/ostream.pass.cpp   |  48 ++
 11 files changed, 326 insertions(+), 7 deletions(-)
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 82da54284c7386..32166ec72da753 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..f5474e3ea6d078 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -202,6 +203,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone __result;
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  if constexpr (same_as<_Tp, chrono::sys_info>) {
+__result.__offset = __value.offset;
+__result.__abbrev = __value.abbrev;
+  }
+#  endif
   return __result;
 }
 
@@ -411,6 +418,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const 
_Tp& __value) {
 return __value.weekday().ok();
   else if constexpr (__is_hh_mm_ss<_Tp>)
 return true;
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  else if constexpr (same_as<_Tp, chrono::sys_info>)
+return true;
+#  endif
   else
 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
 }
@@ -451,6 +462,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool 
__weekday_name_ok(const _Tp& __value) {
 return __value.weekday().ok();
   else if co

[llvm-branch-commits] [libcxx] release/18.x: [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#85756) (PR #85907)

2024-03-20 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante approved this pull request.


https://github.com/llvm/llvm-project/pull/85907
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-20 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/85896

>From 0dbc61d5f18f9fe5f20119805baa968f66504144 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Adds sys_info formatter.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/__chrono/convert_to_tm.h   |   5 +
 libcxx/include/__chrono/formatter.h   |  44 +-
 libcxx/include/__chrono/ostream.h |  20 +++
 libcxx/include/__chrono/sys_info.h|   6 +-
 libcxx/include/chrono |   5 +
 .../time.zone.info.sys/ostream.pass.cpp   |  71 +
 .../test/libcxx/transitive_includes/cxx23.csv |   1 -
 .../test/libcxx/transitive_includes/cxx26.csv |   1 -
 .../time/time.syn/formatter.sys_info.pass.cpp | 137 ++
 .../time.zone.info.sys/ostream.pass.cpp   |  48 ++
 11 files changed, 330 insertions(+), 10 deletions(-)
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 82da54284c7386..32166ec72da753 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..6a9f5870458b32 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -185,10 +186,11 @@ __format_zone_offset(basic_stringstream<_CharT>& __sstr, 
chrono::seconds __offse
 
   chrono::hh_mm_ss __hms{__offset};
   std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  // Note HMS does not allow formatting hours > 23, but the offset is not 
limited to 24H.
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.hours().count());
   if (__modifier)
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
-  else
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+__sstr << _CharT(':');
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.minutes().count());
 }
 
 // Helper to store the time zone information needed for formatting.
@@ -202,6 +204,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone __re

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-20 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/85896

>From caa67f946d7128ebe63c859ed7aa9a03c825e81e Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Adds sys_info formatter.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/__chrono/convert_to_tm.h   |   5 +
 libcxx/include/__chrono/formatter.h   |  44 +-
 libcxx/include/__chrono/ostream.h |  20 +++
 libcxx/include/__chrono/sys_info.h|   6 +-
 libcxx/include/chrono |   5 +
 .../time.zone.info.sys/ostream.pass.cpp   |  71 +
 .../test/libcxx/transitive_includes/cxx23.csv |   1 -
 .../test/libcxx/transitive_includes/cxx26.csv |   1 -
 .../time/time.syn/formatter.sys_info.pass.cpp | 137 ++
 .../time.zone.info.sys/ostream.pass.cpp   |  49 +++
 11 files changed, 331 insertions(+), 10 deletions(-)
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 82da54284c7386..32166ec72da753 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..6a9f5870458b32 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -185,10 +186,11 @@ __format_zone_offset(basic_stringstream<_CharT>& __sstr, 
chrono::seconds __offse
 
   chrono::hh_mm_ss __hms{__offset};
   std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  // Note HMS does not allow formatting hours > 23, but the offset is not 
limited to 24H.
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.hours().count());
   if (__modifier)
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
-  else
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+__sstr << _CharT(':');
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.minutes().count());
 }
 
 // Helper to store the time zone information needed for formatting.
@@ -202,6 +204,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone __r

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-20 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/85896

>From 1c5788302b38da71881854bbee772e3ad8d58cb4 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Adds sys_info formatter.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/__chrono/convert_to_tm.h   |   5 +
 libcxx/include/__chrono/formatter.h   |  44 +-
 libcxx/include/__chrono/ostream.h |  20 +++
 libcxx/include/__chrono/sys_info.h|   6 +-
 libcxx/include/chrono |   7 +-
 .../time.zone.info.sys/ostream.pass.cpp   |  74 ++
 .../test/libcxx/transitive_includes/cxx23.csv |   1 -
 .../test/libcxx/transitive_includes/cxx26.csv |   1 -
 .../time/time.syn/formatter.sys_info.pass.cpp | 137 ++
 .../time.zone.info.sys/ostream.pass.cpp   |  52 +++
 11 files changed, 338 insertions(+), 11 deletions(-)
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 82da54284c7386..32166ec72da753 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..6a9f5870458b32 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -185,10 +186,11 @@ __format_zone_offset(basic_stringstream<_CharT>& __sstr, 
chrono::seconds __offse
 
   chrono::hh_mm_ss __hms{__offset};
   std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  // Note HMS does not allow formatting hours > 23, but the offset is not 
limited to 24H.
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.hours().count());
   if (__modifier)
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
-  else
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+__sstr << _CharT(':');
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.minutes().count());
 }
 
 // Helper to store the time zone information needed for formatting.
@@ -202,6 +204,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone _

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-21 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/85896

>From c17bb85f4863f1fffa8654b4e1931dfebc430e2d Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Adds sys_info formatter.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/__chrono/convert_to_tm.h   |   5 +
 libcxx/include/__chrono/formatter.h   |  58 ++--
 libcxx/include/__chrono/ostream.h |  20 +++
 libcxx/include/__chrono/sys_info.h|   6 +-
 libcxx/include/chrono |   7 +-
 .../time.zone.info.sys/ostream.pass.cpp   |  74 ++
 .../test/libcxx/transitive_includes/cxx23.csv |   1 -
 .../test/libcxx/transitive_includes/cxx26.csv |   1 -
 .../time/time.syn/formatter.sys_info.pass.cpp | 137 ++
 .../time.zone.info.sys/ostream.pass.cpp   |  52 +++
 11 files changed, 344 insertions(+), 19 deletions(-)
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 82da54284c7386..32166ec72da753 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..98976e20b1c820 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -185,10 +186,11 @@ __format_zone_offset(basic_stringstream<_CharT>& __sstr, 
chrono::seconds __offse
 
   chrono::hh_mm_ss __hms{__offset};
   std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  // Note HMS does not allow formatting hours > 23, but the offset is not 
limited to 24H.
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.hours().count());
   if (__modifier)
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
-  else
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+__sstr << _CharT(':');
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.minutes().count());
 }
 
 // Helper to store the time zone information needed for formatting.
@@ -202,6 +204,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-21 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/85896

>From 3eaa059039c7fe9ea4b5fdaadacac7d9c8fa5f3f Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Adds sys_info formatter.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/__chrono/convert_to_tm.h   |   5 +
 libcxx/include/__chrono/formatter.h   |  60 ++--
 libcxx/include/__chrono/ostream.h |  20 +++
 libcxx/include/__chrono/sys_info.h|   6 +-
 libcxx/include/chrono |   7 +-
 .../time.zone.info.sys/ostream.pass.cpp   |  74 ++
 .../test/libcxx/transitive_includes/cxx23.csv |   1 -
 .../test/libcxx/transitive_includes/cxx26.csv |   1 -
 .../time/time.syn/formatter.sys_info.pass.cpp | 137 ++
 .../time.zone.info.sys/ostream.pass.cpp   |  52 +++
 11 files changed, 345 insertions(+), 20 deletions(-)
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 82da54284c7386..32166ec72da753 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..79192fa103fbdb 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -185,10 +186,11 @@ __format_zone_offset(basic_stringstream<_CharT>& __sstr, 
chrono::seconds __offse
 
   chrono::hh_mm_ss __hms{__offset};
   std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  // Note HMS does not allow formatting hours > 23, but the offset is not 
limited to 24H.
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.hours().count());
   if (__modifier)
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
-  else
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+__sstr << _CharT(':');
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.minutes().count());
 }
 
 // Helper to store the time zone information needed for formatting.
@@ -202,6 +204,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone

[llvm-branch-commits] [libcxx] [libc++][chrono] Improves date formatting. (PR #86127)

2024-03-21 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/86127

The formatting of years has been done manually since the results of %Y outside 
the "typical" range may produce unexpected values. The same applies to %F which 
is identical to %Y-%m-%d. Note of these conversion specifiers is affected by 
the locale used. So it's trivial to manually handle this case.

This removes several platform specific ifdefs from the tests.

>From 0aeab5a82110d6e3d01fb8c8562f5569c84203a3 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Thu, 21 Mar 2024 15:22:13 +0100
Subject: [PATCH] [libc++][chrono] Improves date formatting.

The formatting of years has been done manually since the results of %Y
outside the "typical" range may produce unexpected values. The same
applies to %F which is identical to %Y-%m-%d. Note of these conversion
specifiers is affected by the locale used. So it's trivial to manually
handle this case.

This removes several platform specific ifdefs from the tests.
---
 libcxx/include/__chrono/formatter.h   | 16 +-
 .../time.cal.ymd.nonmembers/ostream.pass.cpp  | 31 ---
 .../sys_date.ostream.pass.cpp | 31 ---
 .../formatter.year_month_day.pass.cpp | 24 --
 4 files changed, 7 insertions(+), 95 deletions(-)

diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..217979e88c93db 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -322,15 +322,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 __formatter::__format_year(__sstr, __t.tm_year + 1900);
 break;
 
-  case _CharT('F'): {
-int __year = __t.tm_year + 1900;
-if (__year < 1000) {
-  __formatter::__format_year(__sstr, __year);
-  __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, 
"-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
-} else
-  __facet.put(
-  {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
-  } break;
+  case _CharT('F'):
+// Depending on the platform's libc the range of supported years is
+// limited. Intead of of testing all conditions use the internal
+// implementation unconditionally.
+__formatter::__format_year(__sstr, __t.tm_year + 1900);
+__sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, 
"-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
+break;
 
   case _CharT('z'):
 __formatter::__format_zone_offset(__sstr, __z.__offset, false);
diff --git 
a/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
 
b/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
index ffc737fcad5dd2..3a37e75bbcd2e4 100644
--- 
a/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
+++ 
b/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
@@ -89,20 +89,9 @@ static void test() {
   TEST_EQUAL(stream_c_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, std::chrono::day{29}}),
  SV("2000-02-29"));
-
-#if defined(_AIX)
-  TEST_EQUAL(stream_c_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV("+32767-12-31"));
-#elif defined(_WIN32) // defined(_AIX)
-  TEST_EQUAL(stream_c_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV(""));
-#else //  defined(_AIX)
   TEST_EQUAL(stream_c_locale(
  std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
  SV("32767-12-31"));
-#endif// defined(_AIX)
 
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{-32'768}, 
std::chrono::month{1}, std::chrono::day{1}}),
@@ -122,19 +111,9 @@ static void test() {
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, std::chrono::day{29}}),
  SV("2000-02-29"));
-#if defined(_AIX)
-  TEST_EQUAL(stream_fr_FR_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV("+32767-12-31"));
-#elif defined(_WIN32) // defined(_AIX)
-  TEST_EQUAL(stream_fr_FR_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV(""));
-#else // defined(_AIX)
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std

[llvm-branch-commits] [libcxx] [libc++][chrono] Improves date formatting. (PR #86127)

2024-03-21 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/86127

>From f3e7b583dd8eae59c3caeb84ac3967f361f6e6eb Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Thu, 21 Mar 2024 15:22:13 +0100
Subject: [PATCH] [libc++][chrono] Improves date formatting.

The formatting of years has been done manually since the results of %Y
outside the "typical" range may produce unexpected values. The same
applies to %F which is identical to %Y-%m-%d. Note of these conversion
specifiers is affected by the locale used. So it's trivial to manually
handle this case.

This removes several platform specific ifdefs from the tests.
---
 libcxx/include/__chrono/formatter.h   | 16 -
 .../time.cal.ymd.nonmembers/ostream.pass.cpp  | 34 ---
 .../sys_date.ostream.pass.cpp | 34 ---
 .../formatter.year_month_day.pass.cpp | 24 -
 4 files changed, 7 insertions(+), 101 deletions(-)

diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..217979e88c93db 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -322,15 +322,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 __formatter::__format_year(__sstr, __t.tm_year + 1900);
 break;
 
-  case _CharT('F'): {
-int __year = __t.tm_year + 1900;
-if (__year < 1000) {
-  __formatter::__format_year(__sstr, __year);
-  __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, 
"-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
-} else
-  __facet.put(
-  {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
-  } break;
+  case _CharT('F'):
+// Depending on the platform's libc the range of supported years is
+// limited. Intead of of testing all conditions use the internal
+// implementation unconditionally.
+__formatter::__format_year(__sstr, __t.tm_year + 1900);
+__sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, 
"-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
+break;
 
   case _CharT('z'):
 __formatter::__format_zone_offset(__sstr, __z.__offset, false);
diff --git 
a/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
 
b/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
index ffc737fcad5dd2..20ffb165558e31 100644
--- 
a/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
+++ 
b/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
@@ -13,9 +13,6 @@
 // TODO FMT This test should not require std::to_chars(floating-point)
 // XFAIL: availability-fp_to_chars-missing
 
-// TODO FMT Investigate Windows issues.
-// XFAIL: msvc
-
 // REQUIRES: locale.fr_FR.UTF-8
 // REQUIRES: locale.ja_JP.UTF-8
 
@@ -89,20 +86,9 @@ static void test() {
   TEST_EQUAL(stream_c_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, std::chrono::day{29}}),
  SV("2000-02-29"));
-
-#if defined(_AIX)
-  TEST_EQUAL(stream_c_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV("+32767-12-31"));
-#elif defined(_WIN32) // defined(_AIX)
-  TEST_EQUAL(stream_c_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV(""));
-#else //  defined(_AIX)
   TEST_EQUAL(stream_c_locale(
  std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
  SV("32767-12-31"));
-#endif// defined(_AIX)
 
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{-32'768}, 
std::chrono::month{1}, std::chrono::day{1}}),
@@ -122,19 +108,9 @@ static void test() {
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, std::chrono::day{29}}),
  SV("2000-02-29"));
-#if defined(_AIX)
-  TEST_EQUAL(stream_fr_FR_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV("+32767-12-31"));
-#elif defined(_WIN32) // defined(_AIX)
-  TEST_EQUAL(stream_fr_FR_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV(""));
-#else // defined(_AIX)
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
  SV("32767-12-31"));
-#endif// defined(_AIX)
 
   TEST

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-21 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/85896

>From f3e7b583dd8eae59c3caeb84ac3967f361f6e6eb Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Thu, 21 Mar 2024 15:22:13 +0100
Subject: [PATCH 1/2] [libc++][chrono] Improves date formatting.

The formatting of years has been done manually since the results of %Y
outside the "typical" range may produce unexpected values. The same
applies to %F which is identical to %Y-%m-%d. Note of these conversion
specifiers is affected by the locale used. So it's trivial to manually
handle this case.

This removes several platform specific ifdefs from the tests.
---
 libcxx/include/__chrono/formatter.h   | 16 -
 .../time.cal.ymd.nonmembers/ostream.pass.cpp  | 34 ---
 .../sys_date.ostream.pass.cpp | 34 ---
 .../formatter.year_month_day.pass.cpp | 24 -
 4 files changed, 7 insertions(+), 101 deletions(-)

diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..217979e88c93db 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -322,15 +322,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 __formatter::__format_year(__sstr, __t.tm_year + 1900);
 break;
 
-  case _CharT('F'): {
-int __year = __t.tm_year + 1900;
-if (__year < 1000) {
-  __formatter::__format_year(__sstr, __year);
-  __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, 
"-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
-} else
-  __facet.put(
-  {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
-  } break;
+  case _CharT('F'):
+// Depending on the platform's libc the range of supported years is
+// limited. Intead of of testing all conditions use the internal
+// implementation unconditionally.
+__formatter::__format_year(__sstr, __t.tm_year + 1900);
+__sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, 
"-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
+break;
 
   case _CharT('z'):
 __formatter::__format_zone_offset(__sstr, __z.__offset, false);
diff --git 
a/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
 
b/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
index ffc737fcad5dd2..20ffb165558e31 100644
--- 
a/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
+++ 
b/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
@@ -13,9 +13,6 @@
 // TODO FMT This test should not require std::to_chars(floating-point)
 // XFAIL: availability-fp_to_chars-missing
 
-// TODO FMT Investigate Windows issues.
-// XFAIL: msvc
-
 // REQUIRES: locale.fr_FR.UTF-8
 // REQUIRES: locale.ja_JP.UTF-8
 
@@ -89,20 +86,9 @@ static void test() {
   TEST_EQUAL(stream_c_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, std::chrono::day{29}}),
  SV("2000-02-29"));
-
-#if defined(_AIX)
-  TEST_EQUAL(stream_c_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV("+32767-12-31"));
-#elif defined(_WIN32) // defined(_AIX)
-  TEST_EQUAL(stream_c_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV(""));
-#else //  defined(_AIX)
   TEST_EQUAL(stream_c_locale(
  std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
  SV("32767-12-31"));
-#endif// defined(_AIX)
 
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{-32'768}, 
std::chrono::month{1}, std::chrono::day{1}}),
@@ -122,19 +108,9 @@ static void test() {
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, std::chrono::day{29}}),
  SV("2000-02-29"));
-#if defined(_AIX)
-  TEST_EQUAL(stream_fr_FR_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV("+32767-12-31"));
-#elif defined(_WIN32) // defined(_AIX)
-  TEST_EQUAL(stream_fr_FR_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV(""));
-#else // defined(_AIX)
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
  SV("32767-12-31"));
-#endif// defined(_AIX)
 
   

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-21 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante edited 
https://github.com/llvm/llvm-project/pull/85896
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/18.x: Reapply [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#86020) (PR #86197)

2024-03-21 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante approved this pull request.


https://github.com/llvm/llvm-project/pull/86197
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds local_info formatter. (PR #86256)

2024-03-22 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/86256

This adds the local_info type and its formatting options.
The usage of the local_info object will be done in separate patches.

Implements parts of:
- P0355 Extending to Calendars and Time Zones
- P1361 Integration of chrono with text formatting

>From 891e126cb98a4e8d1ced5b64830b7cd08397d850 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Thu, 14 Mar 2024 21:10:58 +0100
Subject: [PATCH] [libc++][TZDB] Adds local_info formatter.

Note the code using a local_info object will be done in a separate
commit.

Implements parts of:
- P0355 Extending to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/convert_to_tm.h   |   3 +
 libcxx/include/__chrono/formatter.h   |  20 +++
 libcxx/include/__chrono/local_info.h  |  50 +++
 libcxx/include/__chrono/ostream.h |  22 +++
 libcxx/include/chrono |  16 +++
 libcxx/include/libcxx.imp |   1 +
 libcxx/modules/std/chrono.inc |   1 +
 .../time.zone.info.local/ostream.pass.cpp | 114 
 .../time.syn/formatter.local_info.pass.cpp| 126 ++
 .../time.zone.info.local/ostream.pass.cpp |  51 +++
 12 files changed, 406 insertions(+), 1 deletion(-)
 create mode 100644 libcxx/include/__chrono/local_info.h
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.local/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.local_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.local/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 32166ec72da753..b1a957c7b65dd1 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -25,7 +25,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
 `[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
-`[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::local_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
 `P2286R8 `__,"Formatting ranges"
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 2fc329d9e71457..a343e4c69c472c 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -283,6 +283,7 @@ set(files
   __chrono/high_resolution_clock.h
   __chrono/leap_second.h
   __chrono/literals.h
+  __chrono/local_info.h
   __chrono/month.h
   __chrono/month_weekday.h
   __chrono/monthday.h
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index d2c5cf922ba671..f7256db3bea661 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -16,6 +16,7 @@
 #include <__chrono/duration.h>
 #include <__chrono/file_clock.h>
 #include <__chrono/hh_mm_ss.h>
+#include <__chrono/local_info.h>
 #include <__chrono/month.h>
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
@@ -175,6 +176,8 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
 #  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
   } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
 // Has no time information.
+  } else if constexpr (same_as<_ChronoT, chrono::local_info>) {
+// Has no time information.
 #  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 79192fa103fbdb..a090eb0bfcc88a 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -18,6 +18,7 @@
 #include <__chrono/duration.h>
 #include <__chrono/file_clock.h>
 #include <__chrono/hh_mm_ss.h>
+#include <__chrono/local_info.h>
 #include <__chrono/month.h>
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
@@ -420,6 +421,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const 
_Tp& __value) {
 #  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
   else if constexpr (same_as<_Tp, chrono::sys_info>)
 return true;
+  else if constexpr (same_as<_Tp, chrono::local_info>)
+return true;
 #  endif
   else
 static_assert(

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds local_info formatter. (PR #86256)

2024-03-22 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/86256

>From 358347b163202b27b724543727d7602b4c4a19a8 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Thu, 14 Mar 2024 21:10:58 +0100
Subject: [PATCH] [libc++][TZDB] Adds local_info formatter.

Note the code using a local_info object will be done in a separate
commit.

Implements parts of:
- P0355 Extending to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/convert_to_tm.h   |   3 +
 libcxx/include/__chrono/formatter.h   |  20 +++
 libcxx/include/__chrono/local_info.h  |  50 +++
 libcxx/include/__chrono/ostream.h |  22 +++
 libcxx/include/chrono |  16 +++
 libcxx/include/libcxx.imp |   1 +
 libcxx/include/module.modulemap   |   1 +
 libcxx/modules/std/chrono.inc |   1 +
 .../time.zone.info.local/ostream.pass.cpp | 114 
 .../time.syn/formatter.local_info.pass.cpp| 126 ++
 .../time.zone.info.local/ostream.pass.cpp |  51 +++
 13 files changed, 407 insertions(+), 1 deletion(-)
 create mode 100644 libcxx/include/__chrono/local_info.h
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.local/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.local_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.local/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 32166ec72da753..b1a957c7b65dd1 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -25,7 +25,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
 `[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
-`[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::local_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
 `P2286R8 `__,"Formatting ranges"
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 2fc329d9e71457..a343e4c69c472c 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -283,6 +283,7 @@ set(files
   __chrono/high_resolution_clock.h
   __chrono/leap_second.h
   __chrono/literals.h
+  __chrono/local_info.h
   __chrono/month.h
   __chrono/month_weekday.h
   __chrono/monthday.h
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index d2c5cf922ba671..f7256db3bea661 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -16,6 +16,7 @@
 #include <__chrono/duration.h>
 #include <__chrono/file_clock.h>
 #include <__chrono/hh_mm_ss.h>
+#include <__chrono/local_info.h>
 #include <__chrono/month.h>
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
@@ -175,6 +176,8 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
 #  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
   } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
 // Has no time information.
+  } else if constexpr (same_as<_ChronoT, chrono::local_info>) {
+// Has no time information.
 #  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 79192fa103fbdb..a090eb0bfcc88a 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -18,6 +18,7 @@
 #include <__chrono/duration.h>
 #include <__chrono/file_clock.h>
 #include <__chrono/hh_mm_ss.h>
+#include <__chrono/local_info.h>
 #include <__chrono/month.h>
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
@@ -420,6 +421,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const 
_Tp& __value) {
 #  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
   else if constexpr (same_as<_Tp, chrono::sys_info>)
 return true;
+  else if constexpr (same_as<_Tp, chrono::local_info>)
+return true;
 #  endif
   else
 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
@@ -464,6 +467,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool 
__weekday_name_ok(const _Tp& __value) {
 #  if !defined(_LIBCPP_HAS_NO_INCOM

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds local_info formatter. (PR #86256)

2024-03-22 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/86256

>From 601338a04e28e356f0d9b90448ec2550f8870783 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Thu, 14 Mar 2024 21:10:58 +0100
Subject: [PATCH] [libc++][TZDB] Adds local_info formatter.

Note the code using a local_info object will be done in a separate
commit.

Implements parts of:
- P0355 Extending to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/convert_to_tm.h   |   3 +
 libcxx/include/__chrono/formatter.h   |  20 +++
 libcxx/include/__chrono/local_info.h  |  50 +++
 libcxx/include/__chrono/ostream.h |  22 +++
 libcxx/include/chrono |  16 +++
 libcxx/include/libcxx.imp |   1 +
 libcxx/include/module.modulemap   |   1 +
 libcxx/modules/std/chrono.inc |   1 +
 .../time.zone.info.local/ostream.pass.cpp | 114 
 .../time.syn/formatter.local_info.pass.cpp| 126 ++
 .../time.zone.info.local/ostream.pass.cpp |  53 
 13 files changed, 409 insertions(+), 1 deletion(-)
 create mode 100644 libcxx/include/__chrono/local_info.h
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.local/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.local_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.local/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 32166ec72da753..b1a957c7b65dd1 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -25,7 +25,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
 `[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
-`[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::local_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
 `P2286R8 `__,"Formatting ranges"
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 2fc329d9e71457..a343e4c69c472c 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -283,6 +283,7 @@ set(files
   __chrono/high_resolution_clock.h
   __chrono/leap_second.h
   __chrono/literals.h
+  __chrono/local_info.h
   __chrono/month.h
   __chrono/month_weekday.h
   __chrono/monthday.h
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index d2c5cf922ba671..f7256db3bea661 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -16,6 +16,7 @@
 #include <__chrono/duration.h>
 #include <__chrono/file_clock.h>
 #include <__chrono/hh_mm_ss.h>
+#include <__chrono/local_info.h>
 #include <__chrono/month.h>
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
@@ -175,6 +176,8 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
 #  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
   } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
 // Has no time information.
+  } else if constexpr (same_as<_ChronoT, chrono::local_info>) {
+// Has no time information.
 #  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 79192fa103fbdb..a090eb0bfcc88a 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -18,6 +18,7 @@
 #include <__chrono/duration.h>
 #include <__chrono/file_clock.h>
 #include <__chrono/hh_mm_ss.h>
+#include <__chrono/local_info.h>
 #include <__chrono/month.h>
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
@@ -420,6 +421,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const 
_Tp& __value) {
 #  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
   else if constexpr (same_as<_Tp, chrono::sys_info>)
 return true;
+  else if constexpr (same_as<_Tp, chrono::local_info>)
+return true;
 #  endif
   else
 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
@@ -464,6 +467,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool 
__weekday_name_ok(const _Tp& __value) {
 #  if !defined(_LIBCPP_HAS_NO_INCO

[llvm-branch-commits] [libcxx] release/18.x: Reapply [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#86020) (PR #86197)

2024-03-28 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

> @mordante Is the test failure legitimate?

I've checked and the test failure is unrelated to this patch.

https://github.com/llvm/llvm-project/pull/86197
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/18.x: [libcxx] coerce formatter precision to int (#87738) (PR #87801)

2024-04-05 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante approved this pull request.


https://github.com/llvm/llvm-project/pull/87801
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][format] Improves escaping. (PR #88283)

2024-04-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/88283

The change increments the size of the lookup table considerably. The table has 
an "upper boundary" check. The removal of the code units with the property 
Grapheme_Extend=Yes removes the range E0100..E01EF. This breaks the trailing 
large continues section in two parts. This will be improved in a followup patch.

Implements:
- P2713R1 Escaping improvements in std::format
- LWG3965 Incorrect example in [format.string.escaped] p3 for formatting of 
combining characters

Before
---
Benchmark Time CPU   Iterations
---
BM_ascii_escaped95696 ns95459 ns 7341
BM_unicode_escaped  89311 ns89088 ns 7835
BM_cyrillic_escaped 58633 ns58494 ns11964
BM_japanese_escaped 44500 ns44382 ns15780
BM_emoji_escaped99156 ns98911 ns 7075
BM_ascii_escaped 92245 ns92017 ns 7592
BM_unicode_escaped   80970 ns80747 ns 8651
BM_cyrillic_escaped  51253 ns51112 ns13729
BM_japanese_escaped  37252 ns37156 ns18758
BM_emoji_escaped 96226 ns95961 ns 7270

After
---
Benchmark Time CPU   Iterations
---
BM_ascii_escaped   110704 ns   110696 ns 6206
BM_unicode_escaped 101371 ns   101374 ns 6862
BM_cyrillic_escaped 63329 ns63327 ns11013
BM_japanese_escaped 41223 ns41225 ns16938
BM_emoji_escaped   111022 ns   111021 ns 6304
BM_ascii_escaped112441 ns   112443 ns 6231
BM_unicode_escaped  102776 ns   102779 ns 6813
BM_cyrillic_escaped  58977 ns58975 ns11868
BM_japanese_escaped  36885 ns36886 ns18975
BM_emoji_escaped115885 ns   115881 ns 6051

>From 1f06034f8d6fc581b0b3d4c3d1f0ed8ef491979a Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sat, 3 Feb 2024 17:08:59 +0100
Subject: [PATCH] [libc++][format] Improves escaping.

The change increments the size of the lookup table considerably. The table
has an "upper boundary" check. The removal of the code units with the
property Grapheme_Extend=Yes removes the range E0100..E01EF. This breaks
the trailing large continues section in two parts. This will be improved
in a followup patch.

Implements:
- P2713R1 Escaping improvements in std::format
- LWG3965 Incorrect example in [format.string.escaped] p3 for formatting of 
combining characters

Before
---
Benchmark Time CPU   Iterations
---
BM_ascii_escaped95696 ns95459 ns 7341
BM_unicode_escaped  89311 ns89088 ns 7835
BM_cyrillic_escaped 58633 ns58494 ns11964
BM_japanese_escaped 44500 ns44382 ns15780
BM_emoji_escaped99156 ns98911 ns 7075
BM_ascii_escaped 92245 ns92017 ns 7592
BM_unicode_escaped   80970 ns80747 ns 8651
BM_cyrillic_escaped  51253 ns51112 ns13729
BM_japanese_escaped  37252 ns37156 ns18758
BM_emoji_escaped 96226 ns95961 ns 7270

After
---
Benchmark Time CPU   Iterations
---
BM_ascii_escaped   110704 ns   110696 ns 6206
BM_unicode_escaped 101371 ns   101374 ns 6862
BM_cyrillic_escaped 63329 ns63327 ns11013
BM_japanese_escaped 41223 ns41225 ns16938
BM_emoji_escaped   111022 ns   111021 ns 6304
BM_ascii_escaped112441 ns   112443 ns 6231
BM_unicode_escaped  102776 ns   102779 ns 6813
BM_cyrillic_escaped  58977 ns58975 ns11868
BM_japanese_escaped  36885 ns36886 ns18975
BM_emoji_escaped115885 ns   115881 ns 6051
---
 libcxx/docs/ReleaseNotes/19.rst   |2 +
 libcxx/docs/Status/Cxx23Papers.csv|2 +-
 libcxx/docs/Status/Cxx2cIssues.csv|2 +-
 libcxx/docs/Status/FormatIssues.csv   |2 +-
 .../include/__format/escaped_output_table.h   | 1982 +
 libcxx

[llvm-branch-commits] [libcxx] [libc++][TZDB] Improves time zone format specifiers. (PR #85797)

2024-04-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/85797

>From cb87ecc505cf538eaa657a7cc3b1b282e3e7298d Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Improves time zone format specifiers.

Per [tab:time.format.spec]
%z  The offset from UTC as specified in ISO 8601-1:2019, subclause
5.3.4.1. For example -0430 refers to 4 hours 30 minutes behind UTC.
If the offset is zero, + is used. The modified commands %Ez and
%Oz insert a : between the hours and minutes: -04:30. If the offset
information is not available, an exception of type format_error is
thrown.

Typically the modified versions Oz or Ez would have wording like

  The modified command %OS produces the locale's alternative
  representation.

In this case the modified version does not depend on the locale.

This change is a preparation for formatting sys_info which has time zone
information. The function time_put<_CharT>::put() does not have proper
time zone support, therefore it's a manual implementation.

Fixes https://github.com/llvm/llvm-project/issues/78184
---
 libcxx/include/__chrono/formatter.h   | 50 ++-
 .../time.syn/formatter.file_time.pass.cpp | 39 ++-
 .../time/time.syn/formatter.sys_time.pass.cpp | 39 ++-
 3 files changed, 56 insertions(+), 72 deletions(-)

diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index b64cae529a294d..8b8592041a1fb9 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -10,6 +10,7 @@
 #ifndef _LIBCPP___CHRONO_FORMATTER_H
 #define _LIBCPP___CHRONO_FORMATTER_H
 
+#include <__algorithm/ranges_copy.h>
 #include <__chrono/calendar.h>
 #include <__chrono/concepts.h>
 #include <__chrono/convert_to_tm.h>
@@ -170,10 +171,45 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_century(basic_stringstream<_CharT>& __sstr,
   __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __century);
 }
 
+// Implements the %z format specifier according to [tab:time.format.spec], 
where
+// '__modifier' signals %Oz or %Ez were used. (Both modifiers behave the same,
+// so there is no need to distinguish between them.)
+template 
+_LIBCPP_HIDE_FROM_ABI void
+__format_zone_offset(basic_stringstream<_CharT>& __sstr, chrono::seconds 
__offset, bool __modifier) {
+  if (__offset < 0s) {
+__sstr << _CharT('-');
+__offset = -__offset;
+  } else
+__sstr << _CharT('+');
+
+  chrono::hh_mm_ss __hms{__offset};
+  std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  if (__modifier)
+std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
+  else
+std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+}
+
+// Helper to store the time zone information needed for formatting.
+struct _LIBCPP_HIDE_FROM_ABI __time_zone {
+  // Typically these abbreviations as short and fit in the string's internal
+  // buffer.
+  string __abbrev{"UTC"};
+  chrono::seconds __offset{0};
+};
+
+template 
+_LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
+  __time_zone __result;
+  return __result;
+}
+
 template 
 _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
 basic_stringstream<_CharT>& __sstr, const _Tp& __value, 
basic_string_view<_CharT> __chrono_specs) {
   tm __t  = std::__convert_to_tm(__value);
+  __time_zone __z = __formatter::__convert_to_time_zone(__value);
   const auto& __facet = std::use_facet>(__sstr.getloc());
   for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); 
++__it) {
 if (*__it == _CharT('%')) {
@@ -296,9 +332,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
   {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
   } break;
 
+  case _CharT('z'):
+__formatter::__format_zone_offset(__sstr, __z.__offset, false);
+break;
+
   case _CharT('Z'):
-// TODO FMT Add proper timezone support.
-__sstr << _LIBCPP_STATICALLY_WIDEN(_CharT, "UTC");
+// __abbrev is always a char so the copy may convert.
+ranges::copy(__z.__abbrev, std::ostreambuf_iterator<_CharT>{__sstr});
 break;
 
   case _CharT('O'):
@@ -314,9 +354,15 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 break;
   }
 }
+
+// Oz produces the same output as Ez below.
 [[fallthrough]];
   case _CharT('E'):
 ++__it;
+if (*__it == 'z') {
+  __formatter::__format_zone_offset(__sstr, __z.__offset, true);
+  break;
+}
 [[fallthrough]];
   default:
 __facet.put(
diff --git a/libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp 
b/libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp
index b07282593d

[llvm-branch-commits] [libcxx] [libc++][chrono] Improves date formatting. (PR #86127)

2024-04-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/86127

>From 677956d0923c499f8f6d1f13035f5f60d48ea7c8 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Thu, 21 Mar 2024 15:22:13 +0100
Subject: [PATCH] [libc++][chrono] Improves date formatting.

The formatting of years has been done manually since the results of %Y
outside the "typical" range may produce unexpected values. The same
applies to %F which is identical to %Y-%m-%d. Note of these conversion
specifiers is affected by the locale used. So it's trivial to manually
handle this case.

This removes several platform specific ifdefs from the tests.
---
 libcxx/include/__chrono/formatter.h   | 16 -
 .../time.cal.ymd.nonmembers/ostream.pass.cpp  | 34 ---
 .../sys_date.ostream.pass.cpp | 34 ---
 .../formatter.year_month_day.pass.cpp | 24 -
 4 files changed, 7 insertions(+), 101 deletions(-)

diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..217979e88c93db 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -322,15 +322,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 __formatter::__format_year(__sstr, __t.tm_year + 1900);
 break;
 
-  case _CharT('F'): {
-int __year = __t.tm_year + 1900;
-if (__year < 1000) {
-  __formatter::__format_year(__sstr, __year);
-  __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, 
"-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
-} else
-  __facet.put(
-  {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
-  } break;
+  case _CharT('F'):
+// Depending on the platform's libc the range of supported years is
+// limited. Intead of of testing all conditions use the internal
+// implementation unconditionally.
+__formatter::__format_year(__sstr, __t.tm_year + 1900);
+__sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, 
"-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
+break;
 
   case _CharT('z'):
 __formatter::__format_zone_offset(__sstr, __z.__offset, false);
diff --git 
a/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
 
b/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
index ffc737fcad5dd2..20ffb165558e31 100644
--- 
a/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
+++ 
b/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
@@ -13,9 +13,6 @@
 // TODO FMT This test should not require std::to_chars(floating-point)
 // XFAIL: availability-fp_to_chars-missing
 
-// TODO FMT Investigate Windows issues.
-// XFAIL: msvc
-
 // REQUIRES: locale.fr_FR.UTF-8
 // REQUIRES: locale.ja_JP.UTF-8
 
@@ -89,20 +86,9 @@ static void test() {
   TEST_EQUAL(stream_c_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, std::chrono::day{29}}),
  SV("2000-02-29"));
-
-#if defined(_AIX)
-  TEST_EQUAL(stream_c_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV("+32767-12-31"));
-#elif defined(_WIN32) // defined(_AIX)
-  TEST_EQUAL(stream_c_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV(""));
-#else //  defined(_AIX)
   TEST_EQUAL(stream_c_locale(
  std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
  SV("32767-12-31"));
-#endif// defined(_AIX)
 
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{-32'768}, 
std::chrono::month{1}, std::chrono::day{1}}),
@@ -122,19 +108,9 @@ static void test() {
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, std::chrono::day{29}}),
  SV("2000-02-29"));
-#if defined(_AIX)
-  TEST_EQUAL(stream_fr_FR_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV("+32767-12-31"));
-#elif defined(_WIN32) // defined(_AIX)
-  TEST_EQUAL(stream_fr_FR_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV(""));
-#else // defined(_AIX)
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
  SV("32767-12-31"));
-#endif// defined(_AIX)
 
   TEST

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-04-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/85896

>From de4ba883c354ab8510fb0e5e4ad2a09d93000c30 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Adds sys_info formatter.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/__chrono/convert_to_tm.h   |   5 +
 libcxx/include/__chrono/formatter.h   |  44 +-
 libcxx/include/__chrono/ostream.h |  20 +++
 libcxx/include/__chrono/sys_info.h|   2 +-
 libcxx/include/chrono |   5 +
 .../time.zone.info.sys/ostream.pass.cpp   |  74 ++
 .../time/time.syn/formatter.sys_info.pass.cpp | 137 ++
 .../time.zone.info.sys/ostream.pass.cpp   |  52 +++
 .../concept.formattable.compile.pass.cpp  |   2 +-
 10 files changed, 337 insertions(+), 6 deletions(-)
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index e9d407e79e2539..8ace18815f5375 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 217979e88c93db..79192fa103fbdb 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -185,10 +186,11 @@ __format_zone_offset(basic_stringstream<_CharT>& __sstr, 
chrono::seconds __offse
 
   chrono::hh_mm_ss __hms{__offset};
   std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  // Note HMS does not allow formatting hours > 23, but the offset is not 
limited to 24H.
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.hours().count());
   if (__modifier)
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
-  else
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+__sstr << _CharT(':');
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.minutes().count());
 }
 
 // Helper to store the time zone information needed for formatting.
@@ -202,6 +204,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone __result;
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)

[llvm-branch-commits] [libcxx] release/18.x: [libc++] Fix -Wgnu-include-next in stddef.h (#88214) (PR #88419)

2024-04-12 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante approved this pull request.


https://github.com/llvm/llvm-project/pull/88419
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/18.x: [libcxx] coerce formatter precision to int (#87738) (PR #87801)

2024-04-12 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

> > Is it OK to merge this with the failing test?
> 
> is it possible this was a fix for an XFAIL @mordante ?

This failure is in completely unrelated code. So I'm happy to merge it with the 
CI failure.

https://github.com/llvm/llvm-project/pull/87801
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-04-12 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/85896

>From e6ae1f07641b79b63b772b866176ffef94a25d48 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Adds sys_info formatter.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/__chrono/convert_to_tm.h   |   5 +
 libcxx/include/__chrono/formatter.h   |  46 +-
 libcxx/include/__chrono/ostream.h |  20 +++
 libcxx/include/__chrono/sys_info.h|   2 +-
 libcxx/include/chrono |   5 +
 .../time.zone.info.sys/ostream.pass.cpp   |  74 ++
 .../time/time.syn/formatter.sys_info.pass.cpp | 137 ++
 .../time.zone.info.sys/ostream.pass.cpp   |  52 +++
 .../concept.formattable.compile.pass.cpp  |   5 +-
 libcxx/test/support/test_macros.h |   8 +
 11 files changed, 350 insertions(+), 6 deletions(-)
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index e9d407e79e2539..8ace18815f5375 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 217979e88c93db..e3235a9b5b5cf5 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -185,10 +186,11 @@ __format_zone_offset(basic_stringstream<_CharT>& __sstr, 
chrono::seconds __offse
 
   chrono::hh_mm_ss __hms{__offset};
   std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  // Note HMS does not allow formatting hours > 23, but the offset is not 
limited to 24H.
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.hours().count());
   if (__modifier)
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
-  else
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+__sstr << _CharT(':');
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.minutes().count());
 }
 
 // Helper to store the time zone information needed for formatting.
@@ -202,6 +204,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone __

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-04-13 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/85896

>From 96bc907e4f38cd771bc8fed3936932b841c6bd26 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Adds sys_info formatter.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/__chrono/convert_to_tm.h   |   5 +
 libcxx/include/__chrono/formatter.h   |  44 +-
 libcxx/include/__chrono/ostream.h |  20 +++
 libcxx/include/__chrono/sys_info.h|   2 +-
 libcxx/include/chrono |   5 +
 .../time.zone.info.sys/ostream.pass.cpp   |  74 ++
 .../time/time.syn/formatter.sys_info.pass.cpp | 137 ++
 .../time.zone.info.sys/ostream.pass.cpp   |  52 +++
 .../concept.formattable.compile.pass.cpp  |   4 +-
 libcxx/test/support/test_macros.h |   8 +
 11 files changed, 347 insertions(+), 6 deletions(-)
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index e9d407e79e2539..8ace18815f5375 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 217979e88c93db..79192fa103fbdb 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -185,10 +186,11 @@ __format_zone_offset(basic_stringstream<_CharT>& __sstr, 
chrono::seconds __offse
 
   chrono::hh_mm_ss __hms{__offset};
   std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  // Note HMS does not allow formatting hours > 23, but the offset is not 
limited to 24H.
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.hours().count());
   if (__modifier)
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
-  else
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+__sstr << _CharT(':');
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.minutes().count());
 }
 
 // Helper to store the time zone information needed for formatting.
@@ -202,6 +204,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone __

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds local_info formatter. (PR #86256)

2024-04-13 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/86256

>From 42728d0c66c0a9592949d7bad611bd7d8fe1cd5e Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Thu, 14 Mar 2024 21:10:58 +0100
Subject: [PATCH] [libc++][TZDB] Adds local_info formatter.

Note the code using a local_info object will be done in a separate
commit.

Implements parts of:
- P0355 Extending to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/convert_to_tm.h   |   3 +
 libcxx/include/__chrono/formatter.h   |  20 +++
 libcxx/include/__chrono/local_info.h  |  50 +++
 libcxx/include/__chrono/ostream.h |  22 +++
 libcxx/include/chrono |  16 +++
 libcxx/include/libcxx.imp |   1 +
 libcxx/include/module.modulemap   |   1 +
 libcxx/modules/std/chrono.inc |   1 +
 .../time.zone.info.local/ostream.pass.cpp | 114 
 .../time.syn/formatter.local_info.pass.cpp| 126 ++
 .../time.zone.info.local/ostream.pass.cpp |  53 
 .../concept.formattable.compile.pass.cpp  |   2 +-
 14 files changed, 410 insertions(+), 2 deletions(-)
 create mode 100644 libcxx/include/__chrono/local_info.h
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.local/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.local_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.local/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 8ace18815f5375..f29f1f7ca74875 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -25,7 +25,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
 `[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
-`[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::local_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
 "`P2693R1 `__","Formatting ``thread::id`` and 
``stacktrace``"
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index a4a58a787ee9ae..ac46b545ea75d2 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -284,6 +284,7 @@ set(files
   __chrono/high_resolution_clock.h
   __chrono/leap_second.h
   __chrono/literals.h
+  __chrono/local_info.h
   __chrono/month.h
   __chrono/month_weekday.h
   __chrono/monthday.h
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index d2c5cf922ba671..f7256db3bea661 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -16,6 +16,7 @@
 #include <__chrono/duration.h>
 #include <__chrono/file_clock.h>
 #include <__chrono/hh_mm_ss.h>
+#include <__chrono/local_info.h>
 #include <__chrono/month.h>
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
@@ -175,6 +176,8 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
 #  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
   } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
 // Has no time information.
+  } else if constexpr (same_as<_ChronoT, chrono::local_info>) {
+// Has no time information.
 #  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 79192fa103fbdb..a090eb0bfcc88a 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -18,6 +18,7 @@
 #include <__chrono/duration.h>
 #include <__chrono/file_clock.h>
 #include <__chrono/hh_mm_ss.h>
+#include <__chrono/local_info.h>
 #include <__chrono/month.h>
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
@@ -420,6 +421,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const 
_Tp& __value) {
 #  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
   else if constexpr (same_as<_Tp, chrono::sys_info>)
 return true;
+  else if constexpr (same_as<_Tp, chrono::local_info>)
+return true;
 #  endif
   else
 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
@@ -464,6 +467,8 @@ _LIBCPP_HIDE_FROM_ABI cons

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds local_info formatter. (PR #86256)

2024-04-13 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/86256

>From 73d01a392239c643c1636e9b34310c42f20b3c90 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Thu, 14 Mar 2024 21:10:58 +0100
Subject: [PATCH] [libc++][TZDB] Adds local_info formatter.

Note the code using a local_info object will be done in a separate
commit.

Implements parts of:
- P0355 Extending to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/convert_to_tm.h   |   3 +
 libcxx/include/__chrono/formatter.h   |  20 +++
 libcxx/include/__chrono/local_info.h  |  50 +++
 libcxx/include/__chrono/ostream.h |  22 +++
 libcxx/include/chrono |  16 +++
 libcxx/include/libcxx.imp |   1 +
 libcxx/include/module.modulemap   |   1 +
 libcxx/modules/std/chrono.inc |   1 +
 .../time.zone.info.local/ostream.pass.cpp | 114 
 .../time.syn/formatter.local_info.pass.cpp| 126 ++
 .../time.zone.info.local/ostream.pass.cpp |  53 
 .../concept.formattable.compile.pass.cpp  |   2 +-
 14 files changed, 410 insertions(+), 2 deletions(-)
 create mode 100644 libcxx/include/__chrono/local_info.h
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.local/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.local_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.local/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 8ace18815f5375..f29f1f7ca74875 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -25,7 +25,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
 `[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
-`[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::local_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
 "`P2693R1 `__","Formatting ``thread::id`` and 
``stacktrace``"
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index a4a58a787ee9ae..ac46b545ea75d2 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -284,6 +284,7 @@ set(files
   __chrono/high_resolution_clock.h
   __chrono/leap_second.h
   __chrono/literals.h
+  __chrono/local_info.h
   __chrono/month.h
   __chrono/month_weekday.h
   __chrono/monthday.h
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index d2c5cf922ba671..f7256db3bea661 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -16,6 +16,7 @@
 #include <__chrono/duration.h>
 #include <__chrono/file_clock.h>
 #include <__chrono/hh_mm_ss.h>
+#include <__chrono/local_info.h>
 #include <__chrono/month.h>
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
@@ -175,6 +176,8 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
 #  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
   } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
 // Has no time information.
+  } else if constexpr (same_as<_ChronoT, chrono::local_info>) {
+// Has no time information.
 #  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 79192fa103fbdb..a090eb0bfcc88a 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -18,6 +18,7 @@
 #include <__chrono/duration.h>
 #include <__chrono/file_clock.h>
 #include <__chrono/hh_mm_ss.h>
+#include <__chrono/local_info.h>
 #include <__chrono/month.h>
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
@@ -420,6 +421,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const 
_Tp& __value) {
 #  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
   else if constexpr (same_as<_Tp, chrono::sys_info>)
 return true;
+  else if constexpr (same_as<_Tp, chrono::local_info>)
+return true;
 #  endif
   else
 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
@@ -464,6 +467,8 @@ _LIBCPP_HIDE_FROM_ABI cons

[llvm-branch-commits] [libcxx] [libc++][chrono] Fixes format output of negative values. (PR #89408)

2024-04-19 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/89408

The negative values were shown as

  1900-01-01 00:01:39.-0001

after the changes they are shown as

  1900-01-01 00:01:39.9

>From 11fa6e806dd9a2a6f0a036041de8245f5bcd Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Tue, 16 Apr 2024 20:57:19 +0200
Subject: [PATCH] [libc++][chrono] Fixes format output of negative values.

The negative values were shown as

  1900-01-01 00:01:39.-0001

after the changes they are shown as

  1900-01-01 00:01:39.9
---
 libcxx/include/__chrono/formatter.h   |  3 ++
 .../time.clock.file/ostream.pass.cpp  | 54 +++
 .../time.clock.local/ostream.pass.cpp | 54 +++
 .../sys_time.ostream.pass.cpp | 54 +++
 4 files changed, 165 insertions(+)

diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 226fccbee6d133..058e9ac97bc941 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -88,6 +88,9 @@ __format_sub_seconds(basic_stringstream<_CharT>& __sstr, 
const chrono::duration<
   using __duration = chrono::duration<_Rep, _Period>;
 
   auto __fraction = __value - chrono::duration_cast(__value);
+  // Converts a negative fraction to its positive value.
+  if (__value < chrono::seconds{0})
+__fraction += chrono::seconds{1};
   if constexpr (chrono::treat_as_floating_point_v<_Rep>)
 // When the floating-point value has digits itself they are ignored based
 // on the wording in [tab:time.format.spec]
diff --git a/libcxx/test/std/time/time.clock/time.clock.file/ostream.pass.cpp 
b/libcxx/test/std/time/time.clock/time.clock.file/ostream.pass.cpp
index 18a4506b91566b..99d56002e9c391 100644
--- a/libcxx/test/std/time/time.clock/time.clock.file/ostream.pass.cpp
+++ b/libcxx/test/std/time/time.clock/time.clock.file/ostream.pass.cpp
@@ -71,6 +71,24 @@ template 
 static void test_c() {
   using namespace std::literals::chrono_literals;
 
+  
assert(stream_c_locale(std::chrono::file_time{-946'688'523'123'456'789ns})
 ==
+ SV("1940-01-01 22:57:56.876543211"));
+
+  
assert(stream_c_locale(std::chrono::file_time{-946'688'523'123'456us})
 ==
+ SV("1940-01-01 22:57:56.876544"));
+
+  
assert(stream_c_locale(std::chrono::file_time{-946'688'523'123ms})
 ==
+ SV("1940-01-01 22:57:56.877"));
+
+  
assert(stream_c_locale(std::chrono::file_time{-1ns})
 ==
+ SV("1969-12-31 23:59:59.9"));
+
+  
assert(stream_c_locale(std::chrono::file_time{0ns})
 ==
+ SV("1970-01-01 00:00:00.0"));
+
+  
assert(stream_c_locale(std::chrono::file_time{1ns})
 ==
+ SV("1970-01-01 00:00:00.1"));
+
   
assert(stream_c_locale(file_time{946'688'523'123'456'789ns})
 ==
  SV("2000-01-01 01:02:03.123456789"));
   
assert(stream_c_locale(file_time{946'688'523'123'456us})
 ==
@@ -107,6 +125,24 @@ template 
 static void test_fr_FR() {
   using namespace std::literals::chrono_literals;
 
+  
assert(stream_fr_FR_locale(std::chrono::file_time{-946'688'523'123'456'789ns})
 ==
+ SV("1940-01-01 22:57:56,876543211"));
+
+  
assert(stream_fr_FR_locale(std::chrono::file_time{-946'688'523'123'456us})
 ==
+ SV("1940-01-01 22:57:56,876544"));
+
+  
assert(stream_fr_FR_locale(std::chrono::file_time{-946'688'523'123ms})
 ==
+ SV("1940-01-01 22:57:56,877"));
+
+  
assert(stream_fr_FR_locale(std::chrono::file_time{-1ns})
 ==
+ SV("1969-12-31 23:59:59,9"));
+
+  
assert(stream_fr_FR_locale(std::chrono::file_time{0ns})
 ==
+ SV("1970-01-01 00:00:00,0"));
+
+  
assert(stream_fr_FR_locale(std::chrono::file_time{1ns})
 ==
+ SV("1970-01-01 00:00:00,1"));
+
   
assert(stream_fr_FR_locale(file_time{946'688'523'123'456'789ns})
 ==
  SV("2000-01-01 01:02:03,123456789"));
   
assert(stream_fr_FR_locale(file_time{946'688'523'123'456us})
 ==
@@ -144,6 +180,24 @@ template 
 static void test_ja_JP() {
   using namespace std::literals::chrono_literals;
 
+  
assert(stream_ja_JP_locale(std::chrono::file_time{-946'688'523'123'456'789ns})
 ==
+ SV("1940-01-01 22:57:56.876543211"));
+
+  
assert(stream_ja_JP_locale(std::chrono::file_time{-946'688'523'123'456us})
 ==
+ SV("1940-01-01 22:57:56.876544"));
+
+  
assert(stream_ja_JP_locale(std::chrono::file_time{-946'688'523'123ms})
 ==
+ SV("1940-01-01 22:57:56.877"));
+
+  
assert(stream_ja_JP_locale(std::chrono::file_time{-1ns})
 ==
+ SV("1969-12-31 23:59:59.9"));
+
+  
assert(stream_ja_JP_locale(std::chrono::file_time{0ns})
 ==
+ SV("1970-01-01 00:00:00.0"));
+
+  
assert(stream_ja_JP_locale(std::chrono::file_time{1ns})
 ==
+ SV("1970-01-01 00:00:00.1"));
+
   
assert(stream_ja_JP_locale(file_time{946'688'523'123'456'789ns})
 ==
  SV("2000-01-01 01:02:03.123456789"));
   
assert(stream_ja_JP_locale(fi

[llvm-branch-commits] [libcxx] [libc++][TZDB] Fixes reverse time lookups. (PR #89498)

2024-04-20 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/89498

Testing with the get_info() returning a local_info revealed some issues in the 
reverse lookup. This needed an additional quirck. Also the skipping when not in 
the current continuation optimization was wrong. It prevented merging two 
sys_info objects.

>From 26f7f3abb6398a749810230f08c2ef4db5150e6f Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Fixes reverse time lookups.

Testing with the get_info() returning a local_info revealed some issues in
the reverse lookup. This needed an additional quirck. Also the skipping
when not in the current continuation optimization was wrong. It prevented
merging two sys_info objects.
---
 libcxx/src/time_zone.cpp  | 19 -
 .../get_info.sys_time.pass.cpp| 76 +++
 2 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/libcxx/src/time_zone.cpp b/libcxx/src/time_zone.cpp
index aef6ac674a11e6..928f3d2855e456 100644
--- a/libcxx/src/time_zone.cpp
+++ b/libcxx/src/time_zone.cpp
@@ -567,11 +567,22 @@ __first_rule(seconds __stdoff, const 
vector<__tz::__rule>& __rules) {
 false};
   }
 
-  __named_rule_until __continuation_end{__continuation};
-  if (__time >= __continuation_end.__until() && 
!__continuation_end.__needs_adjustment())
-// note std::unexpected(__end); is ambiguous with 
std::unexpected() in ,
-return __sys_info_result{std::unexpect, __continuation_end.__until()};
+  if (__rule->__save.__time != 0s) {
+// another fix for America/Punta_Arenas when not at the start of the
+// sys_info object.
+seconds __save = __rule->__save.__time;
+if (__continuation_begin >= __rule_begin - __save && __time < 
__next.first) {
+  return __sys_info{
+  sys_info{__continuation_begin,
+   __next.first,
+   __continuation.__stdoff + __save,
+   chrono::duration_cast(__save),
+   chrono::__format(__continuation, __rule->__letters, 
__save)},
+  false};
+}
+  }
 
+  __named_rule_until __continuation_end{__continuation};
   while (__next.second != __rules.end()) {
 #ifdef PRINT
 std::print(
diff --git 
a/libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp
 
b/libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp
index 25d2ff11d09341..1a1705d5ae59a5 100644
--- 
a/libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp
+++ 
b/libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp
@@ -1299,6 +1299,78 @@ static void test_america_indiana_knox() {
tz->get_info(to_sys_seconds(2006y, std::chrono::October, 29d, 
6h, 59min, 59s)));
 }
 
+static void test_america_punta_arenas() {
+  // Z America/Punta_Arenas -4:43:40 - LMT 1890
+  // ...
+  // -4 - -04 1919 Jul
+  // -4:42:45 - SMT 1927 S
+  // -5 x -05/-04 1932 S
+  // ...
+  //
+  // R x 1927 1931 - S 1 0 1 -
+  // R x 1928 1932 - Ap 1 0 0 -
+  // ...
+
+  using namespace std::literals::chrono_literals;
+  const std::chrono::time_zone* tz = 
std::chrono::locate_zone("America/Punta_Arenas");
+
+  assert_equal(
+  std::chrono::sys_info(
+  to_sys_seconds(1927y, std::chrono::September, 1d, 4h, 42min, 45s),
+  to_sys_seconds(1928y, std::chrono::April, 1d, 4h),
+  -4h,
+  60min,
+  "-04"),
+  tz->get_info(to_sys_seconds(1927y, std::chrono::September, 1d, 4h, 
42min, 45s)));
+
+  assert_equal(
+  std::chrono::sys_info(
+  to_sys_seconds(1927y, std::chrono::September, 1d, 4h, 42min, 45s),
+  to_sys_seconds(1928y, std::chrono::April, 1d, 4h),
+  -4h,
+  60min,
+  "-04"),
+  tz->get_info(to_sys_seconds(1928y, std::chrono::April, 1d, 3h, 59min, 
59s)));
+}
+
+static void test_europ_ljubljana() {
+  // Z Europe/Ljubljana 0:58:4 - LMT 1884
+  // 1 - CET 1941 Ap 18 23
+  // 1 c CE%sT 1945 May 8 2s
+  // 1 1 CEST 1945 S 16 2s
+  // 1 - CET 1982 N 27
+  // 1 E CE%sT
+  //
+  // ...
+  // R c 1943 o - O 4 2s 0 -
+  // R c 1944 1945 - Ap M>=1 2s 1 S
+  // R c 1944 o - O 2 2s 0 -
+  // R c 1945 o - S 16 2s 0 -
+  // R c 1977 1980 - Ap Su>=1 2s 1 S
+  // ...
+
+  using namespace std::literals::chrono_literals;
+  const std::chrono::time_zone* tz = 
std::chrono::locate_zone("Europe/Ljubljana");
+
+  assert_equal(
+  std::chrono::sys_info(
+  to_sys_seconds(1945y, std::chrono::April, 2d, 1h),
+  to_sys_seconds(1945y, std::chrono::September, 16d, 1h),
+  2h,
+  60min,
+  "CEST"),
+  tz->get_info(to_sys_seconds(1945y, std::chrono::April, 2d, 1h)));
+
+  assert_equal(
+  std::chrono::sys_info(
+  to_sys_seconds(1945y, std::chrono::April, 2d, 1h),
+  to_sys_seconds(1945y, std::chrono::September, 16

[llvm-branch-commits] [libcxx] [libc++][TZDB] Fixes reverse time lookups. (PR #89502)

2024-04-20 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/89502

Testing with the get_info() returning a local_info revealed some issues in the 
reverse lookup. This needed an additional quirck. Also the skipping when not in 
the current continuation optimization was wrong. It prevented merging two 
sys_info objects.

>From 26f7f3abb6398a749810230f08c2ef4db5150e6f Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Fixes reverse time lookups.

Testing with the get_info() returning a local_info revealed some issues in
the reverse lookup. This needed an additional quirck. Also the skipping
when not in the current continuation optimization was wrong. It prevented
merging two sys_info objects.
---
 libcxx/src/time_zone.cpp  | 19 -
 .../get_info.sys_time.pass.cpp| 76 +++
 2 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/libcxx/src/time_zone.cpp b/libcxx/src/time_zone.cpp
index aef6ac674a11e6..928f3d2855e456 100644
--- a/libcxx/src/time_zone.cpp
+++ b/libcxx/src/time_zone.cpp
@@ -567,11 +567,22 @@ __first_rule(seconds __stdoff, const 
vector<__tz::__rule>& __rules) {
 false};
   }
 
-  __named_rule_until __continuation_end{__continuation};
-  if (__time >= __continuation_end.__until() && 
!__continuation_end.__needs_adjustment())
-// note std::unexpected(__end); is ambiguous with 
std::unexpected() in ,
-return __sys_info_result{std::unexpect, __continuation_end.__until()};
+  if (__rule->__save.__time != 0s) {
+// another fix for America/Punta_Arenas when not at the start of the
+// sys_info object.
+seconds __save = __rule->__save.__time;
+if (__continuation_begin >= __rule_begin - __save && __time < 
__next.first) {
+  return __sys_info{
+  sys_info{__continuation_begin,
+   __next.first,
+   __continuation.__stdoff + __save,
+   chrono::duration_cast(__save),
+   chrono::__format(__continuation, __rule->__letters, 
__save)},
+  false};
+}
+  }
 
+  __named_rule_until __continuation_end{__continuation};
   while (__next.second != __rules.end()) {
 #ifdef PRINT
 std::print(
diff --git 
a/libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp
 
b/libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp
index 25d2ff11d09341..1a1705d5ae59a5 100644
--- 
a/libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp
+++ 
b/libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp
@@ -1299,6 +1299,78 @@ static void test_america_indiana_knox() {
tz->get_info(to_sys_seconds(2006y, std::chrono::October, 29d, 
6h, 59min, 59s)));
 }
 
+static void test_america_punta_arenas() {
+  // Z America/Punta_Arenas -4:43:40 - LMT 1890
+  // ...
+  // -4 - -04 1919 Jul
+  // -4:42:45 - SMT 1927 S
+  // -5 x -05/-04 1932 S
+  // ...
+  //
+  // R x 1927 1931 - S 1 0 1 -
+  // R x 1928 1932 - Ap 1 0 0 -
+  // ...
+
+  using namespace std::literals::chrono_literals;
+  const std::chrono::time_zone* tz = 
std::chrono::locate_zone("America/Punta_Arenas");
+
+  assert_equal(
+  std::chrono::sys_info(
+  to_sys_seconds(1927y, std::chrono::September, 1d, 4h, 42min, 45s),
+  to_sys_seconds(1928y, std::chrono::April, 1d, 4h),
+  -4h,
+  60min,
+  "-04"),
+  tz->get_info(to_sys_seconds(1927y, std::chrono::September, 1d, 4h, 
42min, 45s)));
+
+  assert_equal(
+  std::chrono::sys_info(
+  to_sys_seconds(1927y, std::chrono::September, 1d, 4h, 42min, 45s),
+  to_sys_seconds(1928y, std::chrono::April, 1d, 4h),
+  -4h,
+  60min,
+  "-04"),
+  tz->get_info(to_sys_seconds(1928y, std::chrono::April, 1d, 3h, 59min, 
59s)));
+}
+
+static void test_europ_ljubljana() {
+  // Z Europe/Ljubljana 0:58:4 - LMT 1884
+  // 1 - CET 1941 Ap 18 23
+  // 1 c CE%sT 1945 May 8 2s
+  // 1 1 CEST 1945 S 16 2s
+  // 1 - CET 1982 N 27
+  // 1 E CE%sT
+  //
+  // ...
+  // R c 1943 o - O 4 2s 0 -
+  // R c 1944 1945 - Ap M>=1 2s 1 S
+  // R c 1944 o - O 2 2s 0 -
+  // R c 1945 o - S 16 2s 0 -
+  // R c 1977 1980 - Ap Su>=1 2s 1 S
+  // ...
+
+  using namespace std::literals::chrono_literals;
+  const std::chrono::time_zone* tz = 
std::chrono::locate_zone("Europe/Ljubljana");
+
+  assert_equal(
+  std::chrono::sys_info(
+  to_sys_seconds(1945y, std::chrono::April, 2d, 1h),
+  to_sys_seconds(1945y, std::chrono::September, 16d, 1h),
+  2h,
+  60min,
+  "CEST"),
+  tz->get_info(to_sys_seconds(1945y, std::chrono::April, 2d, 1h)));
+
+  assert_equal(
+  std::chrono::sys_info(
+  to_sys_seconds(1945y, std::chrono::April, 2d, 1h),
+  to_sys_seconds(1945y, std::chrono::September, 16

[llvm-branch-commits] [libcxx] [libc++][TZDB] Fixes reverse time lookups. (PR #89498)

2024-04-20 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

This was not properly stacked, abandoned.

https://github.com/llvm/llvm-project/pull/89498
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][TZDB] Fixes reverse time lookups. (PR #89498)

2024-04-20 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante closed 
https://github.com/llvm/llvm-project/pull/89498
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++] Makes saturation functions privately available. (PR #89503)

2024-04-20 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/89503

These functions are useful in the implementation of the time zone database. So 
expose them with private names.

The functions could be exposed before C++ 20, but since libc++ is mostly C++ 17 
complete it seems less useful to allow earlier.

>From d1f131136d005699a882bf30af9520b06fc898b4 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++] Makes saturation functions privately available.

These functions are useful in the implementation of the time zone
database. So expose them with private names.

The functions could be exposed before C++ 20, but since libc++ is mostly
C++ 17 complete it seems less useful to allow earlier.
---
 .../include/__numeric/saturation_arithmetic.h | 41 ---
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/libcxx/include/__numeric/saturation_arithmetic.h 
b/libcxx/include/__numeric/saturation_arithmetic.h
index 41596a0c58e27d..fd64cac935de85 100644
--- a/libcxx/include/__numeric/saturation_arithmetic.h
+++ b/libcxx/include/__numeric/saturation_arithmetic.h
@@ -25,10 +25,10 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if _LIBCPP_STD_VER >= 26
+#if _LIBCPP_STD_VER >= 20
 
 template <__libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {
   if (_Tp __sum; !__builtin_add_overflow(__x, __y, &__sum))
 return __sum;
   // Handle overflow
@@ -46,7 +46,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) 
noexcept {
 }
 
 template <__libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {
   if (_Tp __sub; !__builtin_sub_overflow(__x, __y, &__sub))
 return __sub;
   // Handle overflow
@@ -65,7 +65,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) 
noexcept {
 }
 
 template <__libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {
   if (_Tp __mul; !__builtin_mul_overflow(__x, __y, &__mul))
 return __mul;
   // Handle overflow
@@ -81,7 +81,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) 
noexcept {
 }
 
 template <__libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept {
   _LIBCPP_ASSERT_UNCATEGORIZED(__y != 0, "Division by 0 is undefined");
   if constexpr (__libcpp_unsigned_integer<_Tp>) {
 return __x / __y;
@@ -94,7 +94,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) 
noexcept {
 }
 
 template <__libcpp_integer _Rp, __libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {
   // Saturation is impossible edge case when ((min _Rp) < (min _Tp) && (max 
_Rp) > (max _Tp)) and it is expected to be
   // optimized out by the compiler.
 
@@ -107,6 +107,35 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) 
noexcept {
   return static_cast<_Rp>(__x);
 }
 
+#endif // _LIBCPP_STD_VER >= 20
+
+#if _LIBCPP_STD_VER >= 26
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
+  return std::add_sat(__x, __y);
+}
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
+  return std::sub_sat(__x, __y);
+}
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
+  return std::mul_sat(__x, __y);
+}
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
+  return std::div_sat(__x, __y);
+}
+
+template <__libcpp_integer _Rp, __libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
+  return std::saturate_cast<_Rp>(__x);
+}
+
 #endif // _LIBCPP_STD_VER >= 26
 
 _LIBCPP_END_NAMESPACE_STD

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++] Makes saturation functions privately available. (PR #89503)

2024-04-20 Thread Mark de Wever via llvm-branch-commits


@@ -107,6 +107,35 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) 
noexcept {
   return static_cast<_Rp>(__x);
 }
 
+#endif // _LIBCPP_STD_VER >= 20
+
+#if _LIBCPP_STD_VER >= 26
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
+  return std::add_sat(__x, __y);

mordante wrote:

Thanks good catch!

https://github.com/llvm/llvm-project/pull/89503
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++] Makes saturation functions privately available. (PR #89503)

2024-04-20 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/89503

>From d1f131136d005699a882bf30af9520b06fc898b4 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH 1/2] [libc++] Makes saturation functions privately available.

These functions are useful in the implementation of the time zone
database. So expose them with private names.

The functions could be exposed before C++ 20, but since libc++ is mostly
C++ 17 complete it seems less useful to allow earlier.
---
 .../include/__numeric/saturation_arithmetic.h | 41 ---
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/libcxx/include/__numeric/saturation_arithmetic.h 
b/libcxx/include/__numeric/saturation_arithmetic.h
index 41596a0c58e27d..fd64cac935de85 100644
--- a/libcxx/include/__numeric/saturation_arithmetic.h
+++ b/libcxx/include/__numeric/saturation_arithmetic.h
@@ -25,10 +25,10 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if _LIBCPP_STD_VER >= 26
+#if _LIBCPP_STD_VER >= 20
 
 template <__libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {
   if (_Tp __sum; !__builtin_add_overflow(__x, __y, &__sum))
 return __sum;
   // Handle overflow
@@ -46,7 +46,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) 
noexcept {
 }
 
 template <__libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {
   if (_Tp __sub; !__builtin_sub_overflow(__x, __y, &__sub))
 return __sub;
   // Handle overflow
@@ -65,7 +65,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) 
noexcept {
 }
 
 template <__libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {
   if (_Tp __mul; !__builtin_mul_overflow(__x, __y, &__mul))
 return __mul;
   // Handle overflow
@@ -81,7 +81,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) 
noexcept {
 }
 
 template <__libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept {
   _LIBCPP_ASSERT_UNCATEGORIZED(__y != 0, "Division by 0 is undefined");
   if constexpr (__libcpp_unsigned_integer<_Tp>) {
 return __x / __y;
@@ -94,7 +94,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) 
noexcept {
 }
 
 template <__libcpp_integer _Rp, __libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {
   // Saturation is impossible edge case when ((min _Rp) < (min _Tp) && (max 
_Rp) > (max _Tp)) and it is expected to be
   // optimized out by the compiler.
 
@@ -107,6 +107,35 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) 
noexcept {
   return static_cast<_Rp>(__x);
 }
 
+#endif // _LIBCPP_STD_VER >= 20
+
+#if _LIBCPP_STD_VER >= 26
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
+  return std::add_sat(__x, __y);
+}
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
+  return std::sub_sat(__x, __y);
+}
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
+  return std::mul_sat(__x, __y);
+}
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
+  return std::div_sat(__x, __y);
+}
+
+template <__libcpp_integer _Rp, __libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
+  return std::saturate_cast<_Rp>(__x);
+}
+
 #endif // _LIBCPP_STD_VER >= 26
 
 _LIBCPP_END_NAMESPACE_STD

>From 84f547d0da8721c105dea5faa9ed7eedd1e19d61 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sat, 20 Apr 2024 18:35:24 +0200
Subject: [PATCH 2/2] Update libcxx/include/__numeric/saturation_arithmetic.h

Co-authored-by: Hristo Hristov 
---
 libcxx/include/__numeric/saturation_arithmetic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/__numeric/saturation_arithmetic.h 
b/libcxx/include/__numeric/saturation_arithmetic.h
index fd64cac935de85..d6c02ac224f9e2 100644
--- a/libcxx/include/__numeric/saturation_arithmetic.h
+++ b/libcxx/include/__numeric/saturation_arithmetic.h
@@ -113,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp 
__x) noexcept {
 
 template <__libcpp_integer _Tp>
 _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
-  return std::add_sat(__x, __y);
+  return std::__add_sat(__x, __y);
 }
 
 template <__libcpp_integer _Tp>

___
llvm-branch-commi

[llvm-branch-commits] [libcxx] [libc++] Makes saturation functions privately available. (PR #89503)

2024-04-20 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/89503

>From d1f131136d005699a882bf30af9520b06fc898b4 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH 1/3] [libc++] Makes saturation functions privately available.

These functions are useful in the implementation of the time zone
database. So expose them with private names.

The functions could be exposed before C++ 20, but since libc++ is mostly
C++ 17 complete it seems less useful to allow earlier.
---
 .../include/__numeric/saturation_arithmetic.h | 41 ---
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/libcxx/include/__numeric/saturation_arithmetic.h 
b/libcxx/include/__numeric/saturation_arithmetic.h
index 41596a0c58e27d..fd64cac935de85 100644
--- a/libcxx/include/__numeric/saturation_arithmetic.h
+++ b/libcxx/include/__numeric/saturation_arithmetic.h
@@ -25,10 +25,10 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if _LIBCPP_STD_VER >= 26
+#if _LIBCPP_STD_VER >= 20
 
 template <__libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {
   if (_Tp __sum; !__builtin_add_overflow(__x, __y, &__sum))
 return __sum;
   // Handle overflow
@@ -46,7 +46,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) 
noexcept {
 }
 
 template <__libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {
   if (_Tp __sub; !__builtin_sub_overflow(__x, __y, &__sub))
 return __sub;
   // Handle overflow
@@ -65,7 +65,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) 
noexcept {
 }
 
 template <__libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {
   if (_Tp __mul; !__builtin_mul_overflow(__x, __y, &__mul))
 return __mul;
   // Handle overflow
@@ -81,7 +81,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) 
noexcept {
 }
 
 template <__libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept {
   _LIBCPP_ASSERT_UNCATEGORIZED(__y != 0, "Division by 0 is undefined");
   if constexpr (__libcpp_unsigned_integer<_Tp>) {
 return __x / __y;
@@ -94,7 +94,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) 
noexcept {
 }
 
 template <__libcpp_integer _Rp, __libcpp_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {
   // Saturation is impossible edge case when ((min _Rp) < (min _Tp) && (max 
_Rp) > (max _Tp)) and it is expected to be
   // optimized out by the compiler.
 
@@ -107,6 +107,35 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) 
noexcept {
   return static_cast<_Rp>(__x);
 }
 
+#endif // _LIBCPP_STD_VER >= 20
+
+#if _LIBCPP_STD_VER >= 26
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
+  return std::add_sat(__x, __y);
+}
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
+  return std::sub_sat(__x, __y);
+}
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
+  return std::mul_sat(__x, __y);
+}
+
+template <__libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
+  return std::div_sat(__x, __y);
+}
+
+template <__libcpp_integer _Rp, __libcpp_integer _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
+  return std::saturate_cast<_Rp>(__x);
+}
+
 #endif // _LIBCPP_STD_VER >= 26
 
 _LIBCPP_END_NAMESPACE_STD

>From 84f547d0da8721c105dea5faa9ed7eedd1e19d61 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sat, 20 Apr 2024 18:35:24 +0200
Subject: [PATCH 2/3] Update libcxx/include/__numeric/saturation_arithmetic.h

Co-authored-by: Hristo Hristov 
---
 libcxx/include/__numeric/saturation_arithmetic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/__numeric/saturation_arithmetic.h 
b/libcxx/include/__numeric/saturation_arithmetic.h
index fd64cac935de85..d6c02ac224f9e2 100644
--- a/libcxx/include/__numeric/saturation_arithmetic.h
+++ b/libcxx/include/__numeric/saturation_arithmetic.h
@@ -113,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp 
__x) noexcept {
 
 template <__libcpp_integer _Tp>
 _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
-  return std::add_sat(__x, __y);
+  return std::__add_sat(__x, __y);
 }
 
 template <__libcpp_integer _Tp>

>From 483890963a0ae405f4822b6546a3f8a096675191 Mon Sep 17 00:00:0

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time zone get_info(local_time). (PR #89537)

2024-04-21 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/89537

Implements parts of:
- P0355 Extending to Calendars and Time Zones

>From ed7053e22620924b6bc18a46cfd6d7201afab3fe Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Implements time zone get_info(local_time).

Implements parts of:
- P0355 Extending to Calendars and Time Zones
---
 libcxx/include/__chrono/time_zone.h   |7 +
 libcxx/include/chrono |3 +
 libcxx/src/time_zone.cpp  |  175 +++
 .../chrono.nodiscard_extensions.verify.cpp|2 +
 .../get_info.local_time.pass.cpp  | 1302 +
 5 files changed, 1489 insertions(+)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.local_time.pass.cpp

diff --git a/libcxx/include/__chrono/time_zone.h 
b/libcxx/include/__chrono/time_zone.h
index 799602c1cdbaf0..3ea03683ccc187 100644
--- a/libcxx/include/__chrono/time_zone.h
+++ b/libcxx/include/__chrono/time_zone.h
@@ -17,6 +17,7 @@
 #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
 
 #  include <__chrono/duration.h>
+#  include <__chrono/local_info.h>
 #  include <__chrono/sys_info.h>
 #  include <__chrono/system_clock.h>
 #  include <__compare/strong_order.h>
@@ -63,12 +64,18 @@ class _LIBCPP_AVAILABILITY_TZDB time_zone {
 return __get_info(chrono::time_point_cast(__time));
   }
 
+  template 
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_info get_info(const 
local_time<_Duration>& __time) const {
+return __get_info(chrono::time_point_cast(__time));
+  }
+
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const __impl& __implementation() const 
noexcept { return *__impl_; }
 
 private:
   [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI string_view __name() const noexcept;
 
   [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI sys_info 
__get_info(sys_seconds __time) const;
+  [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI local_info 
__get_info(local_seconds __time) const;
 
   unique_ptr<__impl> __impl_;
 };
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 96a3e92faa81f2..4d8398af1a108f 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -763,6 +763,9 @@ class time_zone {
 
   template
   sys_info get_info(const sys_time& st) const;
+
+  template
+  local_info get_info(const local_time& tp) const;
 };
 bool operator==(const time_zone& x, const time_zone& y) noexcept;  
  // C++20
 strong_ordering operator<=>(const time_zone& x, const time_zone& y) noexcept;  
  // C++20
diff --git a/libcxx/src/time_zone.cpp b/libcxx/src/time_zone.cpp
index 928f3d2855e456..24c22859080e10 100644
--- a/libcxx/src/time_zone.cpp
+++ b/libcxx/src/time_zone.cpp
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "include/tzdb/time_zone_private.h"
@@ -903,6 +904,180 @@ time_zone::__get_info(sys_seconds __time) const {
   std::__throw_runtime_error("tzdb: corrupt db");
 }
 
+enum class __position {
+  __beginning,
+  __middle,
+  __end,
+};
+
+// Determines the position of "__time" inside "__info".
+//
+// The code picks an arbitrary value to determine the "middle"
+// - Every time that is more than the threshold from a boundary, or
+// - Every value that is at the boundary sys_seconds::min() or
+//   sys_seconds::max().
+//
+// If not in the middle, it returns __beginning or __end.
+[[nodiscard]] static __position __get_position(sys_seconds __time, const 
sys_info __info) {
+  _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
+  __time >= __info.begin && __time < __info.end, "A value outside the 
range's position can't be determined.");
+
+  using _Tp = sys_seconds::rep;
+  // Africa/Freetown has a 4 day "zone"
+  // Africa/Freetown  Fri Sep  1 00:59:59 1939 UT = Thu Aug 31 23:59:59 1939 
-01 isdst=0 gmtoff=-3600
+  // Africa/Freetown  Fri Sep  1 01:00:00 1939 UT = Fri Sep  1 00:20:00 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:39:59 1939 UT = Mon Sep  4 23:59:59 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:40:00 1939 UT = Mon Sep  4 23:40:00 1939 
-01 isdst=0 gmtoff=-3600
+  //
+  // Originally used a one week threshold, but due to this switched to 1 day.
+  // This seems to work in practice.
+  //
+  // TODO TZDB Evaluate the proper threshold.
+  constexpr _Tp __threshold = 24 * 3600;
+
+  _Tp __upper = std::__add_sat(__info.begin.time_since_epoch().count(), 
__threshold);
+  if (__time >= __info.begin && __time.time_since_epoch().count() < __upper)
+return __info.begin != sys_seconds::min() ? __position::__beginning : 
__position::__middle;
+
+  _Tp __lower = std::__sub_sat(__info.end.time_since_epoch().count(), 
__threshold);
+  if (__time < __info.end && __time.time_since_epoch().count() >= __lower)
+return __info.end != sys_seconds::max() ? __position::__end : 
__position::__middle;
+
+  return __position:

[llvm-branch-commits] [libcxx] [libc++] Makes saturation functions privately available. (PR #89503)

2024-04-23 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

> @mordante The PR looks odd. Is this intentional or have you mixed two 
> branches?

This is due to using manually stacked reviews in GitHub. This is patch 3 in a 
series
* patch 1 has landed
* I just rebased patch 2 and wait for the CI
* patch 3 now believes patches 1 & 2 part of this branch. This will be fixed 
after I rebase this patch on the new patch 2

I really miss the nice stacked reviews of Phabriacator.

https://github.com/llvm/llvm-project/pull/89503
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/18.x: [libcxx] [modules] Add _LIBCPP_USING_IF_EXISTS on aligned_alloc (#89827) (PR #89894)

2024-04-24 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante approved this pull request.


https://github.com/llvm/llvm-project/pull/89894
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][chrono] Fixes leap seconds. (PR #90070)

2024-04-25 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/90070

While implementing the UTC clock it turns out that the implementation of the 
leap seconds was not correct, it should store the individual value, not the sum.

It also looks like LWG3359 has not been fully implemented.

Implements parts of:
- LWG3359  leap second support should allow for negative leap seconds

>From d094cded6d023bbffdca0af983ef64e00289c797 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Mon, 15 Apr 2024 19:56:40 +0200
Subject: [PATCH] [libc++][chrono] Fixes leap seconds.

While implementing the UTC clock it turns out that the implementation of
the leap seconds was not correct, it should store the individual value,
not the sum.

It also looks like LWG3359 has not been fully implemented.

Implements parts of:
- LWG3359  leap second support should allow for negative leap seconds
---
 libcxx/docs/Status/Cxx20Issues.csv|  2 +-
 libcxx/src/tzdb.cpp   | 64 ---
 .../time.zone.db/leap_seconds.pass.cpp| 23 ---
 .../time.zone.db/leap_seconds.pass.cpp| 55 
 4 files changed, 83 insertions(+), 61 deletions(-)

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index db57b15256a62f..fed1c7e736248f 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -269,7 +269,7 @@
 "`3355 `__","The memory algorithms should support 
move-only input iterators introduced by 
P1207","Prague","|Complete|","15.0","|ranges|"
 "`3356 `__","``__cpp_lib_nothrow_convertible``\  
should be ``__cpp_lib_is_nothrow_convertible``\ ","Prague","|Complete|","12.0"
 "`3358 `__","|sect|\ [span.cons] is mistaken that 
``to_address``\  can throw","Prague","|Complete|","17.0"
-"`3359 `__","\  leap second support 
should allow for negative leap seconds","Prague","|Complete|","19.0","|chrono|"
+"`3359 `__","\  leap second support 
should allow for negative leap seconds","Prague","|In Progress|","","|chrono|"
 "`3360 `__","``three_way_comparable_with``\  is 
inconsistent with similar concepts","Prague","|Nothing To Do|","","|spaceship|"
 "`3362 `__","Strike ``stop_source``\ 's 
``operator!=``\ ","Prague","",""
 "`3363 `__","``drop_while_view``\  should opt-out 
of ``sized_range``\ ","Prague","|Nothing To Do|","","|ranges|"
diff --git a/libcxx/src/tzdb.cpp b/libcxx/src/tzdb.cpp
index 5951e59248e94f..8588646bbbc417 100644
--- a/libcxx/src/tzdb.cpp
+++ b/libcxx/src/tzdb.cpp
@@ -626,29 +626,49 @@ static void __parse_leap_seconds(vector& 
__leap_seconds, istream&&
   // seconds since 1 January 1970.
   constexpr auto __offset = sys_days{1970y / January / 1} - sys_days{1900y / 
January / 1};
 
-  while (true) {
-switch (__input.peek()) {
-case istream::traits_type::eof():
-  return;
-
-case ' ':
-case '\t':
-case '\n':
-  __input.get();
-  continue;
+  struct __entry {
+sys_seconds __timestamp;
+seconds __value;
+  };
+  vector<__entry> __entries;
+  [&] {
+while (true) {
+  switch (__input.peek()) {
+  case istream::traits_type::eof():
+return;
+
+  case ' ':
+  case '\t':
+  case '\n':
+__input.get();
+continue;
+
+  case '#':
+chrono::__skip_line(__input);
+continue;
+  }
 
-case '#':
+  sys_seconds __date = 
sys_seconds{seconds{chrono::__parse_integral(__input, false)}} - __offset;
+  chrono::__skip_mandatory_whitespace(__input);
+  seconds __value{chrono::__parse_integral(__input, false)};
   chrono::__skip_line(__input);
-  continue;
-}
 
-sys_seconds __date = sys_seconds{seconds{chrono::__parse_integral(__input, 
false)}} - __offset;
-chrono::__skip_mandatory_whitespace(__input);
-seconds __value{chrono::__parse_integral(__input, false)};
-chrono::__skip_line(__input);
-
-__leap_seconds.emplace_back(std::__private_constructor_tag{}, __date, 
__value);
-  }
+  __entries.emplace_back(__date, __value);
+}
+  }();
+  // The Standard requires the leap seconds to be sorted. The file
+  // leap-seconds.list usually provides them in sorted order, but that is not
+  // guaranteed so we ensure it here.
+  std::ranges::sort(__entries, {}, &__entry::__timestamp);
+
+  // The database should contain the number of seconds inserted by a leap
+  // second (1 or -1). So the difference between the two elements are stored.
+  // std::ranges::views::adjacent has not been implemented yet.
+  (void)ranges::adjacent_find(__entries, [&](const __entry& __first, const 
__entry& __second) {
+__leap_seconds.emplace_back(
+std::__private_constructor_tag{}, __second.__timestamp, 
__second.__value - __first.__value);
+return f

  1   2   3   >