[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone::to_sys. (PR #90394)

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

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

>From d7b42718303e017acfe3e61c67d6e8a9bb0ffa9d 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::to_sys.

This implements the throwing overload and the exception classes throw by
this overload.

Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/exception.h   | 129 ++
 libcxx/include/__chrono/time_zone.h   |  26 ++
 libcxx/include/chrono |   9 +
 libcxx/include/module.modulemap   |   6 +-
 libcxx/modules/std/chrono.inc |   2 -
 libcxx/src/CMakeLists.txt |   3 +
 libcxx/src/chrono_exception.cpp   |  20 ++
 .../assert.ctor.pass.cpp  |  53 
 .../assert.ctor.pass.cpp  |  53 
 .../time.zone.members/assert.to_sys.pass.cpp  |  39 +++
 .../test/libcxx/transitive_includes/cxx03.csv |   3 -
 .../test/libcxx/transitive_includes/cxx11.csv |   3 -
 .../test/libcxx/transitive_includes/cxx14.csv |   3 -
 .../test/libcxx/transitive_includes/cxx17.csv |   3 -
 .../test/libcxx/transitive_includes/cxx20.csv |   8 +-
 .../test/libcxx/transitive_includes/cxx23.csv |  12 +-
 .../test/libcxx/transitive_includes/cxx26.csv |  12 +-
 .../time.zone.exception.ambig/ctor.pass.cpp   | 171 +
 .../types.compile.pass.cpp|  33 +++
 .../ctor.pass.cpp | 172 +
 .../types.compile.pass.cpp|  33 +++
 .../time.zone.members/to_sys.pass.cpp | 237 ++
 23 files changed, 987 insertions(+), 44 deletions(-)
 create mode 100644 libcxx/include/__chrono/exception.h
 create mode 100644 libcxx/src/chrono_exception.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.ambig/assert.ctor.pass.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.nonexist/assert.ctor.pass.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/ctor.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/types.compile.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/ctor.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/types.compile.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/to_sys.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 1296c536bc882c..386bd967eed7ab 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -264,6 +264,7 @@ set(files
   __chrono/convert_to_tm.h
   __chrono/day.h
   __chrono/duration.h
+  __chrono/exception.h
   __chrono/file_clock.h
   __chrono/formatter.h
   __chrono/hh_mm_ss.h
diff --git a/libcxx/include/__chrono/exception.h 
b/libcxx/include/__chrono/exception.h
new file mode 100644
index 00..6059a62c3b2ea9
--- /dev/null
+++ b/libcxx/include/__chrono/exception.h
@@ -0,0 +1,129 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
+
+#ifndef _LIBCPP___CHRONO_EXCEPTION_H
+#define _LIBCPP___CHRONO_EXCEPTION_H
+
+#include 
+// Enable the contents of the header only when libc++ was built with 
experimental features enabled.
+#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+
+#  include <__availability>
+#  include <__chrono/calendar.h>
+#  include <__chrono/local_info.h>
+#  include <__chrono/time_point.h>
+#  include <__config>
+#  include <__verbose_abort>
+#  include 
+#  include 
+#  include 
+
+#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#  endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#  if _LIBCPP_STD_VER >= 20
+
+namespace chrono {
+
+class nonexistent_local_time : public runtime_error {
+public:
+  template 
+  _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& 
__time, const local_info& __info)
+  : runtime_error{__create_message(__time, __info)} {
+// [time.zone.exception.nonexist]/2
+//   Preconditions: i.result == local_info::nonexistent is true.
+// The value of 

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone::to_sys. (PR #90394)

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

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

>From e72a966c0aca3319d7aea43d3a9dd4cc25eaeb70 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::to_sys.

This implements the throwing overload and the exception classes throw by
this overload.

Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/exception.h   | 129 ++
 libcxx/include/__chrono/time_zone.h   |  26 ++
 libcxx/include/chrono |   9 +
 libcxx/include/module.modulemap   |   6 +-
 libcxx/modules/std/chrono.inc |   2 -
 libcxx/src/CMakeLists.txt |   3 +
 libcxx/src/chrono_exception.cpp   |  20 ++
 .../assert.ctor.pass.cpp  |  53 
 .../assert.ctor.pass.cpp  |  53 
 .../time.zone.members/assert.to_sys.pass.cpp  |  39 +++
 .../test/libcxx/transitive_includes/cxx03.csv |   3 -
 .../test/libcxx/transitive_includes/cxx11.csv |   3 -
 .../test/libcxx/transitive_includes/cxx14.csv |   3 -
 .../test/libcxx/transitive_includes/cxx17.csv |   3 -
 .../test/libcxx/transitive_includes/cxx20.csv |   8 +-
 .../test/libcxx/transitive_includes/cxx23.csv |  12 +-
 .../test/libcxx/transitive_includes/cxx26.csv |  12 +-
 .../time.zone.exception.ambig/ctor.pass.cpp   | 171 +
 .../types.compile.pass.cpp|  32 +++
 .../ctor.pass.cpp | 172 +
 .../types.compile.pass.cpp|  32 +++
 .../time.zone.members/to_sys.pass.cpp | 237 ++
 23 files changed, 985 insertions(+), 44 deletions(-)
 create mode 100644 libcxx/include/__chrono/exception.h
 create mode 100644 libcxx/src/chrono_exception.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.ambig/assert.ctor.pass.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.nonexist/assert.ctor.pass.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/ctor.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/types.compile.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/ctor.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/types.compile.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/to_sys.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 1296c536bc882c..386bd967eed7ab 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -264,6 +264,7 @@ set(files
   __chrono/convert_to_tm.h
   __chrono/day.h
   __chrono/duration.h
+  __chrono/exception.h
   __chrono/file_clock.h
   __chrono/formatter.h
   __chrono/hh_mm_ss.h
diff --git a/libcxx/include/__chrono/exception.h 
b/libcxx/include/__chrono/exception.h
new file mode 100644
index 00..6059a62c3b2ea9
--- /dev/null
+++ b/libcxx/include/__chrono/exception.h
@@ -0,0 +1,129 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
+
+#ifndef _LIBCPP___CHRONO_EXCEPTION_H
+#define _LIBCPP___CHRONO_EXCEPTION_H
+
+#include 
+// Enable the contents of the header only when libc++ was built with 
experimental features enabled.
+#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+
+#  include <__availability>
+#  include <__chrono/calendar.h>
+#  include <__chrono/local_info.h>
+#  include <__chrono/time_point.h>
+#  include <__config>
+#  include <__verbose_abort>
+#  include 
+#  include 
+#  include 
+
+#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#  endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#  if _LIBCPP_STD_VER >= 20
+
+namespace chrono {
+
+class nonexistent_local_time : public runtime_error {
+public:
+  template 
+  _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& 
__time, const local_info& __info)
+  : runtime_error{__create_message(__time, __info)} {
+// [time.zone.exception.nonexist]/2
+//   Preconditions: i.result == local_info::nonexistent is true.
+// The value of 

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone::to_sys. (PR #90394)

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

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

>From fe9a4ce7f13e981d1ebcdfb088e16da686e22ea1 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::to_sys.

This implements the throwing overload and the exception classes throw by
this overload.

Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/exception.h   | 129 ++
 libcxx/include/__chrono/time_zone.h   |  26 ++
 libcxx/include/chrono |   9 +
 libcxx/include/module.modulemap   |   6 +-
 libcxx/modules/std/chrono.inc |   2 -
 libcxx/src/CMakeLists.txt |   3 +
 libcxx/src/chrono_exception.cpp   |  20 ++
 .../assert.ctor.pass.cpp  |  53 
 .../assert.ctor.pass.cpp  |  53 
 .../time.zone.members/assert.to_sys.pass.cpp  |  39 +++
 .../test/libcxx/transitive_includes/cxx03.csv |   3 -
 .../test/libcxx/transitive_includes/cxx11.csv |   3 -
 .../test/libcxx/transitive_includes/cxx14.csv |   3 -
 .../test/libcxx/transitive_includes/cxx17.csv |   3 -
 .../test/libcxx/transitive_includes/cxx20.csv |   8 +-
 .../test/libcxx/transitive_includes/cxx23.csv |  12 +-
 .../test/libcxx/transitive_includes/cxx26.csv |  12 +-
 .../time.zone.exception.ambig/ctor.pass.cpp   | 171 +
 .../types.compile.pass.cpp|  32 +++
 .../ctor.pass.cpp | 172 +
 .../types.compile.pass.cpp|  32 +++
 .../time.zone.members/to_sys.pass.cpp | 237 ++
 23 files changed, 985 insertions(+), 44 deletions(-)
 create mode 100644 libcxx/include/__chrono/exception.h
 create mode 100644 libcxx/src/chrono_exception.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.ambig/assert.ctor.pass.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.nonexist/assert.ctor.pass.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/ctor.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/types.compile.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/ctor.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/types.compile.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/to_sys.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 1296c536bc882c..386bd967eed7ab 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -264,6 +264,7 @@ set(files
   __chrono/convert_to_tm.h
   __chrono/day.h
   __chrono/duration.h
+  __chrono/exception.h
   __chrono/file_clock.h
   __chrono/formatter.h
   __chrono/hh_mm_ss.h
diff --git a/libcxx/include/__chrono/exception.h 
b/libcxx/include/__chrono/exception.h
new file mode 100644
index 00..9a7fca74fd369c
--- /dev/null
+++ b/libcxx/include/__chrono/exception.h
@@ -0,0 +1,129 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
+
+#ifndef _LIBCPP___CHRONO_EXCEPTION_H
+#define _LIBCPP___CHRONO_EXCEPTION_H
+
+#include 
+// Enable the contents of the header only when libc++ was built with 
experimental features enabled.
+#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+
+#  include <__availability>
+#  include <__chrono/calendar.h>
+#  include <__chrono/local_info.h>
+#  include <__chrono/time_point.h>
+#  include <__config>
+#  include <__verbose_abort>
+#  include 
+#  include 
+#  include 
+
+#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#  endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#  if _LIBCPP_STD_VER >= 20
+
+namespace chrono {
+
+class nonexistent_local_time : public runtime_error {
+public:
+  template 
+  _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& 
__time, const local_info& __info)
+  : runtime_error{__create_message(__time, __info)} {
+// [time.zone.exception.nonexist]/2
+//   Preconditions: i.result == local_info::nonexistent is true.
+// The value of 

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone::to_sys. (PR #90394)

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

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

>From e0f5f099af76108a1b3de6b2735e084047e029c0 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::to_sys.

This implements the throwing overload and the exception classes throw by
this overload.

Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/exception.h   | 129 ++
 libcxx/include/__chrono/time_zone.h   |  26 ++
 libcxx/include/chrono |   9 +
 libcxx/include/module.modulemap   |   6 +-
 libcxx/modules/std/chrono.inc |   2 -
 libcxx/src/CMakeLists.txt |   3 +
 libcxx/src/chrono_exception.cpp   |  20 ++
 .../assert.ctor.pass.cpp  |  53 
 .../assert.ctor.pass.cpp  |  53 
 .../time.zone.members/assert.to_sys.pass.cpp  |  39 +++
 .../test/libcxx/transitive_includes/cxx03.csv |   3 -
 .../test/libcxx/transitive_includes/cxx11.csv |   3 -
 .../test/libcxx/transitive_includes/cxx14.csv |   3 -
 .../test/libcxx/transitive_includes/cxx17.csv |   3 -
 .../test/libcxx/transitive_includes/cxx20.csv |   8 +-
 .../test/libcxx/transitive_includes/cxx23.csv |  12 +-
 .../test/libcxx/transitive_includes/cxx26.csv |  12 +-
 .../time.zone.exception.ambig/ctor.pass.cpp   | 171 +
 .../types.compile.pass.cpp|  31 +++
 .../ctor.pass.cpp | 172 +
 .../types.compile.pass.cpp|  31 +++
 .../time.zone.members/to_sys.pass.cpp | 237 ++
 23 files changed, 983 insertions(+), 44 deletions(-)
 create mode 100644 libcxx/include/__chrono/exception.h
 create mode 100644 libcxx/src/chrono_exception.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.ambig/assert.ctor.pass.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.nonexist/assert.ctor.pass.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/ctor.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/types.compile.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/ctor.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/types.compile.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/to_sys.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 1296c536bc882c..386bd967eed7ab 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -264,6 +264,7 @@ set(files
   __chrono/convert_to_tm.h
   __chrono/day.h
   __chrono/duration.h
+  __chrono/exception.h
   __chrono/file_clock.h
   __chrono/formatter.h
   __chrono/hh_mm_ss.h
diff --git a/libcxx/include/__chrono/exception.h 
b/libcxx/include/__chrono/exception.h
new file mode 100644
index 00..fa9e0cf90e5d96
--- /dev/null
+++ b/libcxx/include/__chrono/exception.h
@@ -0,0 +1,129 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
+
+#ifndef _LIBCPP___CHRONO_EXCEPTION_H
+#define _LIBCPP___CHRONO_EXCEPTION_H
+
+#include 
+// Enable the contents of the header only when libc++ was built with 
experimental features enabled.
+#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+
+#  include <__availability>
+#  include <__chrono/calendar.h>
+#  include <__chrono/local_info.h>
+#  include <__chrono/time_point.h>
+#  include <__config>
+#  include <__verbose_abort>
+#  include 
+#  include 
+#  include 
+
+#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#  endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#  if _LIBCPP_STD_VER >= 20
+
+namespace chrono {
+
+class nonexistent_local_time : public runtime_error {
+public:
+  template 
+  _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& 
__time, const local_info& __info)
+  : runtime_error{__create_message(__time, __info)} {
+// [time.zone.exception.nonexist]/2
+//   Preconditions: i.result == local_info::nonexistent is true.
+// The value of 

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone::to_sys. (PR #90394)

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

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

>From c0cdd074a1e22c3d35f2e235cfd6f0bf74b406dc 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::to_sys.

This implements the throwing overload and the exception classes throw by
this overload.

Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/exception.h   | 129 ++
 libcxx/include/__chrono/time_zone.h   |  26 ++
 libcxx/include/chrono |   9 +
 libcxx/include/module.modulemap   |   6 +-
 libcxx/modules/std/chrono.inc |   2 -
 libcxx/src/CMakeLists.txt |   3 +
 libcxx/src/chrono_exception.cpp   |  20 ++
 .../assert.ctor.pass.cpp  |  53 
 .../assert.ctor.pass.cpp  |  53 
 .../time.zone.members/assert.to_sys.pass.cpp  |  39 +++
 .../test/libcxx/transitive_includes/cxx03.csv |   3 -
 .../test/libcxx/transitive_includes/cxx11.csv |   3 -
 .../test/libcxx/transitive_includes/cxx14.csv |   3 -
 .../test/libcxx/transitive_includes/cxx17.csv |   3 -
 .../test/libcxx/transitive_includes/cxx20.csv |   8 +-
 .../test/libcxx/transitive_includes/cxx23.csv |  12 +-
 .../test/libcxx/transitive_includes/cxx26.csv |  12 +-
 .../time.zone.exception.ambig/ctor.pass.cpp   | 169 +
 .../types.compile.pass.cpp|  31 +++
 .../ctor.pass.cpp | 170 +
 .../types.compile.pass.cpp|  31 +++
 .../time.zone.members/to_sys.pass.cpp | 237 ++
 23 files changed, 979 insertions(+), 44 deletions(-)
 create mode 100644 libcxx/include/__chrono/exception.h
 create mode 100644 libcxx/src/chrono_exception.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.ambig/assert.ctor.pass.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.nonexist/assert.ctor.pass.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/ctor.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/types.compile.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/ctor.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/types.compile.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/to_sys.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 1296c536bc882c..386bd967eed7ab 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -264,6 +264,7 @@ set(files
   __chrono/convert_to_tm.h
   __chrono/day.h
   __chrono/duration.h
+  __chrono/exception.h
   __chrono/file_clock.h
   __chrono/formatter.h
   __chrono/hh_mm_ss.h
diff --git a/libcxx/include/__chrono/exception.h 
b/libcxx/include/__chrono/exception.h
new file mode 100644
index 00..fa9e0cf90e5d96
--- /dev/null
+++ b/libcxx/include/__chrono/exception.h
@@ -0,0 +1,129 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
+
+#ifndef _LIBCPP___CHRONO_EXCEPTION_H
+#define _LIBCPP___CHRONO_EXCEPTION_H
+
+#include 
+// Enable the contents of the header only when libc++ was built with 
experimental features enabled.
+#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+
+#  include <__availability>
+#  include <__chrono/calendar.h>
+#  include <__chrono/local_info.h>
+#  include <__chrono/time_point.h>
+#  include <__config>
+#  include <__verbose_abort>
+#  include 
+#  include 
+#  include 
+
+#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#  endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#  if _LIBCPP_STD_VER >= 20
+
+namespace chrono {
+
+class nonexistent_local_time : public runtime_error {
+public:
+  template 
+  _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& 
__time, const local_info& __info)
+  : runtime_error{__create_message(__time, __info)} {
+// [time.zone.exception.nonexist]/2
+//   Preconditions: i.result == local_info::nonexistent is true.
+// The value of 

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone::to_sys. (PR #90394)

2024-04-28 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

This implements the throwing overload and the exception classes throw by this 
overload.

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

---

Patch is 44.82 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/90394.diff


16 Files Affected:

- (modified) libcxx/include/CMakeLists.txt (+1) 
- (added) libcxx/include/__chrono/exception.h (+128) 
- (modified) libcxx/include/__chrono/time_zone.h (+25) 
- (modified) libcxx/include/chrono (+9) 
- (modified) libcxx/include/module.modulemap (+1) 
- (modified) libcxx/modules/std/chrono.inc (-2) 
- (modified) libcxx/src/CMakeLists.txt (+3) 
- (added) libcxx/src/chrono_exception.cpp (+20) 
- (added) 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.ambig/assert.ctor.pass.cpp
 (+53) 
- (added) 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.nonexist/assert.ctor.pass.cpp
 (+53) 
- (added) 
libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys.pass.cpp
 (+39) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/ctor.pass.cpp
 (+169) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/types.compile.pass.cpp
 (+31) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/ctor.pass.cpp
 (+170) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/types.compile.pass.cpp
 (+31) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/to_sys.pass.cpp
 (+237) 


``diff
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 1296c536bc882c..386bd967eed7ab 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -264,6 +264,7 @@ set(files
   __chrono/convert_to_tm.h
   __chrono/day.h
   __chrono/duration.h
+  __chrono/exception.h
   __chrono/file_clock.h
   __chrono/formatter.h
   __chrono/hh_mm_ss.h
diff --git a/libcxx/include/__chrono/exception.h 
b/libcxx/include/__chrono/exception.h
new file mode 100644
index 00..ca0acecf151ba9
--- /dev/null
+++ b/libcxx/include/__chrono/exception.h
@@ -0,0 +1,128 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
+
+#ifndef _LIBCPP___CHRONO_EXCEPTION_H
+#define _LIBCPP___CHRONO_EXCEPTION_H
+
+#include 
+// Enable the contents of the header only when libc++ was built with 
experimental features enabled.
+#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+
+#  include <__availability>
+#  include <__chrono/calendar.h>
+#  include <__chrono/local_info.h>
+#  include <__config>
+#  include <__verbose_abort>
+#  include 
+#  include 
+#  include 
+
+#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#  endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#  if _LIBCPP_STD_VER >= 20
+
+namespace chrono {
+
+class nonexistent_local_time : public runtime_error {
+public:
+  template 
+  _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& 
__time, const local_info& __info)
+  : runtime_error{__create_message(__time, __info)} {
+// [time.zone.exception.nonexist]/2
+//   Preconditions: i.result == local_info::nonexistent is true.
+// The value of __info.result is not used.
+_LIBCPP_ASSERT_PEDANTIC(__info.result == local_info::nonexistent,
+"creating an nonexistent_local_time from a 
local_info that is not non-existent");
+  }
+
+  _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI 
~nonexistent_local_time() override; // exported as key function
+
+private:
+  template 
+  _LIBCPP_HIDE_FROM_ABI string __create_message(const local_time<_Duration>& 
__time, const local_info& __info) {
+return std::format(
+R"({} is in a gap between
+{} {} and
+{} {} which are both equivalent to
+{} UTC)",
+__time,
+local_seconds{__info.first.end.time_since_epoch()} + 
__info.first.offset,
+__info.first.abbrev,
+local_seconds{__info.second.begin.time_since_epoch()} + 
__info.second.offset,
+__info.second.abbrev,
+__info.first.end);
+  }
+};
+
+template 
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time(
+[[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] 
const local_info& __info) {
+#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+  throw nonexistent_local_time(__time, __info);
+#else
+  

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone::to_sys. (PR #90394)

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

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

This implements the throwing overload and the exception classes throw by this 
overload.

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

>From e722747d35b87cbcf8e12847c799f87a6082bb73 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::to_sys.

This implements the throwing overload and the exception classes throw by
this overload.

Implements parts of:
- P0355 Extending chrono to Calendars and Time Zones
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__chrono/exception.h   | 128 ++
 libcxx/include/__chrono/time_zone.h   |  25 ++
 libcxx/include/chrono |   9 +
 libcxx/include/module.modulemap   |   1 +
 libcxx/modules/std/chrono.inc |   2 -
 libcxx/src/CMakeLists.txt |   3 +
 libcxx/src/chrono_exception.cpp   |  20 ++
 .../assert.ctor.pass.cpp  |  53 
 .../assert.ctor.pass.cpp  |  53 
 .../time.zone.members/assert.to_sys.pass.cpp  |  39 +++
 .../time.zone.exception.ambig/ctor.pass.cpp   | 169 +
 .../types.compile.pass.cpp|  31 +++
 .../ctor.pass.cpp | 170 +
 .../types.compile.pass.cpp|  31 +++
 .../time.zone.members/to_sys.pass.cpp | 237 ++
 16 files changed, 970 insertions(+), 2 deletions(-)
 create mode 100644 libcxx/include/__chrono/exception.h
 create mode 100644 libcxx/src/chrono_exception.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.ambig/assert.ctor.pass.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.nonexist/assert.ctor.pass.cpp
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/ctor.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/types.compile.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/ctor.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/types.compile.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/to_sys.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 1296c536bc882c..386bd967eed7ab 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -264,6 +264,7 @@ set(files
   __chrono/convert_to_tm.h
   __chrono/day.h
   __chrono/duration.h
+  __chrono/exception.h
   __chrono/file_clock.h
   __chrono/formatter.h
   __chrono/hh_mm_ss.h
diff --git a/libcxx/include/__chrono/exception.h 
b/libcxx/include/__chrono/exception.h
new file mode 100644
index 00..ca0acecf151ba9
--- /dev/null
+++ b/libcxx/include/__chrono/exception.h
@@ -0,0 +1,128 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
+
+#ifndef _LIBCPP___CHRONO_EXCEPTION_H
+#define _LIBCPP___CHRONO_EXCEPTION_H
+
+#include 
+// Enable the contents of the header only when libc++ was built with 
experimental features enabled.
+#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+
+#  include <__availability>
+#  include <__chrono/calendar.h>
+#  include <__chrono/local_info.h>
+#  include <__config>
+#  include <__verbose_abort>
+#  include 
+#  include 
+#  include 
+
+#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#  endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#  if _LIBCPP_STD_VER >= 20
+
+namespace chrono {
+
+class nonexistent_local_time : public runtime_error {
+public:
+  template 
+  _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& 
__time, const local_info& __info)
+  : runtime_error{__create_message(__time, __info)} {
+// [time.zone.exception.nonexist]/2
+//   Preconditions: i.result == local_info::nonexistent is true.
+// The value of __info.result is not used.
+_LIBCPP_ASSERT_PEDANTIC(__info.result == local_info::nonexistent,
+"creating an nonexistent_local_time from a 
local_info that is not non-existent");
+  }
+
+  _LIBCPP_AVAILABILITY_TZDB