-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc++] Granularize the <new> header #119270
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
Conversation
|
@llvm/pr-subscribers-libcxxabi @llvm/pr-subscribers-libcxx Author: Louis Dionne (ldionne) ChangesPatch is 33.34 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/119270.diff 18 Files Affected:
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 561ce4b42fb250..c9ba28ad59b673 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -581,6 +581,15 @@ set(files
__mutex/once_flag.h
__mutex/tag_types.h
__mutex/unique_lock.h
+ __new/align_val_t.h
+ __new/allocate.h
+ __new/destroying_delete_t.h
+ __new/exceptions.h
+ __new/interference_size.h
+ __new/launder.h
+ __new/new_handler.h
+ __new/nothrow_t.h
+ __new/operators.h
__node_handle
__numeric/accumulate.h
__numeric/adjacent_difference.h
diff --git a/libcxx/include/__memory/allocator.h b/libcxx/include/__memory/allocator.h
index ddb4179940b8b1..1fcaf6402667e1 100644
--- a/libcxx/include/__memory/allocator.h
+++ b/libcxx/include/__memory/allocator.h
@@ -12,6 +12,7 @@
#include <__config>
#include <__cstddef/ptrdiff_t.h>
+#include <__cstddef/size_t.h>
#include <__memory/addressof.h>
#include <__memory/allocate_at_least.h>
#include <__memory/allocator_traits.h>
diff --git a/libcxx/include/__memory/builtin_new_allocator.h b/libcxx/include/__memory/builtin_new_allocator.h
index 128288efb05bc1..b1611b12bff03e 100644
--- a/libcxx/include/__memory/builtin_new_allocator.h
+++ b/libcxx/include/__memory/builtin_new_allocator.h
@@ -10,6 +10,7 @@
#define _LIBCPP___MEMORY_BUILTIN_NEW_ALLOCATOR_H
#include <__config>
+#include <__cstddef/size_t.h>
#include <__memory/unique_ptr.h>
#include <new>
diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index 5c34f2efc5730e..4fa75af4ccc86d 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -43,6 +43,7 @@
#include <__type_traits/is_bounded_array.h>
#include <__type_traits/is_constructible.h>
#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_function.h>
#include <__type_traits/is_reference.h>
#include <__type_traits/is_same.h>
#include <__type_traits/is_unbounded_array.h>
diff --git a/libcxx/include/__memory/uninitialized_algorithms.h b/libcxx/include/__memory/uninitialized_algorithms.h
index 71c7ed94fec13e..25d192c7718857 100644
--- a/libcxx/include/__memory/uninitialized_algorithms.h
+++ b/libcxx/include/__memory/uninitialized_algorithms.h
@@ -15,6 +15,7 @@
#include <__algorithm/unwrap_iter.h>
#include <__algorithm/unwrap_range.h>
#include <__config>
+#include <__cstddef/size_t.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/reverse_iterator.h>
#include <__memory/addressof.h>
diff --git a/libcxx/include/__new/align_val_t.h b/libcxx/include/__new/align_val_t.h
new file mode 100644
index 00000000000000..ffb4e36a8bcd88
--- /dev/null
+++ b/libcxx/include/__new/align_val_t.h
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___NEW_ALIGN_VAL_T_H
+#define _LIBCPP___NEW_ALIGN_VAL_T_H
+
+#include <__config>
+#include <__cstddef/size_t.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+// purposefully not using versioning namespace
+namespace std {
+#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME)
+# ifndef _LIBCPP_CXX03_LANG
+enum class align_val_t : size_t {};
+# else
+enum align_val_t { __zero = 0, __max = (size_t)-1 };
+# endif
+#endif
+} // namespace std
+
+#endif // _LIBCPP___NEW_ALIGN_VAL_T_H
diff --git a/libcxx/include/__new/allocate.h b/libcxx/include/__new/allocate.h
new file mode 100644
index 00000000000000..7ea7662c817ad4
--- /dev/null
+++ b/libcxx/include/__new/allocate.h
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___NEW_ALLOCATE_H
+#define _LIBCPP___NEW_ALLOCATE_H
+
+#include <__config>
+#include <__cstddef/max_align_t.h>
+#include <__cstddef/size_t.h>
+#include <__new/align_val_t.h>
+#include <__new/operators.h> // for _LIBCPP_HAS_SIZED_DEALLOCATION
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(size_t __align) _NOEXCEPT {
+#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
+ return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
+#else
+ return __align > _LIBCPP_ALIGNOF(max_align_t);
+#endif
+}
+
+template <class... _Args>
+_LIBCPP_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args) {
+#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
+ return __builtin_operator_new(__args...);
+#else
+ return ::operator new(__args...);
+#endif
+}
+
+template <class... _Args>
+_LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) _NOEXCEPT {
+#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
+ __builtin_operator_delete(__args...);
+#else
+ ::operator delete(__args...);
+#endif
+}
+
+inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_allocate(size_t __size, size_t __align) {
+#if _LIBCPP_HAS_ALIGNED_ALLOCATION
+ if (__is_overaligned_for_new(__align)) {
+ const align_val_t __align_val = static_cast<align_val_t>(__align);
+ return __libcpp_operator_new(__size, __align_val);
+ }
+#endif
+
+ (void)__align;
+ return __libcpp_operator_new(__size);
+}
+
+template <class... _Args>
+_LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __size, _Args... __args) _NOEXCEPT {
+#if !_LIBCPP_HAS_SIZED_DEALLOCATION
+ (void)__size;
+ return std::__libcpp_operator_delete(__ptr, __args...);
+#else
+ return std::__libcpp_operator_delete(__ptr, __size, __args...);
+#endif
+}
+
+inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) _NOEXCEPT {
+#if !_LIBCPP_HAS_ALIGNED_ALLOCATION
+ (void)__align;
+ return __do_deallocate_handle_size(__ptr, __size);
+#else
+ if (__is_overaligned_for_new(__align)) {
+ const align_val_t __align_val = static_cast<align_val_t>(__align);
+ return __do_deallocate_handle_size(__ptr, __size, __align_val);
+ } else {
+ return __do_deallocate_handle_size(__ptr, __size);
+ }
+#endif
+}
+
+inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_t __align) _NOEXCEPT {
+#if !_LIBCPP_HAS_ALIGNED_ALLOCATION
+ (void)__align;
+ return __libcpp_operator_delete(__ptr);
+#else
+ if (__is_overaligned_for_new(__align)) {
+ const align_val_t __align_val = static_cast<align_val_t>(__align);
+ return __libcpp_operator_delete(__ptr, __align_val);
+ } else {
+ return __libcpp_operator_delete(__ptr);
+ }
+#endif
+}
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NEW_ALLOCATE_H
diff --git a/libcxx/include/__new/destroying_delete_t.h b/libcxx/include/__new/destroying_delete_t.h
new file mode 100644
index 00000000000000..7fca4f6c68b212
--- /dev/null
+++ b/libcxx/include/__new/destroying_delete_t.h
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___NEW_DESTROYING_DELETE_T_H
+#define _LIBCPP___NEW_DESTROYING_DELETE_T_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 20
+// purposefully not using versioning namespace
+namespace std {
+// Enable the declaration even if the compiler doesn't support the language
+// feature.
+struct destroying_delete_t {
+ explicit destroying_delete_t() = default;
+};
+inline constexpr destroying_delete_t destroying_delete{};
+} // namespace std
+#endif
+
+#endif // _LIBCPP___NEW_DESTROYING_DELETE_T_H
diff --git a/libcxx/include/__new/exceptions.h b/libcxx/include/__new/exceptions.h
new file mode 100644
index 00000000000000..053feecb036787
--- /dev/null
+++ b/libcxx/include/__new/exceptions.h
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___NEW_EXCEPTIONS_H
+#define _LIBCPP___NEW_EXCEPTIONS_H
+
+#include <__config>
+#include <__exception/exception.h>
+#include <__verbose_abort>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+// purposefully not using versioning namespace
+namespace std {
+#if !defined(_LIBCPP_ABI_VCRUNTIME)
+
+class _LIBCPP_EXPORTED_FROM_ABI bad_alloc : public exception {
+public:
+ bad_alloc() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI bad_alloc(const bad_alloc&) _NOEXCEPT = default;
+ _LIBCPP_HIDE_FROM_ABI bad_alloc& operator=(const bad_alloc&) _NOEXCEPT = default;
+ ~bad_alloc() _NOEXCEPT override;
+ const char* what() const _NOEXCEPT override;
+};
+
+class _LIBCPP_EXPORTED_FROM_ABI bad_array_new_length : public bad_alloc {
+public:
+ bad_array_new_length() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI bad_array_new_length(const bad_array_new_length&) _NOEXCEPT = default;
+ _LIBCPP_HIDE_FROM_ABI bad_array_new_length& operator=(const bad_array_new_length&) _NOEXCEPT = default;
+ ~bad_array_new_length() _NOEXCEPT override;
+ const char* what() const _NOEXCEPT override;
+};
+
+#elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 // !_LIBCPP_ABI_VCRUNTIME
+
+// When _HAS_EXCEPTIONS == 0, these complete definitions are needed,
+// since they would normally be provided in vcruntime_exception.h
+class bad_alloc : public exception {
+public:
+ bad_alloc() noexcept : exception("bad allocation") {}
+
+private:
+ friend class bad_array_new_length;
+
+ bad_alloc(char const* const __message) noexcept : exception(__message) {}
+};
+
+class bad_array_new_length : public bad_alloc {
+public:
+ bad_array_new_length() noexcept : bad_alloc("bad array new length") {}
+};
+
+#endif // defined(_LIBCPP_ABI_VCRUNTIME) && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0
+
+[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_bad_alloc(); // not in C++ spec
+
+[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_array_new_length() {
+#if _LIBCPP_HAS_EXCEPTIONS
+ throw bad_array_new_length();
+#else
+ _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode");
+#endif
+}
+} // namespace std
+
+#endif // _LIBCPP___NEW_EXCEPTIONS_H
diff --git a/libcxx/include/__new/interference_size.h b/libcxx/include/__new/interference_size.h
new file mode 100644
index 00000000000000..be1e4f6e983354
--- /dev/null
+++ b/libcxx/include/__new/interference_size.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___NEW_INTERFERENCE_SIZE_H
+#define _LIBCPP___NEW_INTERFERENCE_SIZE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 17
+
+# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
+
+inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE;
+inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE;
+
+# endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
+
+#endif // _LIBCPP_STD_VER >= 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NEW_INTERFERENCE_SIZE_H
diff --git a/libcxx/include/__new/launder.h b/libcxx/include/__new/launder.h
new file mode 100644
index 00000000000000..83d80015913d96
--- /dev/null
+++ b/libcxx/include/__new/launder.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___NEW_LAUNDER_H
+#define _LIBCPP___NEW_LAUNDER_H
+
+#include <__config>
+#include <__type_traits/is_function.h>
+#include <__type_traits/is_void.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+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_void<_Tp>::value, "can't launder cv-void");
+ return __builtin_launder(__p);
+}
+
+#if _LIBCPP_STD_VER >= 17
+template <class _Tp>
+[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept {
+ return std::__launder(__p);
+}
+#endif
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___NEW_LAUNDER_H
diff --git a/libcxx/include/__new/new_handler.h b/libcxx/include/__new/new_handler.h
new file mode 100644
index 00000000000000..c9afdab45afc13
--- /dev/null
+++ b/libcxx/include/__new/new_handler.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___NEW_NEW_HANDLER_H
+#define _LIBCPP___NEW_NEW_HANDLER_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if defined(_LIBCPP_ABI_VCRUNTIME)
+# include <new.h>
+#else
+// purposefully not using versioning namespace
+namespace std {
+typedef void (*new_handler)();
+_LIBCPP_EXPORTED_FROM_ABI new_handler set_new_handler(new_handler) _NOEXCEPT;
+_LIBCPP_EXPORTED_FROM_ABI new_handler get_new_handler() _NOEXCEPT;
+} // namespace std
+#endif // _LIBCPP_ABI_VCRUNTIME
+
+#endif // _LIBCPP___NEW_NEW_HANDLER_H
diff --git a/libcxx/include/__new/nothrow_t.h b/libcxx/include/__new/nothrow_t.h
new file mode 100644
index 00000000000000..09c2d03f66ccc4
--- /dev/null
+++ b/libcxx/include/__new/nothrow_t.h
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___NEW_NOTHROW_T_H
+#define _LIBCPP___NEW_NOTHROW_T_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if defined(_LIBCPP_ABI_VCRUNTIME)
+# include <new.h>
+#else
+// purposefully not using versioning namespace
+namespace std {
+struct _LIBCPP_EXPORTED_FROM_ABI nothrow_t {
+ explicit nothrow_t() = default;
+};
+extern _LIBCPP_EXPORTED_FROM_ABI const nothrow_t nothrow;
+} // namespace std
+#endif // _LIBCPP_ABI_VCRUNTIME
+
+#endif // _LIBCPP___NEW_NOTHROW_T_H
diff --git a/libcxx/include/__new/operators.h b/libcxx/include/__new/operators.h
new file mode 100644
index 00000000000000..411f956bdda156
--- /dev/null
+++ b/libcxx/include/__new/operators.h
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___NEW_OPERATORS_H
+#define _LIBCPP___NEW_OPERATORS_H
+
+#include <__config>
+#include <__cstddef/size_t.h>
+#include <__new/align_val_t.h>
+#include <__new/exceptions.h>
+#include <__new/nothrow_t.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if defined(_LIBCPP_CXX03_LANG)
+# define _THROW_BAD_ALLOC throw(std::bad_alloc)
+#else
+# define _THROW_BAD_ALLOC
+#endif
+
+#if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L
+# define _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION 1
+#else
+# define _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION 0
+#endif
+
+#if _LIBCPP_STD_VER >= 14 || _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION
+# define _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION 1
+#else
+# define _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION 0
+#endif
+
+#if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION && _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION
+# define _LIBCPP_HAS_SIZED_DEALLOCATION 1
+#else
+# define _LIBCPP_HAS_SIZED_DEALLOCATION 0
+#endif
+
+#if defined(_LIBCPP_ABI_VCRUNTIME)
+# include <new.h>
+#else
+[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
+[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT
+ _LIBCPP_NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
+# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
+# endif
+
+[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC;
+[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT
+ _LIBCPP_NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
+# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
+# endif
+
+# if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
+[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
+[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void*
+operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
+# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
+# endif
+
+[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void*
+operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
+[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void*
+operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
+# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION
+_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val...
[truncated]
|
philnik777
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's your goal with this patch?
This disentangles the code which previously had a mix of many #ifdefs, a non-versioned namespace and a versioned namespace. It also makes it clearer which parts of are implemented on Windows by including <new.h>. My original goal was to fix some modules issues I was seeing with |
f206f8f to
c90284d
Compare
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
1128bdd to
2a22a4e
Compare
|
FYI this resulted in some nice improvements in a few headers: http://libcxx.klauser.berlin/diff/62bdb85f9b293180a2cf402fc2fa7c242d01ef3f/9474e09459189fbed30f329a669f9c14979c5367. I'm sure we can improve this further by granularizing all the includes. |
That's nice -- but somehow I can't access that URL. |
This disentangles the code which previously had a mix of many #ifdefs, a
non-versioned namespace and a versioned namespace. It also makes it clearer
which parts of are implemented on Windows by including <new.h>.