Skip to content

Commit

Permalink
[libc++] Replace several uses of 0 by nullptr
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D43159
  • Loading branch information
waywardmonkeys authored and ldionne committed Nov 27, 2020
1 parent 4c419c4 commit 527a7fd
Show file tree
Hide file tree
Showing 23 changed files with 258 additions and 258 deletions.
2 changes: 1 addition & 1 deletion libcxx/include/__locale
Expand Up @@ -628,7 +628,7 @@ class _LIBCPP_TYPE_VIS ctype<char>
public:
typedef char char_type;

explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);
explicit ctype(const mask* __tab = nullptr, bool __del = false, size_t __refs = 0);

_LIBCPP_INLINE_VISIBILITY
bool is(mask __m, char_type __c) const
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__sso_allocator
Expand Up @@ -48,7 +48,7 @@ public:
private:
__sso_allocator& operator=(const __sso_allocator&);
public:
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = 0)
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = nullptr)
{
if (!__allocated_ && __n <= _Np)
{
Expand Down
16 changes: 8 additions & 8 deletions libcxx/include/__string
Expand Up @@ -268,7 +268,7 @@ char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a
return __s;
++__s;
}
return 0;
return nullptr;
}

template <class _CharT>
Expand Down Expand Up @@ -683,7 +683,7 @@ char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __
return __s;
++__s;
}
return 0;
return nullptr;
}

#endif // #_LIBCPP_NO_HAS_CHAR8_T
Expand Down Expand Up @@ -765,7 +765,7 @@ char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& _
return __s;
++__s;
}
return 0;
return nullptr;
}

inline _LIBCPP_CONSTEXPR_AFTER_CXX17
Expand Down Expand Up @@ -885,7 +885,7 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _
return __s;
++__s;
}
return 0;
return nullptr;
}

inline _LIBCPP_CONSTEXPR_AFTER_CXX17
Expand Down Expand Up @@ -943,7 +943,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
if (__pos >= __sz)
return __npos;
const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);
if (__r == 0)
if (__r == nullptr)
return __npos;
return static_cast<_SizeT>(__r - __p);
}
Expand Down Expand Up @@ -972,7 +972,7 @@ __search_substring(const _CharT *__first1, const _CharT *__last1,

// Find __f2 the first byte matching in __first1.
__first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);
if (__first1 == 0)
if (__first1 == nullptr)
return __last1;

// It is faster to compare from the first byte of __first1 even if we
Expand Down Expand Up @@ -1095,7 +1095,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
{
const _CharT* __pe = __p + __sz;
for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
if (_Traits::find(__s, __n, *__ps) == 0)
if (_Traits::find(__s, __n, *__ps) == nullptr)
return static_cast<_SizeT>(__ps - __p);
}
return __npos;
Expand Down Expand Up @@ -1129,7 +1129,7 @@ __str_find_last_not_of(const _CharT *__p, _SizeT __sz,
else
__pos = __sz;
for (const _CharT* __ps = __p + __pos; __ps != __p;)
if (_Traits::find(__s, __n, *--__ps) == 0)
if (_Traits::find(__s, __n, *--__ps) == nullptr)
return static_cast<_SizeT>(__ps - __p);
return __npos;
}
Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/__threading_support
Expand Up @@ -497,13 +497,13 @@ bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)

// Thread
bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
return *__t == 0;
return *__t == __libcpp_thread_t();
}

int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
{
return pthread_create(__t, 0, __func, __arg);
return pthread_create(__t, nullptr, __func, __arg);
}

__libcpp_thread_id __libcpp_thread_get_current_id()
Expand All @@ -518,7 +518,7 @@ __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)

int __libcpp_thread_join(__libcpp_thread_t *__t)
{
return pthread_join(*__t, 0);
return pthread_join(*__t, nullptr);
}

