@@ -31,37 +31,16 @@ _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(siz
31
31
#endif
32
32
}
33
33
34
- template <class ... _Args>
35
- _LIBCPP_HIDE_FROM_ABI void * __libcpp_operator_new (_Args... __args) {
36
- #if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
37
- return __builtin_operator_new (__args...);
38
- #else
39
- return ::operator new (__args...);
40
- #endif
41
- }
42
-
43
- template <class ... _Args>
44
- _LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete (_Args... __args) _NOEXCEPT {
45
- #if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
46
- __builtin_operator_delete (__args...);
47
- #else
48
- ::operator delete (__args...);
49
- #endif
50
- }
51
-
52
34
template <class _Tp >
53
35
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp*
54
- __libcpp_allocate (__element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) {
36
+ __libcpp_allocate (__element_count __n, [[__maybe_unused__]] size_t __align = _LIBCPP_ALIGNOF(_Tp)) {
55
37
size_t __size = static_cast <size_t >(__n) * sizeof (_Tp);
56
38
#if _LIBCPP_HAS_ALIGNED_ALLOCATION
57
- if (__is_overaligned_for_new (__align)) {
58
- const align_val_t __align_val = static_cast <align_val_t >(__align);
59
- return static_cast <_Tp*>(std::__libcpp_operator_new (__size, __align_val));
60
- }
39
+ if (__is_overaligned_for_new (__align))
40
+ return static_cast <_Tp*>(__builtin_operator_new (__size, static_cast <align_val_t >(__align)));
61
41
#endif
62
42
63
- (void )__align;
64
- return static_cast <_Tp*>(std::__libcpp_operator_new (__size));
43
+ return static_cast <_Tp*>(__builtin_operator_new (__size));
65
44
}
66
45
67
46
#if _LIBCPP_HAS_SIZED_DEALLOCATION
@@ -71,39 +50,29 @@ __libcpp_allocate(__element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) {
71
50
#endif
72
51
73
52
template <class _Tp >
74
- inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate (
75
- __type_identity_t <_Tp>* __ptr, __element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {
76
- size_t __size = static_cast <size_t >(__n) * sizeof (_Tp);
77
- (void )__size;
78
- #if !_LIBCPP_HAS_ALIGNED_ALLOCATION
79
- (void )__align;
80
- return std::__libcpp_operator_delete (__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION (, __size));
81
- #else
82
- if (__is_overaligned_for_new (__align)) {
83
- const align_val_t __align_val = static_cast <align_val_t >(__align);
84
- return std::__libcpp_operator_delete (__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION (, __size), __align_val);
85
- } else {
86
- return std::__libcpp_operator_delete (__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION (, __size));
87
- }
53
+ inline _LIBCPP_HIDE_FROM_ABI void
54
+ __libcpp_deallocate (__type_identity_t <_Tp>* __ptr,
55
+ __element_count __n,
56
+ [[__maybe_unused__]] size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {
57
+ [[__maybe_unused__]] size_t __size = static_cast <size_t >(__n) * sizeof (_Tp);
58
+ #if _LIBCPP_HAS_ALIGNED_ALLOCATION
59
+ if (__is_overaligned_for_new (__align))
60
+ return __builtin_operator_delete (
61
+ __ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION (, __size), static_cast <align_val_t >(__align));
88
62
#endif
63
+ return __builtin_operator_delete (__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION (, __size));
89
64
}
90
65
91
66
#undef _LIBCPP_ONLY_IF_SIZED_DEALLOCATION
92
67
93
68
template <class _Tp >
94
- inline _LIBCPP_HIDE_FROM_ABI void
95
- __libcpp_deallocate_unsized (__type_identity_t <_Tp>* __ptr, size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {
96
- #if !_LIBCPP_HAS_ALIGNED_ALLOCATION
97
- (void )__align;
98
- return std::__libcpp_operator_delete (__ptr);
99
- #else
100
- if (__is_overaligned_for_new (__align)) {
101
- const align_val_t __align_val = static_cast <align_val_t >(__align);
102
- return std::__libcpp_operator_delete (__ptr, __align_val);
103
- } else {
104
- return std::__libcpp_operator_delete (__ptr);
105
- }
69
+ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized (
70
+ __type_identity_t <_Tp>* __ptr, [[__maybe_unused__]] size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {
71
+ #if _LIBCPP_HAS_ALIGNED_ALLOCATION
72
+ if (__is_overaligned_for_new (__align))
73
+ return __builtin_operator_delete (__ptr, static_cast <align_val_t >(__align));
106
74
#endif
75
+ return __builtin_operator_delete (__ptr);
107
76
}
108
77
_LIBCPP_END_NAMESPACE_STD
109
78
0 commit comments