[libcxx-commits] [libcxx] [libc++] Remove _LIBCPP_AUTO_CAST (PR #66027)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Nov 24 04:04:41 PST 2023
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/66027
>From 5439c0f6b64572b132e36fe004a56833eb9ed3c6 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Tue, 12 Sep 2023 01:06:25 +0200
Subject: [PATCH] [libc++] Remove _LIBCPP_AUTO_CAST
---
libcxx/include/CMakeLists.txt | 1 -
libcxx/include/__ranges/access.h | 25 ++++++++++++-------------
libcxx/include/__ranges/all.h | 7 +++----
libcxx/include/__ranges/data.h | 3 +--
libcxx/include/__ranges/drop_view.h | 13 ++++++-------
libcxx/include/__ranges/rbegin.h | 13 ++++++-------
libcxx/include/__ranges/rend.h | 13 ++++++-------
libcxx/include/__ranges/size.h | 13 ++++++-------
libcxx/include/__ranges/take_view.h | 7 +++----
libcxx/include/__utility/auto_cast.h | 22 ----------------------
libcxx/include/future | 9 ++++-----
libcxx/include/module.modulemap.in | 4 ----
libcxx/include/string | 3 +--
libcxx/include/utility | 1 -
14 files changed, 48 insertions(+), 86 deletions(-)
delete mode 100644 libcxx/include/__utility/auto_cast.h
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 889d7fedbf2965f..dd5b6f81dfeed75 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -837,7 +837,6 @@ set(files
__type_traits/void_t.h
__undef_macros
__utility/as_const.h
- __utility/auto_cast.h
__utility/cmp.h
__utility/convert_to_integral.h
__utility/declval.h
diff --git a/libcxx/include/__ranges/access.h b/libcxx/include/__ranges/access.h
index 502bd5e951c4a63..205ac934aadebf2 100644
--- a/libcxx/include/__ranges/access.h
+++ b/libcxx/include/__ranges/access.h
@@ -19,7 +19,6 @@
#include <__type_traits/is_reference.h>
#include <__type_traits/remove_cvref.h>
#include <__type_traits/remove_reference.h>
-#include <__utility/auto_cast.h>
#include <__utility/declval.h>
#include <cstddef>
@@ -46,7 +45,7 @@ namespace __begin {
__can_borrow<_Tp> &&
__workaround_52970<_Tp> &&
requires(_Tp&& __t) {
- { _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator;
+ { auto(__t.begin()) } -> input_or_output_iterator;
};
void begin(auto&) = delete;
@@ -58,7 +57,7 @@ namespace __begin {
__can_borrow<_Tp> &&
__class_or_enum<remove_cvref_t<_Tp>> &&
requires(_Tp && __t) {
- { _LIBCPP_AUTO_CAST(begin(__t)) } -> input_or_output_iterator;
+ { auto(begin(__t)) } -> input_or_output_iterator;
};
struct __fn {
@@ -79,17 +78,17 @@ namespace __begin {
template <class _Tp>
requires __member_begin<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.begin())))
+ noexcept(noexcept(auto(__t.begin())))
{
- return _LIBCPP_AUTO_CAST(__t.begin());
+ return auto(__t.begin());
}
template <class _Tp>
requires __unqualified_begin<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(begin(__t))))
+ noexcept(noexcept(auto(begin(__t))))
{
- return _LIBCPP_AUTO_CAST(begin(__t));
+ return auto(begin(__t));
}
void operator()(auto&&) const = delete;
@@ -118,7 +117,7 @@ namespace __end {
__workaround_52970<_Tp> &&
requires(_Tp&& __t) {
typename iterator_t<_Tp>;
- { _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp>>;
+ { auto(__t.end()) } -> sentinel_for<iterator_t<_Tp>>;
};
void end(auto&) = delete;
@@ -131,7 +130,7 @@ namespace __end {
__class_or_enum<remove_cvref_t<_Tp>> &&
requires(_Tp && __t) {
typename iterator_t<_Tp>;
- { _LIBCPP_AUTO_CAST(end(__t)) } -> sentinel_for<iterator_t<_Tp>>;
+ { auto(end(__t)) } -> sentinel_for<iterator_t<_Tp>>;
};
struct __fn {
@@ -145,17 +144,17 @@ namespace __end {
template <class _Tp>
requires __member_end<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.end())))
+ noexcept(noexcept(auto(__t.end())))
{
- return _LIBCPP_AUTO_CAST(__t.end());
+ return auto(__t.end());
}
template <class _Tp>
requires __unqualified_end<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(end(__t))))
+ noexcept(noexcept(auto(end(__t))))
{
- return _LIBCPP_AUTO_CAST(end(__t));
+ return auto(end(__t));
}
void operator()(auto&&) const = delete;
diff --git a/libcxx/include/__ranges/all.h b/libcxx/include/__ranges/all.h
index 2c88f51b664474f..867b8c3a6af9fb5 100644
--- a/libcxx/include/__ranges/all.h
+++ b/libcxx/include/__ranges/all.h
@@ -21,7 +21,6 @@
#include <__ranges/range_adaptor.h>
#include <__ranges/ref_view.h>
#include <__type_traits/decay.h>
-#include <__utility/auto_cast.h>
#include <__utility/declval.h>
#include <__utility/forward.h>
@@ -41,10 +40,10 @@ namespace __all {
requires ranges::view<decay_t<_Tp>>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))))
- -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)))
+ noexcept(noexcept(auto(std::forward<_Tp>(__t))))
+ -> decltype(auto(std::forward<_Tp>(__t)))
{
- return _LIBCPP_AUTO_CAST(std::forward<_Tp>(__t));
+ return auto(std::forward<_Tp>(__t));
}
template<class _Tp>
diff --git a/libcxx/include/__ranges/data.h b/libcxx/include/__ranges/data.h
index 6c099085af3438b..d37c040e76ea980 100644
--- a/libcxx/include/__ranges/data.h
+++ b/libcxx/include/__ranges/data.h
@@ -22,7 +22,6 @@
#include <__type_traits/is_reference.h>
#include <__type_traits/remove_pointer.h>
#include <__type_traits/remove_reference.h>
-#include <__utility/auto_cast.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -44,7 +43,7 @@ namespace __data {
__can_borrow<_Tp> &&
__workaround_52970<_Tp> &&
requires(_Tp&& __t) {
- { _LIBCPP_AUTO_CAST(__t.data()) } -> __ptr_to_object;
+ { auto(__t.data()) } -> __ptr_to_object;
};
template <class _Tp>
diff --git a/libcxx/include/__ranges/drop_view.h b/libcxx/include/__ranges/drop_view.h
index f10476f0011e739..a220fc1bbdf13c5 100644
--- a/libcxx/include/__ranges/drop_view.h
+++ b/libcxx/include/__ranges/drop_view.h
@@ -39,7 +39,6 @@
#include <__type_traits/is_nothrow_constructible.h>
#include <__type_traits/make_unsigned.h>
#include <__type_traits/remove_cvref.h>
-#include <__utility/auto_cast.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <cstddef>
@@ -205,9 +204,9 @@ struct __fn {
requires __is_empty_view<remove_cvref_t<_Range>>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Range&& __range, _Np&&) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
- -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))
- { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); }
+ noexcept(noexcept(auto(std::forward<_Range>(__range))))
+ -> decltype( auto(std::forward<_Range>(__range)))
+ { return auto(std::forward<_Range>(__range)); }
// [range.drop.overview]: the `span | basic_string_view | iota_view | subrange (StoreSize == false)` case.
template <class _Range,
@@ -289,9 +288,9 @@ struct __fn {
requires (__is_repeat_specialization<_RawRange> && !sized_range<_RawRange>)
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Range&& __range, _Np&&) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
- -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))
- { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); }
+ noexcept(noexcept(auto(std::forward<_Range>(__range))))
+ -> decltype( auto(std::forward<_Range>(__range)))
+ { return auto(std::forward<_Range>(__range)); }
#endif
// clang-format on
diff --git a/libcxx/include/__ranges/rbegin.h b/libcxx/include/__ranges/rbegin.h
index 1ceb1116d695fce..71eb5000a86181b 100644
--- a/libcxx/include/__ranges/rbegin.h
+++ b/libcxx/include/__ranges/rbegin.h
@@ -21,7 +21,6 @@
#include <__type_traits/is_reference.h>
#include <__type_traits/remove_cvref.h>
#include <__type_traits/remove_reference.h>
-#include <__utility/auto_cast.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -40,7 +39,7 @@ concept __member_rbegin =
__can_borrow<_Tp> &&
__workaround_52970<_Tp> &&
requires(_Tp&& __t) {
- { _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator;
+ { auto(__t.rbegin()) } -> input_or_output_iterator;
};
void rbegin(auto&) = delete;
@@ -52,7 +51,7 @@ concept __unqualified_rbegin =
__can_borrow<_Tp> &&
__class_or_enum<remove_cvref_t<_Tp>> &&
requires(_Tp&& __t) {
- { _LIBCPP_AUTO_CAST(rbegin(__t)) } -> input_or_output_iterator;
+ { auto(rbegin(__t)) } -> input_or_output_iterator;
};
template <class _Tp>
@@ -69,17 +68,17 @@ struct __fn {
template <class _Tp>
requires __member_rbegin<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rbegin())))
+ noexcept(noexcept(auto(__t.rbegin())))
{
- return _LIBCPP_AUTO_CAST(__t.rbegin());
+ return auto(__t.rbegin());
}
template <class _Tp>
requires __unqualified_rbegin<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(rbegin(__t))))
+ noexcept(noexcept(auto(rbegin(__t))))
{
- return _LIBCPP_AUTO_CAST(rbegin(__t));
+ return auto(rbegin(__t));
}
template <class _Tp>
diff --git a/libcxx/include/__ranges/rend.h b/libcxx/include/__ranges/rend.h
index 7ee574ccfa6745f..f501021fcf580a6 100644
--- a/libcxx/include/__ranges/rend.h
+++ b/libcxx/include/__ranges/rend.h
@@ -22,7 +22,6 @@
#include <__type_traits/is_reference.h>
#include <__type_traits/remove_cvref.h>
#include <__type_traits/remove_reference.h>
-#include <__utility/auto_cast.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -42,7 +41,7 @@ concept __member_rend =
__workaround_52970<_Tp> &&
requires(_Tp&& __t) {
ranges::rbegin(__t);
- { _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
+ { auto(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
};
void rend(auto&) = delete;
@@ -55,7 +54,7 @@ concept __unqualified_rend =
__class_or_enum<remove_cvref_t<_Tp>> &&
requires(_Tp&& __t) {
ranges::rbegin(__t);
- { _LIBCPP_AUTO_CAST(rend(__t)) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
+ { auto(rend(__t)) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
};
template <class _Tp>
@@ -73,17 +72,17 @@ class __fn {
template <class _Tp>
requires __member_rend<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rend())))
+ noexcept(noexcept(auto(__t.rend())))
{
- return _LIBCPP_AUTO_CAST(__t.rend());
+ return auto(__t.rend());
}
template <class _Tp>
requires __unqualified_rend<_Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(rend(__t))))
+ noexcept(noexcept(auto(rend(__t))))
{
- return _LIBCPP_AUTO_CAST(rend(__t));
+ return auto(rend(__t));
}
template <class _Tp>
diff --git a/libcxx/include/__ranges/size.h b/libcxx/include/__ranges/size.h
index f22dd1ff7b79f3b..0a84e1cf8f1d45a 100644
--- a/libcxx/include/__ranges/size.h
+++ b/libcxx/include/__ranges/size.h
@@ -20,7 +20,6 @@
#include <__type_traits/make_signed.h>
#include <__type_traits/make_unsigned.h>
#include <__type_traits/remove_cvref.h>
-#include <__utility/auto_cast.h>
#include <__utility/declval.h>
#include <cstddef>
@@ -52,7 +51,7 @@ concept __member_size =
__size_enabled<_Tp> &&
__workaround_52970<_Tp> &&
requires(_Tp&& __t) {
- { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like;
+ { auto(__t.size()) } -> __integer_like;
};
template <class _Tp>
@@ -61,7 +60,7 @@ concept __unqualified_size =
!__member_size<_Tp> &&
__class_or_enum<remove_cvref_t<_Tp>> &&
requires(_Tp&& __t) {
- { _LIBCPP_AUTO_CAST(size(__t)) } -> __integer_like;
+ { auto(size(__t)) } -> __integer_like;
};
template <class _Tp>
@@ -91,15 +90,15 @@ struct __fn {
// `[range.prim.size]`: `auto(t.size())` is a valid expression.
template <__member_size _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.size()))) {
- return _LIBCPP_AUTO_CAST(__t.size());
+ noexcept(noexcept(auto(__t.size()))) {
+ return auto(__t.size());
}
// `[range.prim.size]`: `auto(size(t))` is a valid expression.
template <__unqualified_size _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(size(__t)))) {
- return _LIBCPP_AUTO_CAST(size(__t));
+ noexcept(noexcept(auto(size(__t)))) {
+ return auto(size(__t));
}
// [range.prim.size]: the `to-unsigned-like` case.
diff --git a/libcxx/include/__ranges/take_view.h b/libcxx/include/__ranges/take_view.h
index 4204017d9249bcf..3f51bc6225ccfa8 100644
--- a/libcxx/include/__ranges/take_view.h
+++ b/libcxx/include/__ranges/take_view.h
@@ -39,7 +39,6 @@
#include <__type_traits/is_nothrow_constructible.h>
#include <__type_traits/maybe_const.h>
#include <__type_traits/remove_cvref.h>
-#include <__utility/auto_cast.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <cstddef>
@@ -249,9 +248,9 @@ struct __fn {
requires __is_empty_view<remove_cvref_t<_Range>>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
constexpr auto operator()(_Range&& __range, _Np&&) const
- noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
- -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))
- { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); }
+ noexcept(noexcept(auto(std::forward<_Range>(__range))))
+ -> decltype( auto(std::forward<_Range>(__range)))
+ { return auto(std::forward<_Range>(__range)); }
// [range.take.overview]: the `span | basic_string_view | subrange` case.
template <class _Range,
diff --git a/libcxx/include/__utility/auto_cast.h b/libcxx/include/__utility/auto_cast.h
deleted file mode 100644
index 06715b3438f996a..000000000000000
--- a/libcxx/include/__utility/auto_cast.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// -*- 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___UTILITY_AUTO_CAST_H
-#define _LIBCPP___UTILITY_AUTO_CAST_H
-
-#include <__config>
-#include <__type_traits/decay.h>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
-
-#define _LIBCPP_AUTO_CAST(expr) static_cast<::std::__decay_t<decltype((expr))> >(expr)
-
-#endif // _LIBCPP___UTILITY_AUTO_CAST_H
diff --git a/libcxx/include/future b/libcxx/include/future
index 053cecaba7eb147..2636d6dcd0fe46c 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -383,7 +383,6 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
#include <__system_error/error_condition.h>
#include <__type_traits/aligned_storage.h>
#include <__type_traits/strip_signature.h>
-#include <__utility/auto_cast.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <mutex>
@@ -2198,16 +2197,16 @@ async(launch __policy, _Fp&& __f, _Args&&... __args)
{
#endif
if (__does_policy_contain(__policy, launch::async))
- return _VSTD::__make_async_assoc_state<_Rp>(_BF(_LIBCPP_AUTO_CAST(_VSTD::forward<_Fp>(__f)),
- _LIBCPP_AUTO_CAST(_VSTD::forward<_Args>(__args))...));
+ return _VSTD::__make_async_assoc_state<_Rp>(_BF(auto(_VSTD::forward<_Fp>(__f)),
+ auto(_VSTD::forward<_Args>(__args))...));
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch ( ... ) { if (__policy == launch::async) throw ; }
#endif
if (__does_policy_contain(__policy, launch::deferred))
- return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(_LIBCPP_AUTO_CAST(_VSTD::forward<_Fp>(__f)),
- _LIBCPP_AUTO_CAST(_VSTD::forward<_Args>(__args))...));
+ return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(auto(_VSTD::forward<_Fp>(__f)),
+ auto(_VSTD::forward<_Args>(__args))...));
return future<_Rp>{};
}
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 17ebe48f329963d..6296f8172e1410c 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -2041,10 +2041,6 @@ module std_private_type_traits_unwrap_ref [system
module std_private_type_traits_void_t [system] { header "__type_traits/void_t.h" }
module std_private_utility_as_const [system] { header "__utility/as_const.h" }
-module std_private_utility_auto_cast [system] {
- header "__utility/auto_cast.h"
- export std_private_type_traits_decay
-}
module std_private_utility_cmp [system] {
header "__utility/cmp.h"
export std_private_type_traits_make_unsigned
diff --git a/libcxx/include/string b/libcxx/include/string
index 9c2efac8006bd72..c00ea984cff6818 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -606,7 +606,6 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
#include <__type_traits/noexcept_move_assign_container.h>
#include <__type_traits/remove_cvref.h>
#include <__type_traits/void_t.h>
-#include <__utility/auto_cast.h>
#include <__utility/declval.h>
#include <__utility/forward.h>
#include <__utility/is_pointer_in_range.h>
@@ -1181,7 +1180,7 @@ public:
_LIBCPP_HIDE_FROM_ABI constexpr
void resize_and_overwrite(size_type __n, _Op __op) {
__resize_default_init(__n);
- __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n)));
+ __erase_to_end(std::move(__op)(data(), auto(__n)));
}
#endif
diff --git a/libcxx/include/utility b/libcxx/include/utility
index c5581d55e79bbb3..7e3e96f679e00eb 100644
--- a/libcxx/include/utility
+++ b/libcxx/include/utility
@@ -249,7 +249,6 @@ template <class T>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__utility/as_const.h>
-#include <__utility/auto_cast.h>
#include <__utility/cmp.h>
#include <__utility/declval.h>
#include <__utility/exception_guard.h>
More information about the libcxx-commits
mailing list