Revert "[InstCombine] Support gep nuw in icmp folds" (#118698)
[llvm-project.git] / libcxx / include / __chrono / tzdb.h
blob8052043e64765563202571ac9847e82d42ea2411
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
12 #ifndef _LIBCPP___CHRONO_TZDB_H
13 #define _LIBCPP___CHRONO_TZDB_H
15 #include <version>
16 // Enable the contents of the header only when libc++ was built with experimental features enabled.
17 #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
19 # include <__algorithm/ranges_lower_bound.h>
20 # include <__chrono/leap_second.h>
21 # include <__chrono/time_zone.h>
22 # include <__chrono/time_zone_link.h>
23 # include <__config>
24 # include <__memory/addressof.h>
25 # include <__vector/vector.h>
26 # include <stdexcept>
27 # include <string>
28 # include <string_view>
30 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31 # pragma GCC system_header
32 # endif
34 _LIBCPP_PUSH_MACROS
35 # include <__undef_macros>
37 _LIBCPP_BEGIN_NAMESPACE_STD
39 # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
41 namespace chrono {
43 struct tzdb {
44 string version;
45 vector<time_zone> zones;
46 vector<time_zone_link> links;
48 vector<leap_second> leap_seconds;
50 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* __locate_zone(string_view __name) const {
51 if (const time_zone* __result = __find_in_zone(__name))
52 return __result;
54 if (auto __it = ranges::lower_bound(links, __name, {}, &time_zone_link::name);
55 __it != links.end() && __it->name() == __name)
56 if (const time_zone* __result = __find_in_zone(__it->target()))
57 return __result;
59 return nullptr;
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* locate_zone(string_view __name) const {
63 if (const time_zone* __result = __locate_zone(__name))
64 return __result;
66 std::__throw_runtime_error("tzdb: requested time zone not found");
69 [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI const time_zone* current_zone() const {
70 return __current_zone();
73 private:
74 _LIBCPP_HIDE_FROM_ABI const time_zone* __find_in_zone(string_view __name) const noexcept {
75 if (auto __it = ranges::lower_bound(zones, __name, {}, &time_zone::name);
76 __it != zones.end() && __it->name() == __name)
77 return std::addressof(*__it);
79 return nullptr;
82 [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const time_zone* __current_zone() const;
85 } // namespace chrono
87 # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
88 // _LIBCPP_HAS_LOCALIZATION
90 _LIBCPP_END_NAMESPACE_STD
92 _LIBCPP_POP_MACROS
94 #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
96 #endif // _LIBCPP___CHRONO_TZDB_H