Skip to content

Commit

Permalink
Workaround for unexpanded builtins in experimental/meta (llvm#64)
Browse files Browse the repository at this point in the history
* workaround for unexpanded builtins in experimental/meta

* Fix the rest of the builtin type traits

(From TransformTypeTraits.def)
  • Loading branch information
dhollman authored Jun 29, 2024
1 parent 7e30add commit 7419c20
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions libcxx/include/experimental/meta
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ enum : unsigned {
__metafn_return_type_of,
};

consteval auto __workaround_expand_compiler_builtins(info type) -> info;

} // namespace detail

namespace __range_of_infos {
Expand Down Expand Up @@ -1582,15 +1584,15 @@ consteval auto type_is_nothrow_invocable_r(info type_result, info type,
}

consteval auto type_remove_const(info type) -> info {
return dealias(substitute(^remove_const_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_const_t, {type})));
}

consteval auto type_remove_volatile(info type) -> info {
return dealias(substitute(^remove_volatile_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_volatile_t, {type})));
}

consteval auto type_remove_cv(info type) -> info {
return dealias(substitute(^remove_cv_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_cv_t, {type})));
}

consteval auto type_add_const(info type) -> info {
Expand All @@ -1606,47 +1608,47 @@ consteval auto type_add_cv(info type) -> info {
}

consteval auto type_remove_reference(info type) -> info {
return dealias(substitute(^remove_reference_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_reference_t, {type})));
}

consteval auto type_add_lvalue_reference(info type) -> info {
return dealias(substitute(^add_lvalue_reference_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^add_lvalue_reference_t, {type})));
}

consteval auto type_add_rvalue_reference(info type) -> info {
return dealias(substitute(^add_rvalue_reference_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^add_rvalue_reference_t, {type})));
}

consteval auto type_make_signed(info type) -> info {
return dealias(substitute(^make_signed_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^make_signed_t, {type})));
}

consteval auto type_make_unsigned(info type) -> info {
return dealias(substitute(^make_unsigned_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^make_unsigned_t, {type})));
}

consteval auto type_remove_extent(info type) -> info {
return dealias(substitute(^remove_extent_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_extent_t, {type})));
}

consteval auto type_remove_all_extents(info type) -> info {
return dealias(substitute(^remove_all_extents_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_all_extents_t, {type})));
}

consteval auto type_remove_pointer(info type) -> info {
return dealias(substitute(^remove_pointer_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_pointer_t, {type})));
}

consteval auto type_add_pointer(info type) -> info {
return dealias(substitute(^add_pointer_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^add_pointer_t, {type})));
}

consteval auto type_remove_cvref(info type) -> info {
return dealias(substitute(^remove_cvref_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_cvref_t, {type})));
}

consteval auto type_decay(info type) -> info {
return dealias(substitute(^decay_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^decay_t, {type})));
}

template <reflection_range R = initializer_list<info>>
Expand All @@ -1660,7 +1662,7 @@ consteval auto type_common_reference(R &&type_args) -> info {
}

consteval auto type_underlying_type(info type) -> info {
return dealias(substitute(^underlying_type_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^underlying_type_t, {type})));
}

template <reflection_range R = initializer_list<info>>
Expand Down Expand Up @@ -1743,6 +1745,13 @@ consteval auto accessible_subobjects_of(
return subobjects;
}

namespace detail {
template <class T> struct __wrap_workaround { using type = T; };
consteval auto __workaround_expand_compiler_builtins(info type) -> info {
return dealias(members_of(substitute(^__wrap_workaround, {type}))[0]);
}

} // namespace detail

#if __has_feature(parameter_reflection)

Expand Down

0 comments on commit 7419c20

Please sign in to comment.