Skip to content

Commit b48c501

Browse files
committed
[libc++] Make parameter names consistent and enforce the naming style using readability-identifier-naming
Ensure that parameter names have the style `__lower_case` Reviewed By: ldionne, #libc Spies: aheejin, sstefan1, libcxx-commits, miyuki Differential Revision: https://reviews.llvm.org/D129051
1 parent 02769f2 commit b48c501

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+378
-371
lines changed

libcxx/.clang-tidy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Checks: >
1717
modernize-redundant-void-arg,
1818
1919
readability-duplicate-include,
20+
readability-identifier-naming,
2021
readability-function-cognitive-complexity,
2122
readability-function-size,
2223
readability-misplaced-array-index,
@@ -31,6 +32,12 @@ CheckOptions:
3132
value: 143 # TODO: bring that number down
3233
- key: readability-function-size.LineThreshold
3334
value: 194 # TODO: bring that number down
35+
- key: readability-identifier-naming.GetConfigPerFile
36+
value: false
37+
- key: readability-identifier-naming.ParameterCase
38+
value: lower_case
39+
- key: readability-identifier-naming.ParameterPrefix
40+
value: __
3441

3542
# TODO: investigate these checks
3643
# bugprone-branch-clone,

libcxx/include/__algorithm/binary_search.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ template <class _ForwardIterator, class _Tp, class _Compare>
2525
_LIBCPP_NODISCARD_EXT inline
2626
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2727
bool
28-
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
28+
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
2929
{
3030
using _Comp_ref = typename __comp_ref_type<_Compare>::type;
31-
__first = std::lower_bound<_ForwardIterator, _Tp, _Comp_ref>(__first, __last, __value_, __comp);
32-
return __first != __last && !__comp(__value_, *__first);
31+
__first = std::lower_bound<_ForwardIterator, _Tp, _Comp_ref>(__first, __last, __value, __comp);
32+
return __first != __last && !__comp(__value, *__first);
3333
}
3434

3535
template <class _ForwardIterator, class _Tp>
3636
_LIBCPP_NODISCARD_EXT inline
3737
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3838
bool
39-
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
39+
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
4040
{
41-
return std::binary_search(__first, __last, __value_,
41+
return std::binary_search(__first, __last, __value,
4242
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
4343
}
4444

libcxx/include/__algorithm/count.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
template <class _InputIterator, class _Tp>
2323
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2424
typename iterator_traits<_InputIterator>::difference_type
25-
count(_InputIterator __first, _InputIterator __last, const _Tp& __value_) {
25+
count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
2626
typename iterator_traits<_InputIterator>::difference_type __r(0);
2727
for (; __first != __last; ++__first)
28-
if (*__first == __value_)
28+
if (*__first == __value)
2929
++__r;
3030
return __r;
3131
}

libcxx/include/__algorithm/equal_range.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3030

3131
template <class _Compare, class _ForwardIterator, class _Tp>
3232
_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
33-
__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
33+
__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
3434
{
3535
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
3636
difference_type __len = _VSTD::distance(__first, __last);
@@ -39,12 +39,12 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
3939
difference_type __l2 = _VSTD::__half_positive(__len);
4040
_ForwardIterator __m = __first;
4141
_VSTD::advance(__m, __l2);
42-
if (__comp(*__m, __value_))
42+
if (__comp(*__m, __value))
4343
{
4444
__first = ++__m;
4545
__len -= __l2 + 1;
4646
}
47-
else if (__comp(__value_, *__m))
47+
else if (__comp(__value, *__m))
4848
{
4949
__last = __m;
5050
__len = __l2;
@@ -55,8 +55,8 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
5555
_ForwardIterator __mp1 = __m;
5656
return pair<_ForwardIterator, _ForwardIterator>
5757
(
58-
_VSTD::__lower_bound_impl<_StdIterOps>(__first, __m, __value_, __comp, __proj),
59-
_VSTD::__upper_bound<_Compare>(++__mp1, __last, __value_, __comp)
58+
_VSTD::__lower_bound_impl<_StdIterOps>(__first, __m, __value, __comp, __proj),
59+
_VSTD::__upper_bound<_Compare>(++__mp1, __last, __value, __comp)
6060
);
6161
}
6262
}
@@ -67,19 +67,19 @@ template <class _ForwardIterator, class _Tp, class _Compare>
6767
_LIBCPP_NODISCARD_EXT inline
6868
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
6969
pair<_ForwardIterator, _ForwardIterator>
70-
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
70+
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
7171
{
7272
typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
73-
return _VSTD::__equal_range<_Comp_ref>(__first, __last, __value_, __comp);
73+
return _VSTD::__equal_range<_Comp_ref>(__first, __last, __value, __comp);
7474
}
7575

7676
template <class _ForwardIterator, class _Tp>
7777
_LIBCPP_NODISCARD_EXT inline
7878
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
7979
pair<_ForwardIterator, _ForwardIterator>
80-
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
80+
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
8181
{
82-
return _VSTD::equal_range(__first, __last, __value_,
82+
return _VSTD::equal_range(__first, __last, __value,
8383
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
8484
}
8585

libcxx/include/__algorithm/fill.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,26 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
template <class _ForwardIterator, class _Tp>
2424
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2525
void
26-
__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag)
26+
__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag)
2727
{
2828
for (; __first != __last; ++__first)
29-
*__first = __value_;
29+
*__first = __value;
3030
}
3131

3232
template <class _RandomAccessIterator, class _Tp>
3333
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3434
void
35-
__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag)
35+
__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag)
3636
{
37-
_VSTD::fill_n(__first, __last - __first, __value_);
37+
_VSTD::fill_n(__first, __last - __first, __value);
3838
}
3939

