-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc++][NFC] Use more appropriate type traits for a few cases #114025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7969946
to
e6c955a
Compare
e6c955a
to
128a5e0
Compare
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesFull diff: https://github.com/llvm/llvm-project/pull/114025.diff 8 Files Affected:
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 8e4cb3c914dc43..a0c72f4c205413 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -36,6 +36,7 @@
#include <__type_traits/is_nothrow_constructible.h>
#include <__type_traits/is_pointer.h>
#include <__type_traits/is_reference.h>
+#include <__type_traits/is_same.h>
#include <__type_traits/is_swappable.h>
#include <__type_traits/remove_const.h>
#include <__type_traits/remove_cvref.h>
diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index 0722b3f3e6d543..31650a50ff637f 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -42,9 +42,11 @@
#include <__type_traits/is_constructible.h>
#include <__type_traits/is_convertible.h>
#include <__type_traits/is_reference.h>
+#include <__type_traits/is_same.h>
#include <__type_traits/is_unbounded_array.h>
#include <__type_traits/nat.h>
#include <__type_traits/negation.h>
+#include <__type_traits/remove_cv.h>
#include <__type_traits/remove_extent.h>
#include <__type_traits/remove_reference.h>
#include <__utility/declval.h>
diff --git a/libcxx/include/__memory/uninitialized_algorithms.h b/libcxx/include/__memory/uninitialized_algorithms.h
index 38517a2292d3a0..627ee44e808d9c 100644
--- a/libcxx/include/__memory/uninitialized_algorithms.h
+++ b/libcxx/include/__memory/uninitialized_algorithms.h
@@ -25,6 +25,7 @@
#include <__type_traits/extent.h>
#include <__type_traits/is_array.h>
#include <__type_traits/is_constant_evaluated.h>
+#include <__type_traits/is_same.h>
#include <__type_traits/is_trivially_assignable.h>
#include <__type_traits/is_trivially_constructible.h>
#include <__type_traits/is_trivially_relocatable.h>
diff --git a/libcxx/include/__tuple/make_tuple_types.h b/libcxx/include/__tuple/make_tuple_types.h
index 53e98c3d6e9757..024e9c524b527a 100644
--- a/libcxx/include/__tuple/make_tuple_types.h
+++ b/libcxx/include/__tuple/make_tuple_types.h
@@ -18,7 +18,7 @@
#include <__tuple/tuple_size.h>
#include <__tuple/tuple_types.h>
#include <__type_traits/copy_cvref.h>
-#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_cvref.h>
#include <__type_traits/remove_reference.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -58,7 +58,7 @@ template <class _Tp,
bool _SameSize = (_Ep == tuple_size<__libcpp_remove_reference_t<_Tp> >::value)>
struct __make_tuple_types {
static_assert(_Sp <= _Ep, "__make_tuple_types input error");
- using _RawTp = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >;
+ using _RawTp = __remove_cvref_t<_Tp>;
using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
using type = typename _Maker::template __apply_quals<_Tp>;
};
diff --git a/libcxx/include/new b/libcxx/include/new
index 290ad9e97f8ded..5318ce533ea929 100644
--- a/libcxx/include/new
+++ b/libcxx/include/new
@@ -90,8 +90,7 @@ void operator delete[](void* ptr, void*) noexcept;
#include <__cstddef/size_t.h>
#include <__exception/exception.h>
#include <__type_traits/is_function.h>
-#include <__type_traits/is_same.h>
-#include <__type_traits/remove_cv.h>
+#include <__type_traits/is_void.h>
#include <__verbose_abort>
#include <version>
@@ -342,7 +341,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_
template <class _Tp>
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT {
static_assert(!(is_function<_Tp>::value), "can't launder functions");
- static_assert(!(is_same<void, __remove_cv_t<_Tp> >::value), "can't launder cv-void");
+ static_assert(!is_void<_Tp>::value, "can't launder cv-void");
return __builtin_launder(__p);
}
diff --git a/libcxx/include/optional b/libcxx/include/optional
index b9dcf9053633f0..7ad6a9e116941f 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -207,6 +207,7 @@ namespace std {
#include <__type_traits/is_nothrow_constructible.h>
#include <__type_traits/is_object.h>
#include <__type_traits/is_reference.h>
+#include <__type_traits/is_same.h>
#include <__type_traits/is_scalar.h>
#include <__type_traits/is_swappable.h>
#include <__type_traits/is_trivially_assignable.h>
@@ -215,6 +216,7 @@ namespace std {
#include <__type_traits/is_trivially_relocatable.h>
#include <__type_traits/negation.h>
#include <__type_traits/remove_const.h>
+#include <__type_traits/remove_cv.h>
#include <__type_traits/remove_cvref.h>
#include <__type_traits/remove_reference.h>
#include <__utility/declval.h>
diff --git a/libcxx/include/variant b/libcxx/include/variant
index ee80fb0b5ab5be..6e752556a888dd 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -245,6 +245,7 @@ namespace std {
#include <__type_traits/is_nothrow_assignable.h>
#include <__type_traits/is_nothrow_constructible.h>
#include <__type_traits/is_reference.h>
+#include <__type_traits/is_same.h>
#include <__type_traits/is_swappable.h>
#include <__type_traits/is_trivially_assignable.h>
#include <__type_traits/is_trivially_constructible.h>
diff --git a/libcxx/test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp b/libcxx/test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
index 40aba0a84a0805..404cdbcb7c49dd 100644
--- a/libcxx/test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
+++ b/libcxx/test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
@@ -12,10 +12,9 @@
// UNSUPPORTED: c++03, c++11, c++14
-#include <new>
#include <cassert>
-
-#include "test_macros.h"
+#include <new>
+#include <type_traits>
constexpr int gi = 5;
constexpr float gf = 8.f;
|
PhilippRados
pushed a commit
to PhilippRados/llvm-project
that referenced
this pull request
Nov 6, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.