diff --git a/libc/src/__support/CPP/functional.h b/libc/src/__support/CPP/functional.h index 5ddb988d33125..e346011debab1 100644 --- a/libc/src/__support/CPP/functional.h +++ b/libc/src/__support/CPP/functional.h @@ -9,13 +9,8 @@ #ifndef LLVM_LIBC_SRC_SUPPORT_CPP_FUNCTIONAL_H #define LLVM_LIBC_SRC_SUPPORT_CPP_FUNCTIONAL_H -#include "src/__support/CPP/type_traits/enable_if.h" -#include "src/__support/CPP/type_traits/is_convertible.h" -#include "src/__support/CPP/type_traits/is_same.h" -#include "src/__support/CPP/type_traits/is_void.h" -#include "src/__support/CPP/type_traits/remove_cvref.h" -#include "src/__support/CPP/type_traits/remove_reference.h" -#include "src/__support/CPP/utility/forward.h" +#include "src/__support/CPP/type_traits.h" +#include "src/__support/CPP/utility.h" #include "src/__support/macros/attributes.h" #include @@ -35,7 +30,7 @@ template class function { template LIBC_INLINE static Ret callback_fn(intptr_t callable, Params... params) { return (*reinterpret_cast(callable))( - cpp::forward(params)...); + forward(params)...); } public: @@ -47,18 +42,18 @@ template class function { LIBC_INLINE function( Callable &&callable, // This is not the copy-constructor. - enable_if_t, function>> * = + enable_if_t, function>::value> * = nullptr, // Functor must be callable and return a suitable type. - enable_if_t || - cpp::is_convertible_v< + enable_if_t || + is_convertible_v< decltype(declval()(declval()...)), Ret>> * = nullptr) - : callback(callback_fn>), + : callback(callback_fn>), callable(reinterpret_cast(&callable)) {} LIBC_INLINE Ret operator()(Params... params) const { - return callback(callable, cpp::forward(params)...); + return callback(callable, forward(params)...); } LIBC_INLINE explicit operator bool() const { return callback; } diff --git a/libc/src/__support/CPP/type_traits.h b/libc/src/__support/CPP/type_traits.h index 7794b39e0d8f4..aa0a6375e2020 100644 --- a/libc/src/__support/CPP/type_traits.h +++ b/libc/src/__support/CPP/type_traits.h @@ -1,4 +1,4 @@ -//===-- Self contained C++ type_traits --------------------------*- C++ -*-===// +//===-- Self contained C++ type traits --------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,51 +6,344 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_H - -#include "src/__support/CPP/type_traits/add_lvalue_reference.h" -#include "src/__support/CPP/type_traits/add_pointer.h" -#include "src/__support/CPP/type_traits/add_rvalue_reference.h" -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/CPP/type_traits/conditional.h" -#include "src/__support/CPP/type_traits/decay.h" -#include "src/__support/CPP/type_traits/enable_if.h" -#include "src/__support/CPP/type_traits/false_type.h" -#include "src/__support/CPP/type_traits/integral_constant.h" -#include "src/__support/CPP/type_traits/is_arithmetic.h" -#include "src/__support/CPP/type_traits/is_array.h" -#include "src/__support/CPP/type_traits/is_base_of.h" -#include "src/__support/CPP/type_traits/is_class.h" -#include "src/__support/CPP/type_traits/is_const.h" -#include "src/__support/CPP/type_traits/is_convertible.h" -#include "src/__support/CPP/type_traits/is_destructible.h" -#include "src/__support/CPP/type_traits/is_enum.h" -#include "src/__support/CPP/type_traits/is_floating_point.h" -#include "src/__support/CPP/type_traits/is_function.h" -#include "src/__support/CPP/type_traits/is_integral.h" -#include "src/__support/CPP/type_traits/is_lvalue_reference.h" -#include "src/__support/CPP/type_traits/is_null_pointer.h" -#include "src/__support/CPP/type_traits/is_pointer.h" -#include "src/__support/CPP/type_traits/is_reference.h" -#include "src/__support/CPP/type_traits/is_rvalue_reference.h" -#include "src/__support/CPP/type_traits/is_same.h" -#include "src/__support/CPP/type_traits/is_signed.h" -#include "src/__support/CPP/type_traits/is_trivially_constructible.h" -#include "src/__support/CPP/type_traits/is_trivially_copyable.h" -#include "src/__support/CPP/type_traits/is_trivially_destructible.h" -#include "src/__support/CPP/type_traits/is_union.h" -#include "src/__support/CPP/type_traits/is_unsigned.h" -#include "src/__support/CPP/type_traits/is_void.h" -#include "src/__support/CPP/type_traits/make_signed.h" -#include "src/__support/CPP/type_traits/make_unsigned.h" -#include "src/__support/CPP/type_traits/remove_all_extents.h" -#include "src/__support/CPP/type_traits/remove_cv.h" -#include "src/__support/CPP/type_traits/remove_cvref.h" -#include "src/__support/CPP/type_traits/remove_extent.h" -#include "src/__support/CPP/type_traits/remove_reference.h" -#include "src/__support/CPP/type_traits/true_type.h" -#include "src/__support/CPP/type_traits/type_identity.h" -#include "src/__support/CPP/type_traits/void_t.h" - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_H +#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_TYPETRAITS_H +#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPETRAITS_H + +#include "src/__support/macros/attributes.h" +#include "src/__support/macros/config.h" + +#include // For size_t. + +namespace __llvm_libc { +namespace cpp { + +template struct type_identity { + using type = T; +}; + +template struct enable_if; +template struct enable_if : type_identity {}; +template +using enable_if_t = typename enable_if::type; + +template struct integral_constant { + using value_type = T; + LIBC_INLINE_VAR static constexpr T value = v; +}; +using true_type = cpp::integral_constant; +using false_type = cpp::integral_constant; + +template using bool_constant = integral_constant; + +template +struct is_trivially_copyable + : public integral_constant {}; + +template +struct is_trivially_constructible + : integral_constant {}; + +template struct is_same : cpp::false_type {}; +template struct is_same : cpp::true_type {}; +template +LIBC_INLINE_VAR constexpr bool is_same_v = is_same::value; + +template struct is_const : cpp::false_type {}; +template struct is_const : cpp::true_type {}; +template +LIBC_INLINE_VAR constexpr bool is_const_v = is_const::value; + +template struct remove_cv : type_identity {}; +template struct remove_cv : type_identity {}; +template struct remove_cv : type_identity {}; +template struct remove_cv : type_identity {}; +template using remove_cv_t = typename remove_cv::type; + +template struct remove_reference : type_identity {}; +template struct remove_reference : type_identity {}; +template struct remove_reference : type_identity {}; +template +using remove_reference_t = typename remove_reference::type; + +template struct add_rvalue_reference : type_identity {}; + +template struct remove_cvref { + using type = remove_cv_t>; +}; +template using remove_cvref_t = typename remove_cvref::type; + +namespace details { +template +LIBC_INLINE constexpr bool is_unqualified_any_of() { + return (... || is_same_v, Args>); +} +} // namespace details + +template struct is_integral { + LIBC_INLINE_VAR static constexpr bool value = details::is_unqualified_any_of< + T, +#ifdef __SIZEOF_INT128__ + __int128_t, __uint128_t, +#endif + char, signed char, unsigned char, short, unsigned short, int, + unsigned int, long, unsigned long, long long, unsigned long long, bool>(); +}; +template +LIBC_INLINE_VAR constexpr bool is_integral_v = is_integral::value; + +template struct is_enum { + LIBC_INLINE_VAR static constexpr bool value = __is_enum(T); +}; +template +LIBC_INLINE_VAR constexpr bool is_enum_v = is_enum::value; + +template struct is_pointer : cpp::false_type {}; +template struct is_pointer : cpp::true_type {}; +template struct is_pointer : cpp::true_type {}; +template struct is_pointer : cpp::true_type {}; +template struct is_pointer : cpp::true_type {}; +template +LIBC_INLINE_VAR constexpr bool is_pointer_v = is_pointer::value; + +template struct is_floating_point { + LIBC_INLINE_VAR static constexpr bool value = + details::is_unqualified_any_of(); +}; +template +LIBC_INLINE_VAR constexpr bool is_floating_point_v = + is_floating_point::value; + +template struct is_arithmetic { + LIBC_INLINE_VAR static constexpr bool value = + is_integral::value || is_floating_point::value; +}; +template +LIBC_INLINE_VAR constexpr bool is_arithmetic_v = is_arithmetic::value; + +namespace details { +template ::value> +struct is_signed : integral_constant {}; +template struct is_signed : false_type {}; + +template ::value> +struct is_unsigned : integral_constant T(0))> {}; +template struct is_unsigned : false_type {}; +} // namespace details + +template struct is_signed { + LIBC_INLINE_VAR static constexpr bool value = details::is_signed::value; + LIBC_INLINE constexpr operator bool() const { return value; } + LIBC_INLINE constexpr bool operator()() const { return value; } +}; +template +LIBC_INLINE_VAR constexpr bool is_signed_v = is_signed::value; + +template struct is_unsigned { + LIBC_INLINE_VAR static constexpr bool value = details::is_unsigned::value; + LIBC_INLINE constexpr operator bool() const { return value; } + LIBC_INLINE constexpr bool operator()() const { return value; } +}; +template +LIBC_INLINE_VAR constexpr bool is_unsigned_v = is_unsigned::value; + +template struct make_unsigned; +template <> struct make_unsigned : type_identity {}; +template <> struct make_unsigned : type_identity {}; +template <> struct make_unsigned : type_identity {}; +template <> struct make_unsigned : type_identity {}; +template <> struct make_unsigned : type_identity {}; +template <> +struct make_unsigned : type_identity {}; +template <> +struct make_unsigned : type_identity {}; +template <> +struct make_unsigned : type_identity {}; +template <> struct make_unsigned : type_identity {}; +template <> +struct make_unsigned : type_identity {}; +template <> +struct make_unsigned : type_identity {}; +#ifdef __SIZEOF_INT128__ +template <> struct make_unsigned<__int128_t> : type_identity<__uint128_t> {}; +template <> struct make_unsigned<__uint128_t> : type_identity<__uint128_t> {}; +#endif +template using make_unsigned_t = typename make_unsigned::type; + +template struct make_signed; +template <> struct make_signed : type_identity {}; +template <> struct make_signed : type_identity {}; +template <> struct make_signed : type_identity {}; +template <> struct make_signed : type_identity {}; +template <> struct make_signed : type_identity {}; +template <> struct make_signed : type_identity {}; +template <> struct make_signed : type_identity {}; +template <> struct make_signed : type_identity {}; +template <> struct make_signed : type_identity {}; +template <> struct make_signed : type_identity {}; +template <> +struct make_signed : type_identity {}; +#ifdef __SIZEOF_INT128__ +template <> struct make_signed<__int128_t> : type_identity<__int128_t> {}; +template <> struct make_signed<__uint128_t> : type_identity<__int128_t> {}; +#endif +template using make_signed_t = typename make_signed::type; + +// Compile time type selection. +template +struct conditional : type_identity {}; +template +struct conditional : type_identity {}; +template +using conditional_t = typename conditional::type; + +template +struct is_void : is_same::type> {}; +template +LIBC_INLINE_VAR constexpr bool is_void_v = is_void::value; +template T declval(); + +// Compile time checks on implicit conversions. +namespace details { +template using void_t = void; +template void convertible_to_helper(T); +} // namespace details + +template +LIBC_INLINE_VAR constexpr bool is_convertible_v = false; + +// FIXME: This should use LIBC_INLINE_VAR, but clang buggily complains about +// this when LIBC_INLINE_VAR uses [[clang::internal_linkage]]. +template +constexpr bool + is_convertible_v( + declval()))>> = true; + +namespace details { +#if LIBC_HAS_BUILTIN(__is_lvalue_reference) && \ + LIBC_HAS_BUILTIN(__is_rvalue_reference) && \ + LIBC_HAS_BUILTIN(__is_reference) + +template +struct is_lvalue_reference : bool_constant<__is_lvalue_reference(T)> {}; +template +struct is_rvalue_reference : bool_constant<__is_rvalue_reference(T)> {}; +template struct is_reference : bool_constant<__is_reference(T)> {}; + +#else // LIBC_HAS_BUILTIN(__is_lvalue_reference) && etc... + +template struct is_lvalue_reference : public false_type {}; +template struct is_lvalue_reference : public true_type {}; + +template struct is_rvalue_reference : public false_type {}; +template struct is_rvalue_reference : public true_type {}; + +template struct is_reference : public false_type {}; +template struct is_reference : public true_type {}; +template struct is_reference : public true_type {}; + +#endif // LIBC_HAS_BUILTIN(__is_lvalue_reference) && etc... + +#if LIBC_HAS_BUILTIN(__remove_all_extents) +template using __remove_all_extents_t = __remove_all_extents(T); +#else +template struct remove_all_extents { + typedef T type; +}; +template struct remove_all_extents { + typedef typename remove_all_extents::type type; +}; +template struct remove_all_extents { + typedef typename remove_all_extents::type type; +}; + +template +using __remove_all_extents_t = typename remove_all_extents::type; +#endif // LIBC_HAS_BUILTIN(__remove_all_extents) + +#if LIBC_HAS_BUILTIN(__is_function) + +template +struct is_function : integral_constant {}; + +#else + +template +struct is_function + : public integral_constant::value || + is_const::value)> {}; + +#endif // LIBC_HAS_BUILTIN(__is_function) + +#if LIBC_HAS_BUILTIN(__is_destructible) + +template +struct is_destructible : bool_constant<__is_destructible(T)> {}; + +#else // LIBC_HAS_BUILTIN(__is_destructible) + +// if it's a reference, return true +// if it's a function, return false +// if it's void, return false +// if it's an array of unknown bound, return false +// Otherwise, return "declval().~T()" is well-formed +// where T is remove_all_extents::type + +template struct __is_destructible_apply { + typedef int type; +}; + +template struct __is_destructor_wellformed { + template + static true_type __test( + typename __is_destructible_apply().~T1())>::type); + + template static false_type __test(...); + + static const bool value = decltype(__test(12))::value; +}; + +template struct __destructible_imp; + +template +struct __destructible_imp + : public integral_constant< + bool, __is_destructor_wellformed<__remove_all_extents_t>::value> { +}; + +template struct __destructible_imp : public true_type {}; + +template struct __destructible_false; +template +struct __destructible_false + : public __destructible_imp::value> {}; +template +struct __destructible_false : public false_type {}; + +template +struct is_destructible : public __destructible_false::value> { +}; +template struct is_destructible : public false_type {}; +template <> struct is_destructible : public false_type {}; + +#endif // LIBC_HAS_BUILTIN(__is_destructible) +} // namespace details + +#if LIBC_HAS_BUILTIN(__is_trivially_destructible) + +template +struct is_trivially_destructible + : public integral_constant {}; + +#else +template +struct is_trivially_destructible + : public integral_constant< + bool, __llvm_libc::cpp::details::is_destructible::value + &&__has_trivial_destructor(T)> {}; +#endif // LIBC_HAS_BUILTIN(__is_trivially_destructible) + +} // namespace cpp +} // namespace __llvm_libc + +#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPETRAITS_H diff --git a/libc/src/__support/CPP/type_traits/add_lvalue_reference.h b/libc/src/__support/CPP/type_traits/add_lvalue_reference.h deleted file mode 100644 index 7cb22ac03bb03..0000000000000 --- a/libc/src/__support/CPP/type_traits/add_lvalue_reference.h +++ /dev/null @@ -1,28 +0,0 @@ -//===-- add_lvalue_reference type_traits ------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H - -#include "src/__support/CPP/type_traits/type_identity.h" - -namespace __llvm_libc::cpp { - -// add_lvalue_reference -namespace detail { -template // Note that `cv void&` is a substitution failure -auto try_add_lvalue_reference(int) -> cpp::type_identity; -template // Handle T = cv void case -auto try_add_lvalue_reference(...) -> cpp::type_identity; -} // namespace detail -template -struct add_lvalue_reference : decltype(detail::try_add_lvalue_reference(0)) { -}; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H diff --git a/libc/src/__support/CPP/type_traits/add_pointer.h b/libc/src/__support/CPP/type_traits/add_pointer.h deleted file mode 100644 index 543259ea1ca8f..0000000000000 --- a/libc/src/__support/CPP/type_traits/add_pointer.h +++ /dev/null @@ -1,28 +0,0 @@ -//===-- add_pointer type_traits ---------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H - -#include "src/__support/CPP/type_traits/remove_reference.h" -#include "src/__support/CPP/type_traits/type_identity.h" -#include "src/__support/macros/config.h" - -namespace __llvm_libc::cpp { - -// add_pointer -namespace detail { -template -auto try_add_pointer(int) -> cpp::type_identity *>; -template auto try_add_pointer(...) -> cpp::type_identity; -} // namespace detail -template -struct add_pointer : decltype(detail::try_add_pointer(0)) {}; -template using add_pointer_t = typename add_pointer::type; -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H diff --git a/libc/src/__support/CPP/type_traits/add_rvalue_reference.h b/libc/src/__support/CPP/type_traits/add_rvalue_reference.h deleted file mode 100644 index b912cef59b68f..0000000000000 --- a/libc/src/__support/CPP/type_traits/add_rvalue_reference.h +++ /dev/null @@ -1,29 +0,0 @@ -//===-- add_rvalue_reference type_traits ------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H - -#include "src/__support/CPP/type_traits/type_identity.h" - -namespace __llvm_libc::cpp { - -// add_rvalue_reference -namespace detail { -template -auto try_add_rvalue_reference(int) -> cpp::type_identity; -template auto try_add_rvalue_reference(...) -> cpp::type_identity; -} // namespace detail -template -struct add_rvalue_reference : decltype(detail::try_add_rvalue_reference(0)) { -}; -template -using add_rvalue_reference_t = typename add_rvalue_reference::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H diff --git a/libc/src/__support/CPP/type_traits/bool_constant.h b/libc/src/__support/CPP/type_traits/bool_constant.h deleted file mode 100644 index 6fcfb8e82e4d8..0000000000000 --- a/libc/src/__support/CPP/type_traits/bool_constant.h +++ /dev/null @@ -1,20 +0,0 @@ -//===-- bool_constant type_traits -------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H - -#include "src/__support/CPP/type_traits/integral_constant.h" - -namespace __llvm_libc::cpp { - -// bool_constant -template using bool_constant = cpp::integral_constant; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H diff --git a/libc/src/__support/CPP/type_traits/conditional.h b/libc/src/__support/CPP/type_traits/conditional.h deleted file mode 100644 index f9917c2a7264c..0000000000000 --- a/libc/src/__support/CPP/type_traits/conditional.h +++ /dev/null @@ -1,25 +0,0 @@ -//===-- conditional type_traits ---------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H - -#include "src/__support/CPP/type_traits/type_identity.h" - -namespace __llvm_libc::cpp { - -// conditional -template -struct conditional : type_identity {}; -template -struct conditional : type_identity {}; -template -using conditional_t = typename conditional::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H diff --git a/libc/src/__support/CPP/type_traits/decay.h b/libc/src/__support/CPP/type_traits/decay.h deleted file mode 100644 index f3f9cfc5eaa00..0000000000000 --- a/libc/src/__support/CPP/type_traits/decay.h +++ /dev/null @@ -1,38 +0,0 @@ -//===-- decay type_traits ---------------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_DECAY_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_DECAY_H - -#include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" - -#include "src/__support/CPP/type_traits/add_pointer.h" -#include "src/__support/CPP/type_traits/conditional.h" -#include "src/__support/CPP/type_traits/is_array.h" -#include "src/__support/CPP/type_traits/is_function.h" -#include "src/__support/CPP/type_traits/remove_cv.h" -#include "src/__support/CPP/type_traits/remove_extent.h" -#include "src/__support/CPP/type_traits/remove_reference.h" - -namespace __llvm_libc::cpp { - -// decay -template class decay { - using U = cpp::remove_reference_t; - -public: - using type = conditional_t< - cpp::is_array_v, cpp::add_pointer_t>, - cpp::conditional_t, cpp::add_pointer_t, - cpp::remove_cv_t>>; -}; -template using decay_t = typename decay::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_DECAY_H diff --git a/libc/src/__support/CPP/type_traits/enable_if.h b/libc/src/__support/CPP/type_traits/enable_if.h deleted file mode 100644 index 51d7252fc3e48..0000000000000 --- a/libc/src/__support/CPP/type_traits/enable_if.h +++ /dev/null @@ -1,23 +0,0 @@ -//===-- enable_if type_traits -----------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H - -#include "src/__support/CPP/type_traits/type_identity.h" - -namespace __llvm_libc::cpp { - -// enable_if -template struct enable_if; -template struct enable_if : type_identity {}; -template -using enable_if_t = typename enable_if::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H diff --git a/libc/src/__support/CPP/type_traits/false_type.h b/libc/src/__support/CPP/type_traits/false_type.h deleted file mode 100644 index 8dc6fc66d2887..0000000000000 --- a/libc/src/__support/CPP/type_traits/false_type.h +++ /dev/null @@ -1,20 +0,0 @@ -//===-- false_type type_traits ----------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H - -#include "src/__support/CPP/type_traits/bool_constant.h" - -namespace __llvm_libc::cpp { - -// false_type -using false_type = cpp::bool_constant; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H diff --git a/libc/src/__support/CPP/type_traits/integral_constant.h b/libc/src/__support/CPP/type_traits/integral_constant.h deleted file mode 100644 index 21bdbccf073a6..0000000000000 --- a/libc/src/__support/CPP/type_traits/integral_constant.h +++ /dev/null @@ -1,23 +0,0 @@ -//===-- integral_constant type_traits ---------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H - -#include "src/__support/macros/attributes.h" // LIBC_INLINE_VAR - -namespace __llvm_libc::cpp { - -// integral_constant -template struct integral_constant { - using value_type = T; - LIBC_INLINE_VAR static constexpr T value = v; -}; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H diff --git a/libc/src/__support/CPP/type_traits/is_arithmetic.h b/libc/src/__support/CPP/type_traits/is_arithmetic.h deleted file mode 100644 index cc651b11b2048..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_arithmetic.h +++ /dev/null @@ -1,27 +0,0 @@ -//===-- is_arithmetic type_traits -------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H - -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/CPP/type_traits/is_floating_point.h" -#include "src/__support/CPP/type_traits/is_integral.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_arithmetic -template -struct is_arithmetic : cpp::bool_constant<(cpp::is_integral_v || - cpp::is_floating_point_v)> {}; -template -LIBC_INLINE_VAR constexpr bool is_arithmetic_v = is_arithmetic::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H diff --git a/libc/src/__support/CPP/type_traits/is_array.h b/libc/src/__support/CPP/type_traits/is_array.h deleted file mode 100644 index c04a2edb6c77e..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_array.h +++ /dev/null @@ -1,28 +0,0 @@ -//===-- is_array type_traits ------------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H - -#include "src/__support/CPP/type_traits/false_type.h" -#include "src/__support/CPP/type_traits/true_type.h" -#include "src/__support/macros/attributes.h" - -#include // For size_t - -namespace __llvm_libc::cpp { - -// is_array -template struct is_array : false_type {}; -template struct is_array : true_type {}; -template struct is_array : true_type {}; -template -LIBC_INLINE_VAR constexpr bool is_array_v = is_array::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H diff --git a/libc/src/__support/CPP/type_traits/is_base_of.h b/libc/src/__support/CPP/type_traits/is_base_of.h deleted file mode 100644 index 7820c83f7cbca..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_base_of.h +++ /dev/null @@ -1,44 +0,0 @@ -//===-- is_base_of type_traits ----------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H - -#include "src/__support/CPP/type_traits/add_rvalue_reference.h" -#include "src/__support/CPP/type_traits/false_type.h" -#include "src/__support/CPP/type_traits/is_class.h" -#include "src/__support/CPP/type_traits/remove_all_extents.h" -#include "src/__support/CPP/type_traits/true_type.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_base_of -namespace detail { -template cpp::true_type __test_ptr_conv(const volatile B *); -template cpp::false_type __test_ptr_conv(const volatile void *); - -template -auto is_base_of(int) -> decltype(__test_ptr_conv(static_cast(nullptr))); - -template -auto is_base_of(...) -> cpp::true_type; // private or ambiguous base - -} // namespace detail - -template -struct is_base_of - : cpp::bool_constant< - cpp::is_class_v && - cpp::is_class_v &&decltype(detail::is_base_of( - 0))::value> {}; -template -LIBC_INLINE_VAR constexpr bool is_base_of_v = is_base_of::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H diff --git a/libc/src/__support/CPP/type_traits/is_class.h b/libc/src/__support/CPP/type_traits/is_class.h deleted file mode 100644 index 93b3c3d5df33e..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_class.h +++ /dev/null @@ -1,29 +0,0 @@ -//===-- is_class type_traits ------------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H - -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/CPP/type_traits/false_type.h" -#include "src/__support/CPP/type_traits/is_union.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_class -namespace detail { -template cpp::bool_constant> test(int T::*); -template cpp::false_type test(...); -} // namespace detail -template struct is_class : decltype(detail::test(nullptr)) {}; -template -LIBC_INLINE_VAR constexpr bool is_class_v = is_class::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H diff --git a/libc/src/__support/CPP/type_traits/is_const.h b/libc/src/__support/CPP/type_traits/is_const.h deleted file mode 100644 index 5434e2982d95c..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_const.h +++ /dev/null @@ -1,25 +0,0 @@ -//===-- is_const type_traits ------------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H - -#include "src/__support/CPP/type_traits/false_type.h" -#include "src/__support/CPP/type_traits/true_type.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_const -template struct is_const : cpp::false_type {}; -template struct is_const : cpp::true_type {}; -template -LIBC_INLINE_VAR constexpr bool is_const_v = is_const::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H diff --git a/libc/src/__support/CPP/type_traits/is_convertible.h b/libc/src/__support/CPP/type_traits/is_convertible.h deleted file mode 100644 index a7292c3461d48..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_convertible.h +++ /dev/null @@ -1,45 +0,0 @@ -//===-- is_convertible type_traits ------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H - -#include "src/__support/CPP/type_traits/is_void.h" -#include "src/__support/CPP/utility/declval.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_convertible -namespace detail { -template -auto test_returnable(int) - -> decltype(void(static_cast(nullptr)), cpp::true_type{}); -template auto test_returnable(...) -> cpp::false_type; - -template -auto test_implicitly_convertible(int) - -> decltype(void(cpp::declval()(cpp::declval())), - cpp::true_type{}); -template -auto test_implicitly_convertible(...) -> cpp::false_type; -} // namespace detail - -template -struct is_convertible - : cpp::bool_constant< - (decltype(detail::test_returnable(0))::value && - decltype(detail::test_implicitly_convertible(0))::value) || - (cpp::is_void_v && cpp::is_void_v)> {}; - -template -LIBC_INLINE_VAR constexpr bool is_convertible_v = - is_convertible::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H diff --git a/libc/src/__support/CPP/type_traits/is_destructible.h b/libc/src/__support/CPP/type_traits/is_destructible.h deleted file mode 100644 index 38b64a90e4253..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_destructible.h +++ /dev/null @@ -1,65 +0,0 @@ -//===-- is_destructible type_traits -----------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_DESTRUCTIBLE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_DESTRUCTIBLE_H - -#include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" - -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/CPP/type_traits/false_type.h" -#include "src/__support/CPP/type_traits/is_function.h" -#include "src/__support/CPP/type_traits/is_reference.h" -#include "src/__support/CPP/type_traits/remove_all_extents.h" -#include "src/__support/CPP/type_traits/true_type.h" -#include "src/__support/CPP/type_traits/type_identity.h" - -namespace __llvm_libc::cpp { - -// is_destructible -#if LIBC_HAS_BUILTIN(__is_destructible) -template -struct is_destructible : bool_constant<__is_destructible(T)> {}; -#else -// if it's a reference, return true -// if it's a function, return false -// if it's void, return false -// if it's an array of unknown bound, return false -// Otherwise, return "declval().~T()" is well-formed -// where T is remove_all_extents::type -template struct __is_destructible_apply : cpp::type_identity {}; -template struct __is_destructor_wellformed { - template - static cpp::true_type __test( - typename __is_destructible_apply().~T1())>::type); - template static cpp::false_type __test(...); - static const bool value = decltype(__test(12))::value; -}; -template struct __destructible_imp; -template -struct __destructible_imp - : public bool_constant< - __is_destructor_wellformed>::value> {}; -template -struct __destructible_imp : public cpp::true_type {}; -template struct __destructible_false; -template -struct __destructible_false - : public __destructible_imp::value> {}; -template -struct __destructible_false : public cpp::false_type {}; -template -struct is_destructible : public __destructible_false::value> { -}; -template struct is_destructible : public false_type {}; -template <> struct is_destructible : public false_type {}; -#endif - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_DESTRUCTIBLE_H diff --git a/libc/src/__support/CPP/type_traits/is_enum.h b/libc/src/__support/CPP/type_traits/is_enum.h deleted file mode 100644 index 4914df30c3cd1..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_enum.h +++ /dev/null @@ -1,23 +0,0 @@ -//===-- is_enum type_traits -------------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H - -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_enum -template struct is_enum : bool_constant<__is_enum(T)> {}; -template -LIBC_INLINE_VAR constexpr bool is_enum_v = is_enum::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H diff --git a/libc/src/__support/CPP/type_traits/is_floating_point.h b/libc/src/__support/CPP/type_traits/is_floating_point.h deleted file mode 100644 index 746d0e36c92eb..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_floating_point.h +++ /dev/null @@ -1,35 +0,0 @@ -//===-- is_floating_point type_traits ---------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H - -#include "src/__support/CPP/type_traits/is_same.h" -#include "src/__support/CPP/type_traits/remove_cv.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_floating_point -template struct is_floating_point { -private: - template - LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() { - return (... || is_same_v, Args>); - } - -public: - LIBC_INLINE_VAR static constexpr bool value = - __is_unqualified_any_of(); -}; -template -LIBC_INLINE_VAR constexpr bool is_floating_point_v = - is_floating_point::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H diff --git a/libc/src/__support/CPP/type_traits/is_function.h b/libc/src/__support/CPP/type_traits/is_function.h deleted file mode 100644 index 3a8b3486e8f3a..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_function.h +++ /dev/null @@ -1,33 +0,0 @@ -//===-- is_function type_traits ---------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H - -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/CPP/type_traits/is_const.h" -#include "src/__support/CPP/type_traits/is_reference.h" -#include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" - -namespace __llvm_libc::cpp { - -// is_function -#if LIBC_HAS_BUILTIN(__is_function) -template -struct is_function : integral_constant {}; -#else -template -struct is_function - : public bool_constant || is_const_v)> {}; -#endif -template -LIBC_INLINE_VAR constexpr bool is_function_v = is_function::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H diff --git a/libc/src/__support/CPP/type_traits/is_integral.h b/libc/src/__support/CPP/type_traits/is_integral.h deleted file mode 100644 index 0113a5bf91139..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_integral.h +++ /dev/null @@ -1,39 +0,0 @@ -//===-- is_integral type_traits ---------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H - -#include "src/__support/CPP/type_traits/is_same.h" -#include "src/__support/CPP/type_traits/remove_cv.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_integral -template struct is_integral { -private: - template - LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() { - return (... || is_same_v, Args>); - } - -public: - LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of< - T, -#ifdef __SIZEOF_INT128__ - __int128_t, __uint128_t, -#endif - char, signed char, unsigned char, short, unsigned short, int, - unsigned int, long, unsigned long, long long, unsigned long long, bool>(); -}; -template -LIBC_INLINE_VAR constexpr bool is_integral_v = is_integral::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H diff --git a/libc/src/__support/CPP/type_traits/is_lvalue_reference.h b/libc/src/__support/CPP/type_traits/is_lvalue_reference.h deleted file mode 100644 index fe7f4f7252530..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_lvalue_reference.h +++ /dev/null @@ -1,33 +0,0 @@ -//===-- is_lvalue_reference type_traits -------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H - -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/CPP/type_traits/false_type.h" -#include "src/__support/CPP/type_traits/true_type.h" -#include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" - -namespace __llvm_libc::cpp { - -// is_lvalue_reference -#if LIBC_HAS_BUILTIN(__is_lvalue_reference) -template -struct is_lvalue_reference : bool_constant<__is_lvalue_reference(T)> {}; -#else -template struct is_lvalue_reference : public false_type {}; -template struct is_lvalue_reference : public true_type {}; -#endif -template -LIBC_INLINE_VAR constexpr bool is_lvalue_reference_v = - is_lvalue_reference::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H diff --git a/libc/src/__support/CPP/type_traits/is_null_pointer.h b/libc/src/__support/CPP/type_traits/is_null_pointer.h deleted file mode 100644 index e5c024b1b3898..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_null_pointer.h +++ /dev/null @@ -1,24 +0,0 @@ -//===-- is_null_pointer type_traits -----------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H - -#include "src/__support/CPP/type_traits/is_same.h" -#include "src/__support/CPP/type_traits/remove_cv.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_null_pointer -using nullptr_t = decltype(nullptr); -template -struct is_null_pointer : cpp::is_same> {}; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H diff --git a/libc/src/__support/CPP/type_traits/is_pointer.h b/libc/src/__support/CPP/type_traits/is_pointer.h deleted file mode 100644 index f7af8752e8d89..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_pointer.h +++ /dev/null @@ -1,28 +0,0 @@ -//===-- is_pointer type_traits ----------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H - -#include "src/__support/CPP/type_traits/false_type.h" -#include "src/__support/CPP/type_traits/true_type.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_pointer -template struct is_pointer : cpp::false_type {}; -template struct is_pointer : cpp::true_type {}; -template struct is_pointer : cpp::true_type {}; -template struct is_pointer : cpp::true_type {}; -template struct is_pointer : cpp::true_type {}; -template -LIBC_INLINE_VAR constexpr bool is_pointer_v = is_pointer::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H diff --git a/libc/src/__support/CPP/type_traits/is_reference.h b/libc/src/__support/CPP/type_traits/is_reference.h deleted file mode 100644 index 147b65ebfe7b7..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_reference.h +++ /dev/null @@ -1,29 +0,0 @@ -//===-- is_reference type_traits --------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H - -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/CPP/type_traits/false_type.h" -#include "src/__support/CPP/type_traits/true_type.h" -#include "src/__support/macros/config.h" - -namespace __llvm_libc::cpp { - -// is_reference -#if LIBC_HAS_BUILTIN(__is_reference) -template struct is_reference : bool_constant<__is_reference(T)> {}; -#else -template struct is_reference : public false_type {}; -template struct is_reference : public true_type {}; -template struct is_reference : public true_type {}; -#endif - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H diff --git a/libc/src/__support/CPP/type_traits/is_rvalue_reference.h b/libc/src/__support/CPP/type_traits/is_rvalue_reference.h deleted file mode 100644 index 33b2037df0138..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_rvalue_reference.h +++ /dev/null @@ -1,32 +0,0 @@ -//===-- is_rvalue_reference type_traits -------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H - -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/CPP/type_traits/false_type.h" -#include "src/__support/CPP/type_traits/true_type.h" -#include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" - -namespace __llvm_libc::cpp { - -// is_rvalue_reference -#if LIBC_HAS_BUILTIN(__is_rvalue_reference) -template -struct is_rvalue_reference : bool_constant<__is_rvalue_reference(T)> {}; -#else -template struct is_rvalue_reference : public false_type {}; -template struct is_rvalue_reference : public true_type {}; -#endif -template -using add_rvalue_reference_t = typename add_rvalue_reference::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H diff --git a/libc/src/__support/CPP/type_traits/is_same.h b/libc/src/__support/CPP/type_traits/is_same.h deleted file mode 100644 index f8fa7ed2f350c..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_same.h +++ /dev/null @@ -1,25 +0,0 @@ -//===-- is_same type_traits -------------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H - -#include "src/__support/CPP/type_traits/false_type.h" -#include "src/__support/CPP/type_traits/true_type.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_same -template struct is_same : cpp::false_type {}; -template struct is_same : cpp::true_type {}; -template -LIBC_INLINE_VAR constexpr bool is_same_v = is_same::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H diff --git a/libc/src/__support/CPP/type_traits/is_signed.h b/libc/src/__support/CPP/type_traits/is_signed.h deleted file mode 100644 index a4e6dbcf3d62e..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_signed.h +++ /dev/null @@ -1,28 +0,0 @@ -//===-- is_signed type_traits -----------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H - -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/CPP/type_traits/is_arithmetic.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_signed -template -struct is_signed : bool_constant<(is_arithmetic_v && (T(-1) < T(0)))> { - LIBC_INLINE constexpr operator bool() const { return is_signed::value; } - LIBC_INLINE constexpr bool operator()() const { return is_signed::value; } -}; -template -LIBC_INLINE_VAR constexpr bool is_signed_v = is_signed::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H diff --git a/libc/src/__support/CPP/type_traits/is_trivially_constructible.h b/libc/src/__support/CPP/type_traits/is_trivially_constructible.h deleted file mode 100644 index 3053e7b9ac53b..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_trivially_constructible.h +++ /dev/null @@ -1,22 +0,0 @@ -//===-- is_trivially_constructible type_traits ------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H - -#include "src/__support/CPP/type_traits/integral_constant.h" - -namespace __llvm_libc::cpp { - -// is_trivially_constructible -template -struct is_trivially_constructible - : integral_constant {}; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H diff --git a/libc/src/__support/CPP/type_traits/is_trivially_copyable.h b/libc/src/__support/CPP/type_traits/is_trivially_copyable.h deleted file mode 100644 index a1b5a0cb26c5f..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_trivially_copyable.h +++ /dev/null @@ -1,23 +0,0 @@ -//===-- is_trivially_copyable type_traits -----------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H - -#include "src/__support/CPP/type_traits/integral_constant.h" -#include "src/__support/macros/config.h" - -namespace __llvm_libc::cpp { - -// is_trivially_copyable -template -struct is_trivially_copyable - : public integral_constant {}; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H diff --git a/libc/src/__support/CPP/type_traits/is_trivially_destructible.h b/libc/src/__support/CPP/type_traits/is_trivially_destructible.h deleted file mode 100644 index 5eab5aa084604..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_trivially_destructible.h +++ /dev/null @@ -1,35 +0,0 @@ -//===-- is_trivially_destructible type_traits -------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H - -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/CPP/type_traits/is_destructible.h" -#include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" - -namespace __llvm_libc::cpp { - -// is_trivially_destructible -#if LIBC_HAS_BUILTIN(__is_trivially_destructible) -template -struct is_trivially_destructible - : public bool_constant<__is_trivially_destructible(T)> {}; -#else -template -struct is_trivially_destructible - : public bool_constant &&__has_trivial_destructor( - T)> {}; -#endif // LIBC_HAS_BUILTIN(__is_trivially_destructible) -template -LIBC_INLINE_VAR constexpr bool is_trivially_destructible_v = - is_trivially_destructible::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H diff --git a/libc/src/__support/CPP/type_traits/is_union.h b/libc/src/__support/CPP/type_traits/is_union.h deleted file mode 100644 index 354dbd160844b..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_union.h +++ /dev/null @@ -1,23 +0,0 @@ -//===-- is_union type_traits ------------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H - -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_union -template struct is_union : bool_constant<__is_union(T)> {}; -template -LIBC_INLINE_VAR constexpr bool is_union_v = is_union::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H diff --git a/libc/src/__support/CPP/type_traits/is_unsigned.h b/libc/src/__support/CPP/type_traits/is_unsigned.h deleted file mode 100644 index 6510c1304cf34..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_unsigned.h +++ /dev/null @@ -1,28 +0,0 @@ -//===-- is_unsigned type_traits ---------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H - -#include "src/__support/CPP/type_traits/bool_constant.h" -#include "src/__support/CPP/type_traits/is_arithmetic.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_unsigned -template -struct is_unsigned : bool_constant<(is_arithmetic_v && (T(-1) > T(0)))> { - LIBC_INLINE constexpr operator bool() const { return is_unsigned::value; } - LIBC_INLINE constexpr bool operator()() const { return is_unsigned::value; } -}; -template -LIBC_INLINE_VAR constexpr bool is_unsigned_v = is_unsigned::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H diff --git a/libc/src/__support/CPP/type_traits/is_void.h b/libc/src/__support/CPP/type_traits/is_void.h deleted file mode 100644 index be054f0860c26..0000000000000 --- a/libc/src/__support/CPP/type_traits/is_void.h +++ /dev/null @@ -1,24 +0,0 @@ -//===-- is_void type_traits -------------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H - -#include "src/__support/CPP/type_traits/is_same.h" -#include "src/__support/CPP/type_traits/remove_cv.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// is_void -template struct is_void : is_same> {}; -template -LIBC_INLINE_VAR constexpr bool is_void_v = is_void::value; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H diff --git a/libc/src/__support/CPP/type_traits/make_signed.h b/libc/src/__support/CPP/type_traits/make_signed.h deleted file mode 100644 index c896c45902325..0000000000000 --- a/libc/src/__support/CPP/type_traits/make_signed.h +++ /dev/null @@ -1,37 +0,0 @@ -//===-- make_signed type_traits ---------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H - -#include "src/__support/CPP/type_traits/type_identity.h" - -namespace __llvm_libc::cpp { - -// make_signed -template struct make_signed; -template <> struct make_signed : type_identity {}; -template <> struct make_signed : type_identity {}; -template <> struct make_signed : type_identity {}; -template <> struct make_signed : type_identity {}; -template <> struct make_signed : type_identity {}; -template <> struct make_signed : type_identity {}; -template <> struct make_signed : type_identity {}; -template <> struct make_signed : type_identity {}; -template <> struct make_signed : type_identity {}; -template <> struct make_signed : type_identity {}; -template <> -struct make_signed : type_identity {}; -#ifdef __SIZEOF_INT128__ -template <> struct make_signed<__int128_t> : type_identity<__int128_t> {}; -template <> struct make_signed<__uint128_t> : type_identity<__int128_t> {}; -#endif -template using make_signed_t = typename make_signed::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H diff --git a/libc/src/__support/CPP/type_traits/make_unsigned.h b/libc/src/__support/CPP/type_traits/make_unsigned.h deleted file mode 100644 index 5cd7c3cd4c863..0000000000000 --- a/libc/src/__support/CPP/type_traits/make_unsigned.h +++ /dev/null @@ -1,42 +0,0 @@ -//===-- make_unsigned type_traits -------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_MAKE_UNSIGNED_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_MAKE_UNSIGNED_H - -#include "src/__support/CPP/type_traits/type_identity.h" - -namespace __llvm_libc::cpp { - -// make_unsigned - -template struct make_unsigned; -template <> struct make_unsigned : type_identity {}; -template <> struct make_unsigned : type_identity {}; -template <> struct make_unsigned : type_identity {}; -template <> struct make_unsigned : type_identity {}; -template <> struct make_unsigned : type_identity {}; -template <> -struct make_unsigned : type_identity {}; -template <> -struct make_unsigned : type_identity {}; -template <> -struct make_unsigned : type_identity {}; -template <> struct make_unsigned : type_identity {}; -template <> -struct make_unsigned : type_identity {}; -template <> -struct make_unsigned : type_identity {}; -#ifdef __SIZEOF_INT128__ -template <> struct make_unsigned<__int128_t> : type_identity<__uint128_t> {}; -template <> struct make_unsigned<__uint128_t> : type_identity<__uint128_t> {}; -#endif -template using make_unsigned_t = typename make_unsigned::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_MAKE_UNSIGNED_H diff --git a/libc/src/__support/CPP/type_traits/remove_all_extents.h b/libc/src/__support/CPP/type_traits/remove_all_extents.h deleted file mode 100644 index 7799032ad5255..0000000000000 --- a/libc/src/__support/CPP/type_traits/remove_all_extents.h +++ /dev/null @@ -1,37 +0,0 @@ -//===-- remove_all_extents type_traits --------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H - -#include "src/__support/CPP/type_traits/type_identity.h" -#include "src/__support/macros/config.h" - -namespace __llvm_libc::cpp { - -// remove_all_extents -#if LIBC_HAS_BUILTIN(__remove_all_extents) -template using remove_all_extents_t = __remove_all_extents(T); -template -struct remove_all_extents : cpp::type_identity> {}; -#else -template struct remove_all_extents { - using type = T; -}; -template struct remove_all_extents { - using type = typename remove_all_extents::type; -}; -template struct remove_all_extents { - using type = typename remove_all_extents::type; -}; -template -using remove_all_extents_t = typename remove_all_extents::type; -#endif - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H diff --git a/libc/src/__support/CPP/type_traits/remove_cv.h b/libc/src/__support/CPP/type_traits/remove_cv.h deleted file mode 100644 index 8ce41d64de277..0000000000000 --- a/libc/src/__support/CPP/type_traits/remove_cv.h +++ /dev/null @@ -1,25 +0,0 @@ -//===-- remove_cv type_traits -----------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H - -#include "src/__support/CPP/type_traits/type_identity.h" - -namespace __llvm_libc::cpp { - -// remove_cv -template struct remove_cv : cpp::type_identity {}; -template struct remove_cv : cpp::type_identity {}; -template struct remove_cv : cpp::type_identity {}; -template -struct remove_cv : cpp::type_identity {}; -template using remove_cv_t = typename remove_cv::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H diff --git a/libc/src/__support/CPP/type_traits/remove_cvref.h b/libc/src/__support/CPP/type_traits/remove_cvref.h deleted file mode 100644 index 68eb479f548d4..0000000000000 --- a/libc/src/__support/CPP/type_traits/remove_cvref.h +++ /dev/null @@ -1,24 +0,0 @@ -//===-- remove_cvref type_traits --------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H - -#include "src/__support/CPP/type_traits/remove_cv.h" -#include "src/__support/CPP/type_traits/remove_reference.h" - -namespace __llvm_libc::cpp { - -// remove_cvref -template struct remove_cvref { - using type = remove_cv_t>; -}; -template using remove_cvref_t = typename remove_cvref::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H diff --git a/libc/src/__support/CPP/type_traits/remove_extent.h b/libc/src/__support/CPP/type_traits/remove_extent.h deleted file mode 100644 index cc92f8fd080bf..0000000000000 --- a/libc/src/__support/CPP/type_traits/remove_extent.h +++ /dev/null @@ -1,24 +0,0 @@ -//===-- remove_extent type_traits -------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H - -#include "src/__support/CPP/type_traits/type_identity.h" - -namespace __llvm_libc::cpp { - -// remove_extent -template struct remove_extent : cpp::type_identity {}; -template struct remove_extent : cpp::type_identity {}; -template -struct remove_extent : cpp::type_identity {}; -template using remove_extent_t = typename remove_extent::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H diff --git a/libc/src/__support/CPP/type_traits/remove_reference.h b/libc/src/__support/CPP/type_traits/remove_reference.h deleted file mode 100644 index b1cb176792738..0000000000000 --- a/libc/src/__support/CPP/type_traits/remove_reference.h +++ /dev/null @@ -1,24 +0,0 @@ -//===-- remove_reference type_traits ----------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H - -#include "src/__support/CPP/type_traits/type_identity.h" - -namespace __llvm_libc::cpp { - -// remove_reference -template struct remove_reference : cpp::type_identity {}; -template struct remove_reference : cpp::type_identity {}; -template struct remove_reference : cpp::type_identity {}; -template -using remove_reference_t = typename remove_reference::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H diff --git a/libc/src/__support/CPP/type_traits/true_type.h b/libc/src/__support/CPP/type_traits/true_type.h deleted file mode 100644 index 41f1fcadf1895..0000000000000 --- a/libc/src/__support/CPP/type_traits/true_type.h +++ /dev/null @@ -1,20 +0,0 @@ -//===-- true_type type_traits -----------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H - -#include "src/__support/CPP/type_traits/bool_constant.h" - -namespace __llvm_libc::cpp { - -// true_type -using true_type = cpp::bool_constant; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H diff --git a/libc/src/__support/CPP/type_traits/type_identity.h b/libc/src/__support/CPP/type_traits/type_identity.h deleted file mode 100644 index eaba0a9fbec47..0000000000000 --- a/libc/src/__support/CPP/type_traits/type_identity.h +++ /dev/null @@ -1,20 +0,0 @@ -//===-- type_identity type_traits -------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H - -namespace __llvm_libc::cpp { - -// type_identity -template struct type_identity { - using type = T; -}; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H diff --git a/libc/src/__support/CPP/type_traits/void_t.h b/libc/src/__support/CPP/type_traits/void_t.h deleted file mode 100644 index 237e7ce974415..0000000000000 --- a/libc/src/__support/CPP/type_traits/void_t.h +++ /dev/null @@ -1,26 +0,0 @@ -//===-- void_t type_traits --------------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_VOID_T_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_VOID_T_H - -#include "src/__support/CPP/type_traits/type_identity.h" - -namespace __llvm_libc::cpp { - -// void_t - -namespace detail { -template struct make_void : cpp::type_identity {}; -} // namespace detail - -template -using void_t = typename detail::make_void::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_VOID_T_H diff --git a/libc/src/__support/CPP/utility.h b/libc/src/__support/CPP/utility.h index 105d3a21dc2b0..40455d5e61f87 100644 --- a/libc/src/__support/CPP/utility.h +++ b/libc/src/__support/CPP/utility.h @@ -9,9 +9,48 @@ #ifndef LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H #define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H -#include "src/__support/CPP/utility/declval.h" -#include "src/__support/CPP/utility/forward.h" -#include "src/__support/CPP/utility/integer_sequence.h" -#include "src/__support/CPP/utility/move.h" +#include "src/__support/CPP/type_traits.h" +#include "src/__support/macros/attributes.h" + +namespace __llvm_libc::cpp { + +template struct integer_sequence { + static_assert(is_integral_v); + template using append = integer_sequence; +}; + +namespace internal { + +template struct make_integer_sequence { + using type = + typename make_integer_sequence::type::template append; +}; + +template struct make_integer_sequence { + using type = integer_sequence; +}; + +} // namespace internal + +template +using make_integer_sequence = + typename internal::make_integer_sequence::type; + +template +LIBC_INLINE constexpr T &&forward(typename remove_reference::type &value) { + return static_cast(value); +} + +template +LIBC_INLINE constexpr T &&forward(typename remove_reference::type &&value) { + return static_cast(value); +} + +template +LIBC_INLINE constexpr typename remove_reference::type &&move(T &&value) { + return static_cast::type &&>(value); +} + +} // namespace __llvm_libc::cpp #endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H diff --git a/libc/src/__support/CPP/utility/declval.h b/libc/src/__support/CPP/utility/declval.h deleted file mode 100644 index 9261ceb9332d5..0000000000000 --- a/libc/src/__support/CPP/utility/declval.h +++ /dev/null @@ -1,28 +0,0 @@ -//===-- declval utility -----------------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_DECLVAL_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_DECLVAL_H - -#include "src/__support/CPP/type_traits/add_rvalue_reference.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// declval -namespace detail { -template LIBC_INLINE_VAR constexpr bool always_false = false; -} - -template cpp::add_rvalue_reference_t declval() { - static_assert(detail::always_false, - "declval not allowed in an evaluated context"); -} - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_DECLVAL_H diff --git a/libc/src/__support/CPP/utility/forward.h b/libc/src/__support/CPP/utility/forward.h deleted file mode 100644 index a6698a589cb40..0000000000000 --- a/libc/src/__support/CPP/utility/forward.h +++ /dev/null @@ -1,32 +0,0 @@ -//===-- forward utility -----------------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_FORWARD_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_FORWARD_H - -#include "src/__support/CPP/type_traits/is_lvalue_reference.h" -#include "src/__support/CPP/type_traits/remove_reference.h" -#include "src/__support/macros/attributes.h" - -namespace __llvm_libc::cpp { - -// forward -template -LIBC_INLINE constexpr T &&forward(remove_reference_t &value) { - return static_cast(value); -} - -template -LIBC_INLINE constexpr T &&forward(remove_reference_t &&value) { - static_assert(!is_lvalue_reference_v, - "cannot forward an rvalue as an lvalue"); - return static_cast(value); -} - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_FORWARD_H diff --git a/libc/src/__support/CPP/utility/integer_sequence.h b/libc/src/__support/CPP/utility/integer_sequence.h deleted file mode 100644 index 471567f714f88..0000000000000 --- a/libc/src/__support/CPP/utility/integer_sequence.h +++ /dev/null @@ -1,37 +0,0 @@ -//===-- integer_sequence utility --------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H - -#include "src/__support/CPP/type_traits/is_integral.h" - -namespace __llvm_libc::cpp { - -// integer_sequence -template struct integer_sequence { - static_assert(cpp::is_integral_v); - template using append = integer_sequence; -}; - -namespace detail { -template struct make_integer_sequence { - using type = - typename make_integer_sequence::type::template append; -}; -template struct make_integer_sequence { - using type = integer_sequence; -}; -} // namespace detail - -template -using make_integer_sequence = - typename detail::make_integer_sequence::type; - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H diff --git a/libc/src/__support/CPP/utility/move.h b/libc/src/__support/CPP/utility/move.h deleted file mode 100644 index 3cc73c76ce9af..0000000000000 --- a/libc/src/__support/CPP/utility/move.h +++ /dev/null @@ -1,22 +0,0 @@ -//===-- move utility --------------------------------------------*- 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 LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_MOVE_H -#define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_MOVE_H - -#include "src/__support/CPP/type_traits/remove_reference.h" - -namespace __llvm_libc::cpp { - -// move -template constexpr cpp::remove_reference_t &&move(T &&t) { - return static_cast &&>(t); -} - -} // namespace __llvm_libc::cpp - -#endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_MOVE_H diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel index bdf260a783baa..32f627405ad3b 100644 --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel @@ -284,53 +284,7 @@ libc_support_library( libc_support_library( name = "__support_cpp_type_traits", - hdrs = [ - "src/__support/CPP/type_traits.h", - "src/__support/CPP/type_traits/add_lvalue_reference.h", - "src/__support/CPP/type_traits/add_pointer.h", - "src/__support/CPP/type_traits/add_rvalue_reference.h", - "src/__support/CPP/type_traits/bool_constant.h", - "src/__support/CPP/type_traits/conditional.h", - "src/__support/CPP/type_traits/decay.h", - "src/__support/CPP/type_traits/enable_if.h", - "src/__support/CPP/type_traits/false_type.h", - "src/__support/CPP/type_traits/integral_constant.h", - "src/__support/CPP/type_traits/is_arithmetic.h", - "src/__support/CPP/type_traits/is_array.h", - "src/__support/CPP/type_traits/is_base_of.h", - "src/__support/CPP/type_traits/is_class.h", - "src/__support/CPP/type_traits/is_const.h", - "src/__support/CPP/type_traits/is_convertible.h", - "src/__support/CPP/type_traits/is_destructible.h", - "src/__support/CPP/type_traits/is_enum.h", - "src/__support/CPP/type_traits/is_floating_point.h", - "src/__support/CPP/type_traits/is_function.h", - "src/__support/CPP/type_traits/is_integral.h", - "src/__support/CPP/type_traits/is_lvalue_reference.h", - "src/__support/CPP/type_traits/is_null_pointer.h", - "src/__support/CPP/type_traits/is_pointer.h", - "src/__support/CPP/type_traits/is_reference.h", - "src/__support/CPP/type_traits/is_rvalue_reference.h", - "src/__support/CPP/type_traits/is_same.h", - "src/__support/CPP/type_traits/is_signed.h", - "src/__support/CPP/type_traits/is_trivially_constructible.h", - "src/__support/CPP/type_traits/is_trivially_copyable.h", - "src/__support/CPP/type_traits/is_trivially_destructible.h", - "src/__support/CPP/type_traits/is_union.h", - "src/__support/CPP/type_traits/is_unsigned.h", - "src/__support/CPP/type_traits/is_void.h", - "src/__support/CPP/type_traits/make_signed.h", - "src/__support/CPP/type_traits/make_unsigned.h", - "src/__support/CPP/type_traits/remove_all_extents.h", - "src/__support/CPP/type_traits/remove_cv.h", - "src/__support/CPP/type_traits/remove_cvref.h", - "src/__support/CPP/type_traits/remove_extent.h", - "src/__support/CPP/type_traits/remove_reference.h", - "src/__support/CPP/type_traits/true_type.h", - "src/__support/CPP/type_traits/type_identity.h", - "src/__support/CPP/type_traits/void_t.h", - "src/__support/CPP/utility/declval.h", - ], + hdrs = ["src/__support/CPP/type_traits.h"], deps = [ ":__support_macros_attributes", ":__support_macros_config", @@ -340,13 +294,7 @@ libc_support_library( libc_support_library( name = "__support_cpp_utility", - hdrs = [ - "src/__support/CPP/utility.h", - "src/__support/CPP/utility/declval.h", - "src/__support/CPP/utility/forward.h", - "src/__support/CPP/utility/integer_sequence.h", - "src/__support/CPP/utility/move.h", - ], + hdrs = ["src/__support/CPP/utility.h"], deps = [ ":__support_cpp_type_traits", ":__support_macros_attributes",