• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___AVAILABILITY
11#define _LIBCPP___AVAILABILITY
12
13#include <__config>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16#  pragma GCC system_header
17#endif
18
19// Libc++ is shipped by various vendors. In particular, it is used as a system
20// library on macOS, iOS and other Apple platforms. In order for users to be
21// able to compile a binary that is intended to be deployed to an older version
22// of a platform, Clang provides availability attributes [1]. These attributes
23// can be placed on declarations and are used to describe the life cycle of a
24// symbol in the library.
25//
26// The main goal is to ensure a compile-time error if a symbol that hasn't been
27// introduced in a previously released library is used in a program that targets
28// that previously released library. Normally, this would be a load-time error
29// when one tries to launch the program against the older library.
30//
31// For example, the filesystem library was introduced in the dylib in LLVM 9.
32// On Apple platforms, this corresponds to macOS 10.15. If a user compiles on
33// a macOS 10.15 host but targets macOS 10.13 with their program, the compiler
34// would normally not complain (because the required declarations are in the
35// headers), but the dynamic loader would fail to find the symbols when actually
36// trying to launch the program on macOS 10.13. To turn this into a compile-time
37// issue instead, declarations are annotated with when they were introduced, and
38// the compiler can produce a diagnostic if the program references something that
39// isn't available on the deployment target.
40//
41// This mechanism is general in nature, and any vendor can add their markup to
42// the library (see below). Whenever a new feature is added that requires support
43// in the shared library, two macros are added below to allow marking the feature
44// as unavailable:
45// 1. A macro named `_LIBCPP_AVAILABILITY_HAS_<feature>` which must be defined
46//    to `_LIBCPP_INTRODUCED_IN_<version>` for the appropriate LLVM version.
47// 2. A macro named `_LIBCPP_AVAILABILITY_<feature>`, which must be defined to
48//    `_LIBCPP_INTRODUCED_IN_<version>_MARKUP` for the appropriate LLVM version.
49//
50// When vendors decide to ship the feature as part of their shared library, they
51// can update the `_LIBCPP_INTRODUCED_IN_<version>` macro (and the markup counterpart)
52// based on the platform version they shipped that version of LLVM in. The library
53// will then use this markup to provide an optimal user experience on these platforms.
54//
55// Furthermore, many features in the standard library have corresponding
56// feature-test macros. The `_LIBCPP_AVAILABILITY_HAS_<feature>` macros
57// are checked by the corresponding feature-test macros generated by
58// generate_feature_test_macro_components.py to ensure that the library
59// doesn't announce a feature as being implemented if it is unavailable on
60// the deployment target.
61//
62// Note that this mechanism is disabled by default in the "upstream" libc++.
63// Availability annotations are only meaningful when shipping libc++ inside
64// a platform (i.e. as a system library), and so vendors that want them should
65// turn those annotations on at CMake configuration time.
66//
67// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability
68
69// For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY
70// for a while.
71#if defined(_LIBCPP_DISABLE_AVAILABILITY)
72#  if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
73#    define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
74#  endif
75#endif
76
77// Availability markup is disabled when building the library, or when a non-Clang
78// compiler is used because only Clang supports the necessary attributes.
79#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED)
80#  if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
81#    define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
82#  endif
83#endif
84
85// When availability annotations are disabled, we take for granted that features introduced
86// in all versions of the library are available.
87#if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
88
89#  define _LIBCPP_INTRODUCED_IN_LLVM_4 1
90#  define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE /* nothing */
91
92#  define _LIBCPP_INTRODUCED_IN_LLVM_9 1
93#  define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE      /* nothing */
94#  define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */
95#  define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP  /* nothing */
96
97#  define _LIBCPP_INTRODUCED_IN_LLVM_10 1
98#  define _LIBCPP_INTRODUCED_IN_LLVM_10_ATTRIBUTE /* nothing */
99
100#  define _LIBCPP_INTRODUCED_IN_LLVM_12 1
101#  define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE /* nothing */
102
103#  define _LIBCPP_INTRODUCED_IN_LLVM_14 1
104#  define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE /* nothing */
105
106#  define _LIBCPP_INTRODUCED_IN_LLVM_15 1
107#  define _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE /* nothing */
108
109#  define _LIBCPP_INTRODUCED_IN_LLVM_16 1
110#  define _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE /* nothing */
111
112#  define _LIBCPP_INTRODUCED_IN_LLVM_18 1
113#  define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE /* nothing */
114
115#  define _LIBCPP_INTRODUCED_IN_LLVM_19 1
116#  define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE /* nothing */
117
118#elif defined(__APPLE__)
119
120// LLVM 4
121#  if defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000
122#    define _LIBCPP_INTRODUCED_IN_LLVM_4 0
123#    define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE __attribute__((availability(watchos, strict, introduced = 5.0)))
124#  else
125#    define _LIBCPP_INTRODUCED_IN_LLVM_4 1
126#    define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE /* nothing */
127#  endif
128
129// LLVM 9
130// clang-format off
131#  if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) ||   \
132      (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \
133      (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) ||         \
134      (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000)
135// clang-format on
136#    define _LIBCPP_INTRODUCED_IN_LLVM_9 0
137#    define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE                                                                     \
138      __attribute__((availability(macos, strict, introduced = 10.15)))                                                 \
139      __attribute__((availability(ios, strict, introduced = 13.0)))                                                    \
140      __attribute__((availability(tvos, strict, introduced = 13.0)))                                                   \
141      __attribute__((availability(watchos, strict, introduced = 6.0)))
142// clang-format off
143#    define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH                                                                               \
144      _Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \
145      _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))")    \
146      _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))")   \
147      _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
148#    define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP                                                                    \
149      _Pragma("clang attribute pop") \
150      _Pragma("clang attribute pop") \
151      _Pragma("clang attribute pop") \
152      _Pragma("clang attribute pop")
153// clang-format on
154#  else
155#    define _LIBCPP_INTRODUCED_IN_LLVM_9 1
156#    define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE      /* nothing */
157#    define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */
158#    define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP  /* nothing */
159#  endif
160
161// LLVM 10
162// clang-format off
163#  if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) ||   \
164      (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \
165      (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) ||         \
166      (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000)
167// clang-format on
168#    define _LIBCPP_INTRODUCED_IN_LLVM_10 0
169#    define _LIBCPP_INTRODUCED_IN_LLVM_10_ATTRIBUTE                                                                    \
170      __attribute__((availability(macos, strict, introduced = 11.0)))                                                  \
171      __attribute__((availability(ios, strict, introduced = 14.0)))                                                    \
172      __attribute__((availability(tvos, strict, introduced = 14.0)))                                                   \
173      __attribute__((availability(watchos, strict, introduced = 7.0)))
174#  else
175#    define _LIBCPP_INTRODUCED_IN_LLVM_10 1
176#    define _LIBCPP_INTRODUCED_IN_LLVM_10_ATTRIBUTE /* nothing */
177#  endif
178
179// LLVM 12
180// clang-format off
181#  if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 120000)   || \
182      (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150000) || \
183      (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 150000)         || \
184      (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80000)
185// clang-format on
186#    define _LIBCPP_INTRODUCED_IN_LLVM_12 0
187#    define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE                                                                    \
188      __attribute__((availability(macos, strict, introduced = 12.0)))                                                  \
189      __attribute__((availability(ios, strict, introduced = 15.0)))                                                    \
190      __attribute__((availability(tvos, strict, introduced = 15.0)))                                                   \
191      __attribute__((availability(watchos, strict, introduced = 8.0)))
192#  else
193#    define _LIBCPP_INTRODUCED_IN_LLVM_12 1
194#    define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE /* nothing */
195#  endif
196
197// LLVM 14
198// clang-format off
199#  if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130400) ||   \
200      (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160500) || \
201      (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160500) ||         \
202      (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90500)
203// clang-format on
204#    define _LIBCPP_INTRODUCED_IN_LLVM_14 0
205#    define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE                                                                    \
206      __attribute__((availability(macos, strict, introduced = 13.4)))                                                  \
207      __attribute__((availability(ios, strict, introduced = 16.5)))                                                    \
208      __attribute__((availability(tvos, strict, introduced = 16.5)))                                                   \
209      __attribute__((availability(watchos, strict, introduced = 9.5)))
210#  else
211#    define _LIBCPP_INTRODUCED_IN_LLVM_14 1
212#    define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE /* nothing */
213#  endif
214
215// LLVM 15-16
216#  define _LIBCPP_INTRODUCED_IN_LLVM_15 _LIBCPP_INTRODUCED_IN_LLVM_16
217#  define _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE
218// clang-format off
219#  if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) ||   \
220      (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \
221      (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170000) ||         \
222      (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000)
223// clang-format on
224#    define _LIBCPP_INTRODUCED_IN_LLVM_16 0
225#    define _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE                                                                    \
226      __attribute__((availability(macos, strict, introduced = 14.0)))                                                  \
227      __attribute__((availability(ios, strict, introduced = 17.0)))                                                    \
228      __attribute__((availability(tvos, strict, introduced = 17.0)))                                                   \
229      __attribute__((availability(watchos, strict, introduced = 10.0)))
230#  else
231#    define _LIBCPP_INTRODUCED_IN_LLVM_16 1
232#    define _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE /* nothing */
233#  endif
234
235// LLVM 18
236// TODO: Fill this in
237#  if 1
238#    define _LIBCPP_INTRODUCED_IN_LLVM_18 0
239#    define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE __attribute__((unavailable))
240#  else
241#    define _LIBCPP_INTRODUCED_IN_LLVM_18 1
242#    define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE /* nothing */
243#  endif
244
245// LLVM 19
246// TODO: Fill this in
247#  if 1
248#    define _LIBCPP_INTRODUCED_IN_LLVM_19 0
249#    define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE __attribute__((unavailable))
250#  else
251#    define _LIBCPP_INTRODUCED_IN_LLVM_19 1
252#    define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE /* nothing */
253#  endif
254
255#else
256
257// ...New vendors can add availability markup here...
258
259#  error                                                                                                               \
260      "It looks like you're trying to enable vendor availability markup, but you haven't defined the corresponding macros yet!"
261
262#endif
263
264// These macros control the availability of std::bad_optional_access and
265// other exception types. These were put in the shared library to prevent
266// code bloat from every user program defining the vtable for these exception
267// types.
268//
269// Note that when exceptions are disabled, the methods that normally throw
270// these exceptions can be used even on older deployment targets, but those
271// methods will abort instead of throwing.
272#define _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4
273#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE
274
275#define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4
276#define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE
277
278#define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST _LIBCPP_INTRODUCED_IN_LLVM_4
279#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE
280
281// These macros control the availability of all parts of <filesystem> that
282// depend on something in the dylib.
283#define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9
284#define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE
285#define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH
286#define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP
287
288// This controls the availability of the C++20 synchronization library,
289// which requires shared library support for various operations
290// (see libcxx/src/atomic.cpp). This includes <barier>, <latch>,
291// <semaphore>, and notification functions on std::atomic.
292#define _LIBCPP_AVAILABILITY_HAS_SYNC _LIBCPP_INTRODUCED_IN_LLVM_10
293#define _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INTRODUCED_IN_LLVM_10_ATTRIBUTE
294
295// Enable additional explicit instantiations of iostreams components. This
296// reduces the number of weak definitions generated in programs that use
297// iostreams by providing a single strong definition in the shared library.
298//
299// TODO: Enable additional explicit instantiations on GCC once it supports exclude_from_explicit_instantiation,
300//       or once libc++ doesn't use the attribute anymore.
301// TODO: Enable them on Windows once https://llvm.org/PR41018 has been fixed.
302#if !defined(_LIBCPP_COMPILER_GCC) && !defined(_WIN32)
303#  define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 _LIBCPP_INTRODUCED_IN_LLVM_12
304#else
305#  define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0
306#endif
307
308// This controls the availability of floating-point std::to_chars functions.
309// These overloads were added later than the integer overloads.
310#define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_14
311#define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE
312
313// This controls whether the library claims to provide a default verbose
314// termination function, and consequently whether the headers will try
315// to use it when the mechanism isn't overriden at compile-time.
316#define _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT _LIBCPP_INTRODUCED_IN_LLVM_15
317#define _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE
318
319// This controls the availability of the C++17 std::pmr library,
320// which is implemented in large part in the built library.
321//
322// TODO: Enable std::pmr markup once https://github.com/llvm/llvm-project/issues/40340 has been fixed
323//       Until then, it is possible for folks to try to use `std::pmr` when back-deploying to targets that don't support
324//       it and it'll be a load-time error, but we don't have a good alternative because the library won't compile if we
325//       use availability annotations until that bug has been fixed.
326#define _LIBCPP_AVAILABILITY_HAS_PMR _LIBCPP_INTRODUCED_IN_LLVM_16
327#define _LIBCPP_AVAILABILITY_PMR
328
329// These macros controls the availability of __cxa_init_primary_exception
330// in the built library, which std::make_exception_ptr might use
331// (see libcxx/include/__exception/exception_ptr.h).
332#define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION _LIBCPP_INTRODUCED_IN_LLVM_18
333#define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE
334
335// This controls the availability of C++23 <print>, which
336// has a dependency on the built library (it needs access to
337// the underlying buffer types of std::cout, std::cerr, and std::clog.
338#define _LIBCPP_AVAILABILITY_HAS_PRINT _LIBCPP_INTRODUCED_IN_LLVM_18
339#define _LIBCPP_AVAILABILITY_PRINT _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE
340
341// This controls the availability of the C++20 time zone database.
342// The parser code is built in the library.
343#define _LIBCPP_AVAILABILITY_HAS_TZDB _LIBCPP_INTRODUCED_IN_LLVM_19
344#define _LIBCPP_AVAILABILITY_TZDB _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE
345
346// These macros determine whether we assume that std::bad_function_call and
347// std::bad_expected_access provide a key function in the dylib. This allows
348// centralizing their vtable and typeinfo instead of having all TUs provide
349// a weak definition that then gets deduplicated.
350#define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19
351#define _LIBCPP_AVAILABILITY_BAD_FUNCTION_CALL_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE
352#define _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19
353#define _LIBCPP_AVAILABILITY_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE
354
355// Define availability attributes that depend on _LIBCPP_HAS_NO_EXCEPTIONS.
356// Those are defined in terms of the availability attributes above, and
357// should not be vendor-specific.
358#if defined(_LIBCPP_HAS_NO_EXCEPTIONS)
359#  define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
360#  define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
361#  define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
362#else
363#  define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
364#  define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
365#  define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
366#endif
367
368// Define availability attributes that depend on both
369// _LIBCPP_HAS_NO_EXCEPTIONS and _LIBCPP_HAS_NO_RTTI.
370#if defined(_LIBCPP_HAS_NO_EXCEPTIONS) || defined(_LIBCPP_HAS_NO_RTTI)
371#  undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
372#  undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
373#  define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0
374#  define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
375#endif
376
377#endif // _LIBCPP___AVAILABILITY
378