[libcxx-commits] [libcxx] [libc++] Remove _LIBCPP_AUTO_CAST (PR #66027)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 11 16:07:41 PDT 2023
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/66027:
All supported compilers support `auto()`, so we can drop the workaround.
>From 8a97376c9470d19041b4b98ed9cc9b1c3b491284 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 | 2 +-
libcxx/include/__ranges/drop_view.h | 12 ++++++------
libcxx/include/__ranges/rbegin.h | 12 ++++++------
libcxx/include/__ranges/rend.h | 12 ++++++------
libcxx/include/__ranges/size.h | 12 ++++++------
libcxx/include/__ranges/take_view.h | 6 +++---
libcxx/include/__utility/auto_cast.h | 22 ----------------------
libcxx/include/future | 9 ++++-----
libcxx/include/module.modulemap.in | 4 ----
libcxx/include/string | 3 +--
13 files changed, 48 insertions(+), 79 deletions(-)
delete mode 100644 libcxx/include/__utility/auto_cast.h
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec142..afeeefa78089cb4 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -829,7 +829,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..6f405c92e084042 100644
--- a/libcxx/include/__ranges/data.h
+++ b/libcxx/include/__ranges/data.h
@@ -44,7 +44,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..2b9e1d02435463c 100644
--- a/libcxx/include/__ranges/drop_view.h
+++ b/libcxx/include/__ranges/drop_view.h
@@ -205,9 +205,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 +289,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..6787044c38217d0 100644
--- a/libcxx/include/__ranges/rbegin.h
+++ b/libcxx/include/__ranges/rbegin.h
@@ -40,7 +40,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 +52,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 +69,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..74546f614a45754 100644
--- a/libcxx/include/__ranges/rend.h
+++ b/libcxx/include/__ranges/rend.h
@@ -42,7 +42,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 +55,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 +73,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..a46672103e20dc8 100644
--- a/libcxx/include/__ranges/size.h
+++ b/libcxx/include/__ranges/size.h
@@ -52,7 +52,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 +61,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 +91,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..05e0daeb9975a65 100644
--- a/libcxx/include/__ranges/take_view.h
+++ b/libcxx/include/__ranges/take_view.h
@@ -249,9 +249,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 273e4175e604bd9..9c54da520e8d076 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 <__type_traits/aligned_storage.h>
#include <__type_traits/alignment_of.h>
#include <__type_traits/strip_signature.h>
-#include <__utility/auto_cast.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <mutex>
@@ -2211,16 +2210,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 3b85b6a91a21d87..2f94e670b5b5168 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -2030,10 +2030,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 4b96273698166dd..698db7e08504432 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>
@@ -1192,7 +1191,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
More information about the libcxx-commits
mailing list