[libc++] Make the __availability header a sub-header of __config (#93083)

In essence, this header has always been related to configuration of
the library but we didn't want to put it inside <__config> due to
complexity reasons. Now that we have sub-headers in <__config>, we
can move <__availability> to it and stop including it everywhere since
we already obtain the required macros via <__config>.
This commit is contained in:
Louis Dionne 2024-05-28 18:29:11 -07:00 committed by GitHub
parent 6abc3876c3
commit 04f01a2b9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
61 changed files with 60 additions and 94 deletions

View File

@ -122,7 +122,7 @@ option(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS
on definitions in a shared library. By default, we assume that we're not building
libc++ for any specific vendor, and we disable those annotations. Vendors wishing
to provide compile-time errors when using features unavailable on some version of
the shared library they shipped should turn this on and see `include/__availability`
the shared library they shipped should turn this on and see `include/__configuration/availability.h`
for more details." OFF)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

View File

@ -219,7 +219,6 @@ set(files
__atomic/kill_dependency.h
__atomic/memory_order.h
__atomic/to_gcc_order.h
__availability
__bit/bit_cast.h
__bit/bit_ceil.h
__bit/bit_floor.h
@ -315,7 +314,9 @@ set(files
__condition_variable/condition_variable.h
__config
__configuration/abi.h
__configuration/availability.h
__configuration/compiler.h
__configuration/language.h
__configuration/platform.h
__coroutine/coroutine_handle.h
__coroutine/coroutine_traits.h

View File

@ -14,7 +14,6 @@
#include <__atomic/cxx_atomic_impl.h>
#include <__atomic/is_always_lock_free.h>
#include <__atomic/memory_order.h>
#include <__availability>
#include <__config>
#include <__memory/addressof.h>
#include <__type_traits/is_integral.h>

View File

@ -13,7 +13,6 @@
#include <__atomic/contention_t.h>
#include <__atomic/cxx_atomic_impl.h>
#include <__atomic/memory_order.h>
#include <__availability>
#include <__chrono/duration.h>
#include <__config>
#include <__memory/addressof.h>

View File

@ -13,7 +13,6 @@
#include <__atomic/cxx_atomic_impl.h>
#include <__atomic/memory_order.h>
#include <__atomic/to_gcc_order.h>
#include <__availability>
#include <__chrono/duration.h>
#include <__config>
#include <__memory/addressof.h>

View File

@ -10,7 +10,6 @@
#ifndef _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H
#define _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H
#include <__availability>
#include <__charconv/chars_format.h>
#include <__charconv/to_chars_result.h>
#include <__config>

View File

@ -10,7 +10,6 @@
#ifndef _LIBCPP___CHRONO_FILE_CLOCK_H
#define _LIBCPP___CHRONO_FILE_CLOCK_H
#include <__availability>
#include <__chrono/duration.h>
#include <__chrono/system_clock.h>
#include <__chrono/time_point.h>

View File

@ -16,7 +16,6 @@
// 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/time_zone.h>
# include <__chrono/tzdb.h>
# include <__config>

View File

@ -12,6 +12,7 @@
#include <__config_site>
#include <__configuration/abi.h>
#include <__configuration/availability.h>
#include <__configuration/compiler.h>
#include <__configuration/platform.h>
@ -35,25 +36,6 @@
# define _LIBCPP_FREESTANDING
# endif
// NOLINTBEGIN(libcpp-cpp-version-check)
# ifndef _LIBCPP_STD_VER
# if __cplusplus <= 201103L
# define _LIBCPP_STD_VER 11
# elif __cplusplus <= 201402L
# define _LIBCPP_STD_VER 14
# elif __cplusplus <= 201703L
# define _LIBCPP_STD_VER 17
# elif __cplusplus <= 202002L
# define _LIBCPP_STD_VER 20
# elif __cplusplus <= 202302L
# define _LIBCPP_STD_VER 23
# else
// Expected release year of the next C++ standard
# define _LIBCPP_STD_VER 26
# endif
# endif // _LIBCPP_STD_VER
// NOLINTEND(libcpp-cpp-version-check)
// HARDENING {
// TODO(hardening): deprecate this in LLVM 19.
@ -364,10 +346,6 @@ typedef __char32_t char32_t;
# endif
# if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
# define _LIBCPP_HAS_NO_EXCEPTIONS
# endif
# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
# if defined(_LIBCPP_COMPILER_CLANG_BASED)
@ -840,11 +818,6 @@ typedef __char32_t char32_t;
# define _LIBCPP_CONSTEXPR_SINCE_CXX23
# endif
// Try to find out if RTTI is disabled.
# if !defined(__cpp_rtti) || __cpp_rtti < 199711L
# define _LIBCPP_HAS_NO_RTTI
# endif
# ifndef _LIBCPP_WEAK
# define _LIBCPP_WEAK __attribute__((__weak__))
# endif

View File

@ -7,10 +7,11 @@
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP___AVAILABILITY
#define _LIBCPP___AVAILABILITY
#ifndef _LIBCPP___CONFIGURATION_AVAILABILITY_H
#define _LIBCPP___CONFIGURATION_AVAILABILITY_H
#include <__config>
#include <__configuration/compiler.h>
#include <__configuration/language.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@ -374,4 +375,4 @@
# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
#endif
#endif // _LIBCPP___AVAILABILITY
#endif // _LIBCPP___CONFIGURATION_AVAILABILITY_H

View File

@ -0,0 +1,46 @@
// -*- 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
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP___CONFIGURATION_LANGUAGE_H
#define _LIBCPP___CONFIGURATION_LANGUAGE_H
#include <__config_site>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
# pragma GCC system_header
#endif
// NOLINTBEGIN(libcpp-cpp-version-check)
#ifdef __cplusplus
# if __cplusplus <= 201103L
# define _LIBCPP_STD_VER 11
# elif __cplusplus <= 201402L
# define _LIBCPP_STD_VER 14
# elif __cplusplus <= 201703L
# define _LIBCPP_STD_VER 17
# elif __cplusplus <= 202002L
# define _LIBCPP_STD_VER 20
# elif __cplusplus <= 202302L
# define _LIBCPP_STD_VER 23
# else
// Expected release year of the next C++ standard
# define _LIBCPP_STD_VER 26
# endif
#endif // __cplusplus
// NOLINTEND(libcpp-cpp-version-check)
#if !defined(__cpp_rtti) || __cpp_rtti < 199711L
# define _LIBCPP_HAS_NO_RTTI
#endif
#if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
# define _LIBCPP_HAS_NO_EXCEPTIONS
#endif
#endif // _LIBCPP___CONFIGURATION_LANGUAGE_H

View File

@ -9,7 +9,6 @@
#ifndef _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
#define _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
#include <__availability>
#include <__config>
#include <__exception/operations.h>
#include <__memory/addressof.h>

View File

@ -9,7 +9,6 @@
#ifndef _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
#define _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
#include <__availability>
#include <__config>
#include <__exception/exception.h>
#include <__utility/move.h>

View File

@ -10,7 +10,6 @@
#ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H
#define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H
#include <__availability>
#include <__chrono/time_point.h>
#include <__compare/ordering.h>
#include <__config>

View File

@ -11,7 +11,6 @@
#define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H
#include <__assert>
#include <__availability>
#include <__config>
#include <__filesystem/directory_entry.h>
#include <__filesystem/directory_options.h>

View File

@ -10,7 +10,6 @@
#ifndef _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H
#define _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H
#include <__availability>
#include <__config>
#include <__filesystem/path.h>
#include <__memory/shared_ptr.h>

View File

@ -10,7 +10,6 @@
#ifndef _LIBCPP___FILESYSTEM_OPERATIONS_H
#define _LIBCPP___FILESYSTEM_OPERATIONS_H
#include <__availability>
#include <__chrono/time_point.h>
#include <__config>
#include <__filesystem/copy_options.h>

View File

@ -12,7 +12,6 @@
#include <__algorithm/replace.h>
#include <__algorithm/replace_copy.h>
#include <__availability>
#include <__config>
#include <__functional/unary_function.h>
#include <__fwd/functional.h>

View File

@ -11,7 +11,6 @@
#define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H
#include <__assert>
#include <__availability>
#include <__config>
#include <__filesystem/path.h>
#include <__iterator/iterator_traits.h>

View File

@ -10,7 +10,6 @@
#ifndef _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H
#define _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H
#include <__availability>
#include <__config>
#include <__filesystem/directory_entry.h>
#include <__filesystem/directory_options.h>

View File

@ -11,7 +11,6 @@
#define _LIBCPP___FILESYSTEM_U8PATH_H
#include <__algorithm/unwrap_iter.h>
#include <__availability>
#include <__config>
#include <__filesystem/path.h>
#include <string>

View File

@ -11,7 +11,6 @@
#define _LIBCPP___FUNCTIONAL_FUNCTION_H
#include <__assert>
#include <__availability>
#include <__config>
#include <__exception/exception.h>
#include <__functional/binary_function.h>

View File

@ -9,7 +9,6 @@
#ifndef _LIBCPP___FWD_MEMORY_RESOURCE_H
#define _LIBCPP___FWD_MEMORY_RESOURCE_H
#include <__availability>
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View File

@ -9,7 +9,6 @@
#ifndef _LIBCPP___FWD_STRING_H
#define _LIBCPP___FWD_STRING_H
#include <__availability>
#include <__config>
#include <__fwd/memory.h>
#include <__fwd/memory_resource.h>

View File

@ -9,7 +9,6 @@
#ifndef _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H
#define _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H
#include <__availability>
#include <__config>
#include <__fwd/memory_resource.h>
#include <cstddef>

View File

@ -9,7 +9,6 @@
#ifndef _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
#define _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
#include <__availability>
#include <__config>
#include <__memory/addressof.h>
#include <__memory_resource/memory_resource.h>

View File

@ -10,7 +10,6 @@
#define _LIBCPP___MEMORY_RESOURCE_POLYMORPHIC_ALLOCATOR_H
#include <__assert>
#include <__availability>
#include <__config>
#include <__fwd/pair.h>
#include <__memory_resource/memory_resource.h>

View File

@ -9,7 +9,6 @@
#ifndef _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
#define _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
#include <__availability>
#include <__config>
#include <__memory_resource/memory_resource.h>
#include <__memory_resource/pool_options.h>

View File

@ -9,7 +9,6 @@
#ifndef _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
#define _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
#include <__availability>
#include <__config>
#include <__memory_resource/memory_resource.h>
#include <__memory_resource/pool_options.h>

View File

@ -9,7 +9,6 @@
#ifndef _LIBCPP___OSTREAM_PRINT_H
#define _LIBCPP___OSTREAM_PRINT_H
#include <__availability>
#include <__config>
#include <__fwd/ostream.h>
#include <__iterator/ostreambuf_iterator.h>

View File

@ -10,7 +10,6 @@
#ifndef _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H
#define _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H
#include <__availability>
#include <__concepts/constructible.h>
#include <__concepts/destructible.h>
#include <__concepts/invocable.h>

View File

@ -10,7 +10,6 @@
#ifndef _LIBCPP___STOP_TOKEN_STOP_SOURCE_H
#define _LIBCPP___STOP_TOKEN_STOP_SOURCE_H
#include <__availability>
#include <__config>
#include <__stop_token/intrusive_shared_ptr.h>
#include <__stop_token/stop_state.h>

View File

@ -11,7 +11,6 @@
#define _LIBCPP___STOP_TOKEN_STOP_STATE_H
#include <__assert>
#include <__availability>
#include <__config>
#include <__stop_token/atomic_unique_lock.h>
#include <__stop_token/intrusive_list_view.h>

View File

@ -10,7 +10,6 @@
#ifndef _LIBCPP___STOP_TOKEN_STOP_TOKEN_H
#define _LIBCPP___STOP_TOKEN_STOP_TOKEN_H
#include <__availability>
#include <__config>
#include <__stop_token/intrusive_shared_ptr.h>
#include <__stop_token/stop_state.h>

View File

@ -10,7 +10,6 @@
#ifndef _LIBCPP___THREAD_JTHREAD_H
#define _LIBCPP___THREAD_JTHREAD_H
#include <__availability>
#include <__config>
#include <__functional/invoke.h>
#include <__stop_token/stop_source.h>

View File

@ -10,7 +10,6 @@
#ifndef _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
#include <__availability>
#include <__chrono/duration.h>
#include <__chrono/high_resolution_clock.h>
#include <__config>

View File

@ -10,7 +10,6 @@
#ifndef _LIBCPP___VERBOSE_ABORT
#define _LIBCPP___VERBOSE_ABORT
#include <__availability>
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View File

@ -54,7 +54,6 @@ namespace std
#include <__assert>
#include <__atomic/atomic_base.h>
#include <__atomic/memory_order.h>
#include <__availability>
#include <__memory/unique_ptr.h>
#include <__thread/poll_with_backoff.h>
#include <__thread/timed_backoff_policy.h>

View File

@ -118,7 +118,6 @@ public:
*/
#include <__availability>
#include <__chrono/duration.h>
#include <__chrono/steady_clock.h>
#include <__chrono/time_point.h>

View File

@ -189,7 +189,6 @@ template <class T, class Allocator, class Predicate>
#include <__algorithm/remove_if.h>
#include <__algorithm/unwrap_iter.h>
#include <__assert>
#include <__availability>
#include <__config>
#include <__debug_utils/sanitizers.h>
#include <__format/enable_insertable.h>

View File

@ -199,7 +199,6 @@ template <class T, class Allocator, class Predicate>
#include <__algorithm/lexicographical_compare.h>
#include <__algorithm/lexicographical_compare_three_way.h>
#include <__algorithm/min.h>
#include <__availability>
#include <__config>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>

View File

@ -188,7 +188,6 @@ typedef basic_fstream<wchar_t> wfstream;
#include <__algorithm/max.h>
#include <__assert>
#include <__availability>
#include <__config>
#include <__fwd/fstream.h>
#include <__locale>

View File

@ -50,7 +50,6 @@ namespace std
#include <__atomic/atomic_base.h>
#include <__atomic/atomic_sync.h>
#include <__atomic/memory_order.h>
#include <__availability>
#include <cstddef>
#include <limits>
#include <version>

View File

@ -203,7 +203,6 @@ template <class T, class Allocator, class Predicate>
#include <__algorithm/lexicographical_compare_three_way.h>
#include <__algorithm/min.h>
#include <__assert>
#include <__availability>
#include <__config>
#include <__format/enable_insertable.h>
#include <__iterator/distance.h>

View File

@ -575,7 +575,6 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
#include <__algorithm/lexicographical_compare.h>
#include <__algorithm/lexicographical_compare_three_way.h>
#include <__assert>
#include <__availability>
#include <__config>
#include <__functional/binary_function.h>
#include <__functional/is_transparent.h>

View File

@ -570,10 +570,6 @@ module std_private_assert [system] {
header "__assert"
export *
}
module std_private_availability [system] {
header "__availability"
export *
}
module std_private_bit_reference [system] {
header "__bit_reference"
export *
@ -584,7 +580,9 @@ module std_private_fwd_bit_reference [system] {
module std_private_config [system] {
textual header "__config"
textual header "__configuration/abi.h"
textual header "__configuration/availability.h"
textual header "__configuration/compiler.h"
textual header "__configuration/language.h"
textual header "__configuration/platform.h"
export *
}

View File

@ -178,7 +178,6 @@ namespace std {
*/
#include <__assert>
#include <__availability>
#include <__compare/compare_three_way_result.h>
#include <__compare/three_way_comparable.h>
#include <__concepts/invocable.h>

View File

@ -34,7 +34,6 @@ namespace std {
*/
#include <__assert>
#include <__availability>
#include <__concepts/same_as.h>
#include <__config>
#include <__system_error/system_error.h>

View File

@ -792,7 +792,6 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
#include <__algorithm/find.h>
#include <__algorithm/search.h>
#include <__assert>
#include <__availability>
#include <__config>
#include <__iterator/back_insert_iterator.h>
#include <__iterator/default_sentinel.h>

View File

@ -55,7 +55,6 @@ using binary_semaphore = counting_semaphore<1>;
#include <__atomic/atomic_base.h>
#include <__atomic/atomic_sync.h>
#include <__atomic/memory_order.h>
#include <__availability>
#include <__chrono/time_point.h>
#include <__thread/poll_with_backoff.h>
#include <__thread/support.h>

View File

@ -516,7 +516,6 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
#include <__algorithm/lexicographical_compare.h>
#include <__algorithm/lexicographical_compare_three_way.h>
#include <__assert>
#include <__availability>
#include <__config>
#include <__functional/is_transparent.h>
#include <__functional/operations.h>

View File

@ -312,7 +312,6 @@ typedef basic_stringstream<wchar_t> wstringstream;
// clang-format on
#include <__availability>
#include <__config>
#include <__fwd/sstream.h>
#include <__ostream/basic_ostream.h>

View File

@ -585,7 +585,6 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
#include <__algorithm/is_permutation.h>
#include <__assert>
#include <__availability>
#include <__config>
#include <__functional/is_transparent.h>
#include <__functional/operations.h>

View File

@ -533,7 +533,6 @@ template <class Value, class Hash, class Pred, class Alloc>
#include <__algorithm/is_permutation.h>
#include <__assert>
#include <__availability>
#include <__config>
#include <__functional/is_transparent.h>
#include <__functional/operations.h>

View File

@ -212,7 +212,6 @@ namespace std {
*/
#include <__availability>
#include <__compare/common_comparison_category.h>
#include <__compare/compare_three_way_result.h>
#include <__compare/three_way_comparable.h>

View File

@ -316,7 +316,6 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
#include <__algorithm/rotate.h>
#include <__algorithm/unwrap_iter.h>
#include <__assert>
#include <__availability>
#include <__bit_reference>
#include <__concepts/same_as.h>
#include <__config>

View File

@ -255,7 +255,6 @@ __cpp_lib_void_t 201411L <type_traits>
*/
#include <__availability>
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View File

@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
#include <__availability>
#include <optional>
#include <stdexcept>

View File

@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
#include <__availability>
#include <__config>
#ifndef _LIBCPP_HAS_NO_FILESYSTEM
# include <fstream>

View File

@ -15,7 +15,7 @@
// ADDITIONAL_COMPILE_FLAGS: -pedantic-errors
#include <__availability>
#include <__config>
#if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
# error Availability annotations should be enabled on Apple platforms in the system configuration!

View File

@ -61,7 +61,8 @@ def add_version_header(tc):
# just libc++. It may depend on
# * macros defined by the compiler itself, or
# * macros generated by CMake.
# In some cases we add also depend on macros defined in <__availability>.
# In some cases we add also depend on macros defined in
# <__configuration/availability.h>.
# libcxx_guard An optional string field. When this field is provided,
# `test_suite_guard` must also be provided. This field is used
# only to guard the feature-test macro in <version>. It may
@ -1562,7 +1563,6 @@ def produce_version_header():
*/
#include <__availability>
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)