int __libcpp_thread_detach(__libcpp_thread_t *__t)
Expand Down
34 changes: 17 additions & 17 deletions libcxx/include/algorithm
Expand Up @@ -3405,7 +3405,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
// Update __first to always point to the end of the trues
value_type* __t = __p.first;
::new(__t) value_type(_VSTD::move(*__first));
__d.__incr((value_type*)0);
__d.template __incr<value_type>();
++__t;
_ForwardIterator __i = __first;
while (++__i != __last)
Expand All @@ -3418,7 +3418,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
else
{
::new(__t) value_type(_VSTD::move(*__i));
__d.__incr((value_type*)0);
__d.template __incr<value_type>();
++__t;
}
}
Expand Down Expand Up @@ -3535,7 +3535,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
// Update __first to always point to the end of the trues
value_type* __t = __p.first;
::new(__t) value_type(_VSTD::move(*__first));
__d.__incr((value_type*)0);
__d.template __incr<value_type>();
++__t;
_BidirectionalIterator __i = __first;
while (++__i != __last)
Expand All @@ -3548,7 +3548,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
else
{
::new(__t) value_type(_VSTD::move(*__i));
__d.__incr((value_type*)0);
__d.template __incr<value_type>();
++__t;
}
}
Expand Down Expand Up @@ -3923,23 +3923,23 @@ __insertion_sort_move(_BirdirectionalIterator __first1, _BirdirectionalIterator
unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
value_type* __last2 = __first2;
::new(__last2) value_type(_VSTD::move(*__first1));
__d.__incr((value_type*)0);
__d.template __incr<value_type>();
for (++__last2; ++__first1 != __last1; ++__last2)
{
value_type* __j2 = __last2;
value_type* __i2 = __j2;
if (__comp(*__first1, *--__i2))
{
::new(__j2) value_type(_VSTD::move(*__i2));
__d.__incr((value_type*)0);
__d.template __incr<value_type>();
for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
*__j2 = _VSTD::move(*__i2);
*__j2 = _VSTD::move(*__first1);
}
else
{
::new(__j2) value_type(_VSTD::move(*__first1));
__d.__incr((value_type*)0);
__d.template __incr<value_type>();
}
}
__h.release();
Expand Down Expand Up @@ -4481,14 +4481,14 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
if (__len1 <= __len2)
{
value_type* __p = __buff;
for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), (void) ++__i, (void) ++__p)
for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
::new(__p) value_type(_VSTD::move(*__i));
__half_inplace_merge(__buff, __p, __middle, __last, __first, __comp);
}
else
{
value_type* __p = __buff;
for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), (void) ++__i, (void) ++__p)
for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
::new(__p) value_type(_VSTD::move(*__i));
typedef reverse_iterator<_BidirectionalIterator> _RBi;
typedef reverse_iterator<value_type*> _Rv;
Expand Down Expand Up @@ -4628,28 +4628,28 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
{
if (__first1 == __last1)
{
for (; __first2 != __last2; ++__first2, ++__result, (void) __d.__incr((value_type*)0))
for (; __first2 != __last2; ++__first2, ++__result, (void)__d.template __incr<value_type>())
::new (__result) value_type(_VSTD::move(*__first2));
__h.release();
return;
}
if (__first2 == __last2)
{
for (; __first1 != __last1; ++__first1, ++__result, (void) __d.__incr((value_type*)0))
for (; __first1 != __last1; ++__first1, ++__result, (void)__d.template __incr<value_type>())
::new (__result) value_type(_VSTD::move(*__first1));
__h.release();
return;
}
if (__comp(*__first2, *__first1))
{
::new (__result) value_type(_VSTD::move(*__first2));
__d.__incr((value_type*)0);
__d.template __incr<value_type>();
++__first2;
}
else
{
::new (__result) value_type(_VSTD::move(*__first1));
__d.__incr((value_type*)0);
__d.template __incr<value_type>();
++__first1;
}
}
Expand Down Expand Up @@ -4710,14 +4710,14 @@ __stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1
if (__comp(*--__last1, *__first1))
{
::new(__first2) value_type(_VSTD::move(*__last1));
__d.__incr((value_type*)0);
__d.template __incr<value_type>();
++__first2;
::new(__first2) value_type(_VSTD::move(*__first1));
}
else
{
::new(__first2) value_type(_VSTD::move(*__first1));
__d.__incr((value_type*)0);
__d.template __incr<value_type>();
++__first2;
::new(__first2) value_type(_VSTD::move(*__last1));
}
Expand Down Expand Up @@ -4772,9 +4772,9 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
__stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff);
__d.__set(__l2, (value_type*)0);
__d.__set(__l2, (value_type*)nullptr);
__stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);
__d.__set(__len, (value_type*)0);
__d.__set(__len, (value_type*)nullptr);
__merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);
// __merge<_Compare>(move_iterator<value_type*>(__buff),
// move_iterator<value_type*>(__buff + __l2),
Expand Down
8 changes: 4 additions & 4 deletions libcxx/include/bitset
Expand Up @@ -625,13 +625,13 @@ protected:
explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;

_LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT
{return reference(0, 1);}
{return reference(nullptr, 1);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT
{return const_reference(0, 1);}
{return const_reference(nullptr, 1);}
_LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT
{return iterator(0, 0);}
{return iterator(nullptr, 0);}
_LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT
{return const_iterator(0, 0);}
{return const_iterator(nullptr, 0);}

_LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {}
Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/chrono
Expand Up @@ -1077,7 +1077,7 @@ public:
is_convertible<_Rep2, rep>::value &&
(treat_as_floating_point<rep>::value ||
!treat_as_floating_point<_Rep2>::value)
>::type* = 0)
>::type* = nullptr)
: __rep_(__r) {}

// conversions
Expand All @@ -1090,7 +1090,7 @@ public:
treat_as_floating_point<rep>::value ||
(__no_overflow<_Period2, period>::type::den == 1 &&
!treat_as_floating_point<_Rep2>::value))
>::type* = 0)
>::type* = nullptr)
: __rep_(_VSTD::chrono::duration_cast<duration>(__d).count()) {}

// observer
Expand Down Expand Up @@ -1376,7 +1376,7 @@ public:
typename enable_if
<
is_convertible<_Duration2, duration>::value
>::type* = 0)
>::type* = nullptr)
: __d_(t.time_since_epoch()) {}

// observer
Expand Down

0 comments on commit 527a7fd

Please sign in to comment.