4040
template <class _ForwardIterator, class _Tp>
4141
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
4242
void
43-
fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
43+
fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
4444
{
45-
_VSTD::__fill(__first, __last, __value_, typename iterator_traits<_ForwardIterator>::iterator_category());
45+
_VSTD::__fill(__first, __last, __value, typename iterator_traits<_ForwardIterator>::iterator_category());
4646
}
4747

4848
_LIBCPP_END_NAMESPACE_STD

libcxx/include/__algorithm/fill_n.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
template <class _OutputIterator, class _Size, class _Tp>
2323
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2424
_OutputIterator
25-
__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
25+
__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
2626
{
2727
for (; __n > 0; ++__first, (void) --__n)
28-
*__first = __value_;
28+
*__first = __value;
2929
return __first;
3030
}
3131

3232
template <class _OutputIterator, class _Size, class _Tp>
3333
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3434
_OutputIterator
35-
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
35+
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
3636
{
37-
return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value_);
37+
return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value);
3838
}
3939

4040
_LIBCPP_END_NAMESPACE_STD

libcxx/include/__algorithm/find.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020

2121
template <class _InputIterator, class _Tp>
2222
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
23-
find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) {
23+
find(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
2424
for (; __first != __last; ++__first)
25-
if (*__first == __value_)
25+
if (*__first == __value)
2626
break;
2727
return __first;
2828
}

libcxx/include/__algorithm/lower_bound.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ _Iter __lower_bound_impl(_Iter __first, _Sent __last, const _Type& __value, _Com
4848

4949
template <class _ForwardIterator, class _Tp, class _Compare>
5050
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
51-
_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) {
51+
_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
5252
static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
5353
"The comparator has to be callable");
5454
auto __proj = std::__identity();
55-
return std::__lower_bound_impl<_StdIterOps>(__first, __last, __value_, __comp, __proj);
55+
return std::__lower_bound_impl<_StdIterOps>(__first, __last, __value, __comp, __proj);
5656
}
5757

5858
template <class _ForwardIterator, class _Tp>
5959
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
60-
_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) {
61-
return std::lower_bound(__first, __last, __value_,
60+
_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
61+
return std::lower_bound(__first, __last, __value,
6262
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
6363
}
6464

libcxx/include/__algorithm/minmax_element.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424

2525
template <class _Comp, class _Proj>
2626
class _MinmaxElementLessFunc {
27-
_Comp& __comp;
28-
_Proj& __proj;
27+
_Comp& __comp_;
28+
_Proj& __proj_;
2929

3030
public:
3131
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
32-
_MinmaxElementLessFunc(_Comp& __comp_, _Proj& __proj_) : __comp(__comp_), __proj(__proj_) {}
32+
_MinmaxElementLessFunc(_Comp& __comp, _Proj& __proj) : __comp_(__comp), __proj_(__proj) {}
3333

3434
template <class _Iter>
3535
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
3636
bool operator()(_Iter& __it1, _Iter& __it2) {
37-
return std::__invoke(__comp, std::__invoke(__proj, *__it1), std::__invoke(__proj, *__it2));
37+
return std::__invoke(__comp_, std::__invoke(__proj_, *__it1), std::__invoke(__proj_, *__it2));
3838
}
3939
};
4040

libcxx/include/__algorithm/remove.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222

2323
template <class _ForwardIterator, class _Tp>
2424
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
25-
remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
25+
remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
2626
{
27-
__first = _VSTD::find(__first, __last, __value_);
27+
__first = _VSTD::find(__first, __last, __value);
2828
if (__first != __last)
2929
{
3030
_ForwardIterator __i = __first;
3131
while (++__i != __last)
3232
{
33-
if (!(*__i == __value_))
33+
if (!(*__i == __value))
3434
{
3535
*__first = _VSTD::move(*__i);
3636
++__first;

0 commit comments

Comments
 (0)