[libc++] Consistently replace `::new(__p) T` with `::new ((void*)__p) T`. NFCI.
Everywhere, normalize the whitespace to `::new (EXPR) T`.
Everywhere, normalize the spelling of the cast to `(void*)EXPR`.
Without the cast to `(void*)`, the expression triggers ADL on GCC.
(I think this is a GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98249)
Even if it doesn't trigger ADL, it still seems incorrect to use any argument
that's not exactly `(void*)` because that opens the possibility of overload
resolution picking a user-defined overload of `operator new`, which would be
wrong.
Differential Revision: https://reviews.llvm.org/D93153
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index b1771a1..7a4cc39 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -3404,7 +3404,7 @@
// Move the falses into the temporary buffer, and the trues to the front of the line
// Update __first to always point to the end of the trues
value_type* __t = __p.first;
- ::new(__t) value_type(_VSTD::move(*__first));
+ ::new ((void*)__t) value_type(_VSTD::move(*__first));
__d.template __incr<value_type>();
++__t;
_ForwardIterator __i = __first;
@@ -3417,7 +3417,7 @@
}
else
{
- ::new(__t) value_type(_VSTD::move(*__i));
+ ::new ((void*)__t) value_type(_VSTD::move(*__i));
__d.template __incr<value_type>();
++__t;
}
@@ -3534,7 +3534,7 @@
// Move the falses into the temporary buffer, and the trues to the front of the line
// Update __first to always point to the end of the trues
value_type* __t = __p.first;
- ::new(__t) value_type(_VSTD::move(*__first));
+ ::new ((void*)__t) value_type(_VSTD::move(*__first));
__d.template __incr<value_type>();
++__t;
_BidirectionalIterator __i = __first;
@@ -3547,7 +3547,7 @@
}
else
{
- ::new(__t) value_type(_VSTD::move(*__i));
+ ::new ((void*)__t) value_type(_VSTD::move(*__i));
__d.template __incr<value_type>();
++__t;
}
@@ -3922,7 +3922,7 @@
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
value_type* __last2 = __first2;
- ::new(__last2) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__last2) value_type(_VSTD::move(*__first1));
__d.template __incr<value_type>();
for (++__last2; ++__first1 != __last1; ++__last2)
{
@@ -3930,7 +3930,7 @@
value_type* __i2 = __j2;
if (__comp(*__first1, *--__i2))
{
- ::new(__j2) value_type(_VSTD::move(*__i2));
+ ::new ((void*)__j2) value_type(_VSTD::move(*__i2));
__d.template __incr<value_type>();
for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
*__j2 = _VSTD::move(*__i2);
@@ -3938,7 +3938,7 @@
}
else
{
- ::new(__j2) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__j2) value_type(_VSTD::move(*__first1));
__d.template __incr<value_type>();
}
}
@@ -4482,14 +4482,14 @@
{
value_type* __p = __buff;
for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
- ::new(__p) value_type(_VSTD::move(*__i));
+ ::new ((void*)__p) value_type(_VSTD::move(*__i));
_VSTD::__half_inplace_merge(__buff, __p, __middle, __last, __first, __comp);
}
else
{
value_type* __p = __buff;
for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
- ::new(__p) value_type(_VSTD::move(*__i));
+ ::new ((void*)__p) value_type(_VSTD::move(*__i));
typedef reverse_iterator<_BidirectionalIterator> _RBi;
typedef reverse_iterator<value_type*> _Rv;
_VSTD::__half_inplace_merge(_Rv(__p), _Rv(__buff),
@@ -4629,26 +4629,26 @@
if (__first1 == __last1)
{
for (; __first2 != __last2; ++__first2, ++__result, (void)__d.template __incr<value_type>())
- ::new (__result) value_type(_VSTD::move(*__first2));
+ ::new ((void*)__result) value_type(_VSTD::move(*__first2));
__h.release();
return;
}
if (__first2 == __last2)
{
for (; __first1 != __last1; ++__first1, ++__result, (void)__d.template __incr<value_type>())
- ::new (__result) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__result) value_type(_VSTD::move(*__first1));
__h.release();
return;
}
if (__comp(*__first2, *__first1))
{
- ::new (__result) value_type(_VSTD::move(*__first2));
+ ::new ((void*)__result) value_type(_VSTD::move(*__first2));
__d.template __incr<value_type>();
++__first2;
}
else
{
- ::new (__result) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__result) value_type(_VSTD::move(*__first1));
__d.template __incr<value_type>();
++__first1;
}
@@ -4702,24 +4702,24 @@
case 0:
return;
case 1:
- ::new(__first2) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
return;
case 2:
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);
if (__comp(*--__last1, *__first1))
{
- ::new(__first2) value_type(_VSTD::move(*__last1));
+ ::new ((void*)__first2) value_type(_VSTD::move(*__last1));
__d.template __incr<value_type>();
++__first2;
- ::new(__first2) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
}
else
{
- ::new(__first2) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
__d.template __incr<value_type>();
++__first2;
- ::new(__first2) value_type(_VSTD::move(*__last1));
+ ::new ((void*)__first2) value_type(_VSTD::move(*__last1));
}
__h2.release();
return;