File indexing completed on 2026-05-10 08:44:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_SUPPORT_TYPE_TRAITS_H
0014 #define LLVM_SUPPORT_TYPE_TRAITS_H
0015
0016 #include "llvm/Support/Compiler.h"
0017 #include <type_traits>
0018 #include <utility>
0019
0020 namespace llvm {
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 template <typename T> class is_integral_or_enum {
0031 using UnderlyingT = std::remove_reference_t<T>;
0032
0033 public:
0034 static const bool value =
0035 !std::is_class_v<UnderlyingT> &&
0036 !std::is_pointer_v<UnderlyingT> &&
0037 !std::is_floating_point_v<UnderlyingT> &&
0038 (std::is_enum_v<UnderlyingT> ||
0039 std::is_convertible_v<UnderlyingT, unsigned long long>);
0040 };
0041
0042
0043 template<typename T, typename Enable = void>
0044 struct add_lvalue_reference_if_not_pointer { using type = T &; };
0045
0046 template <typename T>
0047 struct add_lvalue_reference_if_not_pointer<
0048 T, std::enable_if_t<std::is_pointer_v<T>>> {
0049 using type = T;
0050 };
0051
0052
0053
0054 template<typename T, typename Enable = void>
0055 struct add_const_past_pointer { using type = const T; };
0056
0057 template <typename T>
0058 struct add_const_past_pointer<T, std::enable_if_t<std::is_pointer_v<T>>> {
0059 using type = const std::remove_pointer_t<T> *;
0060 };
0061
0062 template <typename T, typename Enable = void>
0063 struct const_pointer_or_const_ref {
0064 using type = const T &;
0065 };
0066 template <typename T>
0067 struct const_pointer_or_const_ref<T, std::enable_if_t<std::is_pointer_v<T>>> {
0068 using type = typename add_const_past_pointer<T>::type;
0069 };
0070
0071 namespace detail {
0072 template<class T>
0073 union trivial_helper {
0074 T t;
0075 };
0076
0077 }
0078
0079 template <typename T>
0080 struct is_copy_assignable {
0081 template<class F>
0082 static auto get(F*) -> decltype(std::declval<F &>() = std::declval<const F &>(), std::true_type{});
0083 static std::false_type get(...);
0084 static constexpr bool value = decltype(get((T*)nullptr))::value;
0085 };
0086
0087 template <typename T>
0088 struct is_move_assignable {
0089 template<class F>
0090 static auto get(F*) -> decltype(std::declval<F &>() = std::declval<F &&>(), std::true_type{});
0091 static std::false_type get(...);
0092 static constexpr bool value = decltype(get((T*)nullptr))::value;
0093 };
0094
0095 }
0096
0097 #endif