-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc++][NFC] Merge add_{const, cv, volatile}.h into a single header #115610
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
|
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesThere isn't much benefit in having granular headers for only a few simple lines of code. Full diff: https://github.com/llvm/llvm-project/pull/115610.diff 10 Files Affected:
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index ae2e8bcb32aaa4..938d0bb872e0b5 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -738,12 +738,10 @@ set(files
__tuple/tuple_like_no_subrange.h
__tuple/tuple_size.h
__tuple/tuple_types.h
- __type_traits/add_const.h
- __type_traits/add_cv.h
+ __type_traits/add_cv_quals.h
__type_traits/add_lvalue_reference.h
__type_traits/add_pointer.h
__type_traits/add_rvalue_reference.h
- __type_traits/add_volatile.h
__type_traits/aligned_storage.h
__type_traits/aligned_union.h
__type_traits/alignment_of.h
diff --git a/libcxx/include/__type_traits/add_const.h b/libcxx/include/__type_traits/add_const.h
deleted file mode 100644
index 9a6f1c10299f7f..00000000000000
--- a/libcxx/include/__type_traits/add_const.h
+++ /dev/null
@@ -1,32 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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___TYPE_TRAITS_ADD_CONST_H
-#define _LIBCPP___TYPE_TRAITS_ADD_CONST_H
-
-#include <__config>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS add_const {
- typedef _LIBCPP_NODEBUG const _Tp type;
-};
-
-#if _LIBCPP_STD_VER >= 14
-template <class _Tp>
-using add_const_t = typename add_const<_Tp>::type;
-#endif
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___TYPE_TRAITS_ADD_CONST_H
diff --git a/libcxx/include/__type_traits/add_cv.h b/libcxx/include/__type_traits/add_cv_quals.h
similarity index 66%
rename from libcxx/include/__type_traits/add_cv.h
rename to libcxx/include/__type_traits/add_cv_quals.h
index 9e23e5ceb7a3bd..1d35b89f42c2d1 100644
--- a/libcxx/include/__type_traits/add_cv.h
+++ b/libcxx/include/__type_traits/add_cv_quals.h
@@ -17,6 +17,16 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS add_const {
+ typedef _LIBCPP_NODEBUG const _Tp type;
+};
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp>
+using add_const_t = typename add_const<_Tp>::type;
+#endif
+
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS add_cv {
typedef _LIBCPP_NODEBUG const volatile _Tp type;
@@ -27,6 +37,16 @@ template <class _Tp>
using add_cv_t = typename add_cv<_Tp>::type;
#endif
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS add_volatile {
+ typedef _LIBCPP_NODEBUG volatile _Tp type;
+};
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp>
+using add_volatile_t = typename add_volatile<_Tp>::type;
+#endif
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___TYPE_TRAITS_ADD_CV_H
diff --git a/libcxx/include/__type_traits/add_volatile.h b/libcxx/include/__type_traits/add_volatile.h
deleted file mode 100644
index 56b7dfaac026e7..00000000000000
--- a/libcxx/include/__type_traits/add_volatile.h
+++ /dev/null
@@ -1,32 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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___TYPE_TRAITS_ADD_VOLATILE_H
-#define _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H
-
-#include <__config>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS add_volatile {
- typedef _LIBCPP_NODEBUG volatile _Tp type;
-};
-
-#if _LIBCPP_STD_VER >= 14
-template <class _Tp>
-using add_volatile_t = typename add_volatile<_Tp>::type;
-#endif
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H
diff --git a/libcxx/include/__type_traits/is_trivially_assignable.h b/libcxx/include/__type_traits/is_trivially_assignable.h
index 201333b0fa0b33..7720c3e637506a 100644
--- a/libcxx/include/__type_traits/is_trivially_assignable.h
+++ b/libcxx/include/__type_traits/is_trivially_assignable.h
@@ -10,7 +10,6 @@
#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H
#include <__config>
-#include <__type_traits/add_const.h>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_rvalue_reference.h>
#include <__type_traits/integral_constant.h>
diff --git a/libcxx/include/__utility/as_const.h b/libcxx/include/__utility/as_const.h
index 582dd42f407915..0f54b984725c60 100644
--- a/libcxx/include/__utility/as_const.h
+++ b/libcxx/include/__utility/as_const.h
@@ -10,9 +10,6 @@
#define _LIBCPP___UTILITY_AS_CONST_H
#include <__config>
-#include <__type_traits/add_const.h>
-#include <__utility/forward.h>
-#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -22,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& as_const(_Tp& __t) noexcept {
return __t;
}
diff --git a/libcxx/include/any b/libcxx/include/any
index e32aa7f8e8a420..719dc2cf999e50 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -85,7 +85,7 @@ namespace std {
#include <__memory/allocator_destructor.h>
#include <__memory/allocator_traits.h>
#include <__memory/unique_ptr.h>
-#include <__type_traits/add_const.h>
+#include <__type_traits/add_cv_quals.h>
#include <__type_traits/add_pointer.h>
#include <__type_traits/aligned_storage.h>
#include <__type_traits/conditional.h>
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 6b0cc07fca0787..5465d603b2c4d0 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -63,12 +63,10 @@ module std_core [system] {
}
module type_traits {
- module add_const { header "__type_traits/add_const.h" }
- module add_cv { header "__type_traits/add_cv.h" }
+ module add_cv_quals { header "__type_traits/add_cv_quals.h" }
module add_lvalue_reference { header "__type_traits/add_lvalue_reference.h" }
module add_pointer { header "__type_traits/add_pointer.h" }
module add_rvalue_reference { header "__type_traits/add_rvalue_reference.h" }
- module add_volatile { header "__type_traits/add_volatile.h" }
module aligned_storage { header "__type_traits/aligned_storage.h" }
module aligned_union { header "__type_traits/aligned_union.h" }
module alignment_of { header "__type_traits/alignment_of.h" }
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index baeed35ca8508b..cc2b7511d24d3b 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -425,12 +425,10 @@ namespace std
*/
#include <__config>
-#include <__type_traits/add_const.h>
-#include <__type_traits/add_cv.h>
+#include <__type_traits/add_cv_quals.h>
#include <__type_traits/add_lvalue_reference.h>
#include <__type_traits/add_pointer.h>
#include <__type_traits/add_rvalue_reference.h>
-#include <__type_traits/add_volatile.h>
#include <__type_traits/aligned_storage.h>
#include <__type_traits/aligned_union.h>
#include <__type_traits/alignment_of.h>
diff --git a/libcxx/include/variant b/libcxx/include/variant
index 6e752556a888dd..f604527cd22569 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -226,10 +226,8 @@ namespace std {
#include <__memory/construct_at.h>
#include <__tuple/find_index.h>
#include <__tuple/sfinae_helpers.h>
-#include <__type_traits/add_const.h>
-#include <__type_traits/add_cv.h>
+#include <__type_traits/add_cv_quals.h>
#include <__type_traits/add_pointer.h>
-#include <__type_traits/add_volatile.h>
#include <__type_traits/common_type.h>
#include <__type_traits/conditional.h>
#include <__type_traits/conjunction.h>
|
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Nov 15, 2024
…lvm#115610) There isn't much benefit in having granular headers for only a few simple lines of code.
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.
There isn't much benefit in having granular headers for only a few simple lines of code.