[libcxx-commits] [libcxx] [libc++] Remove <stddef.h> includes from the granularized <cstddef> headers (PR #114788)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 4 07:30:35 PST 2024
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/114788
>From 3b7dcf6e9b291c587c559409e132ec2edff8f5ce Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Mon, 4 Nov 2024 14:02:45 +0100
Subject: [PATCH] [libc++] Remove <stddef.h> includes from the granularized
<cstddef> headers
---
libcxx/include/__cstddef/nullptr_t.h | 3 +--
libcxx/include/__cstddef/ptrdiff_t.h | 3 +--
libcxx/include/__cstddef/size_t.h | 3 +--
libcxx/include/__exception/exception_ptr.h | 1 +
libcxx/include/__functional/function.h | 1 +
libcxx/include/__memory/shared_ptr.h | 1 +
libcxx/include/forward_list | 1 +
libcxx/include/new | 1 +
libcxx/include/string_view | 1 +
.../util.smartptr.shared.cmp/cmp_nullptr.pass.cpp | 3 ++-
.../unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp | 4 ++--
11 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/libcxx/include/__cstddef/nullptr_t.h b/libcxx/include/__cstddef/nullptr_t.h
index de3f7d4ab5fa75..7eaae017539652 100644
--- a/libcxx/include/__cstddef/nullptr_t.h
+++ b/libcxx/include/__cstddef/nullptr_t.h
@@ -10,7 +10,6 @@
#define _LIBCPP___CSTDDEF_NULLPTR_T_H
#include <__config>
-#include <stddef.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -18,7 +17,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::nullptr_t;
+using nullptr_t = decltype(nullptr);
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__cstddef/ptrdiff_t.h b/libcxx/include/__cstddef/ptrdiff_t.h
index f8b5cdaaff01c9..c53e999d73b019 100644
--- a/libcxx/include/__cstddef/ptrdiff_t.h
+++ b/libcxx/include/__cstddef/ptrdiff_t.h
@@ -10,7 +10,6 @@
#define _LIBCPP___CSTDDEF_PTRDIFF_T_H
#include <__config>
-#include <stddef.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -18,7 +17,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
+using ptrdiff_t = __PTRDIFF_TYPE__;
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__cstddef/size_t.h b/libcxx/include/__cstddef/size_t.h
index 91abbf01318953..9a6d921d0d1f2f 100644
--- a/libcxx/include/__cstddef/size_t.h
+++ b/libcxx/include/__cstddef/size_t.h
@@ -10,7 +10,6 @@
#define _LIBCPP___CSTDDEF_SIZE_T_H
#include <__config>
-#include <stddef.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -18,7 +17,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::size_t _LIBCPP_USING_IF_EXISTS;
+using size_t = __SIZE_TYPE__;
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 32c56fc5cc1263..c43c005603dd7a 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -10,6 +10,7 @@
#define _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
#include <__config>
+#include <__cstddef/nullptr_t.h>
#include <__exception/operations.h>
#include <__memory/addressof.h>
#include <__memory/construct_at.h>
diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h
index e3844f86dbd3f5..543be05f10f330 100644
--- a/libcxx/include/__functional/function.h
+++ b/libcxx/include/__functional/function.h
@@ -12,6 +12,7 @@
#include <__assert>
#include <__config>
+#include <__cstddef/nullptr_t.h>
#include <__exception/exception.h>
#include <__functional/binary_function.h>
#include <__functional/invoke.h>
diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index 0722b3f3e6d543..f50dc272f64ae1 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -13,6 +13,7 @@
#include <__compare/compare_three_way.h>
#include <__compare/ordering.h>
#include <__config>
+#include <__cstddef/nullptr_t.h>
#include <__cstddef/ptrdiff_t.h>
#include <__exception/exception.h>
#include <__functional/binary_function.h>
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index 04466d9a673fc6..a511fef31bc5d1 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -200,6 +200,7 @@ template <class T, class Allocator, class Predicate>
#include <__algorithm/lexicographical_compare_three_way.h>
#include <__algorithm/min.h>
#include <__config>
+#include <__cstddef/nullptr_t.h>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/move_iterator.h>
diff --git a/libcxx/include/new b/libcxx/include/new
index 290ad9e97f8ded..dc5aabe6a97ef3 100644
--- a/libcxx/include/new
+++ b/libcxx/include/new
@@ -87,6 +87,7 @@ void operator delete[](void* ptr, void*) noexcept;
*/
#include <__config>
+#include <__cstddef/max_align_t.h>
#include <__cstddef/size_t.h>
#include <__exception/exception.h>
#include <__type_traits/is_function.h>
diff --git a/libcxx/include/string_view b/libcxx/include/string_view
index 0edda7aeb1a77c..db1f42523a13a3 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -208,6 +208,7 @@ namespace std {
#include <__algorithm/min.h>
#include <__assert>
#include <__config>
+#include <__cstddef/nullptr_t.h>
#include <__cstddef/ptrdiff_t.h>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp
index 4ca83ddff78e5b..e0aea76561e3a2 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp
@@ -37,8 +37,9 @@
// template<class T>
// strong_ordering operator<=>(shared_ptr<T> const& x, nullptr_t) noexcept; // C++20
-#include <memory>
#include <cassert>
+#include <cstddef>
+#include <memory>
#include "test_macros.h"
#include "test_comparisons.h"
diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp
index 6f0ba2e756196c..5ef9c4b044c681 100644
--- a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp
+++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp
@@ -39,9 +39,9 @@
// constexpr compare_three_way_result_t<typename unique_ptr<T, D>::pointer>
// operator<=>(const unique_ptr<T, D>& x, nullptr_t); // C++20
-#include <memory>
#include <cassert>
-#include <type_traits>
+#include <cstddef>
+#include <memory>
#include "test_macros.h"
#include "test_comparisons.h"
More information about the libcxx-commits
mailing list