Skip to content

Commit 9cccf69

Browse files
committed
Merge branch 'main' into users/vikramRH/enable_opt
2 parents 888623a + 662c6fc commit 9cccf69

File tree

682 files changed

+19006
-9339
lines changed

Some content is hidden

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

682 files changed

+19006
-9339
lines changed

clang-tools-extra/clang-tidy/bugprone/AssignmentInIfConditionCheck.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ void AssignmentInIfConditionCheck::check(
3939
return true;
4040
}
4141

42+
// Dont traverse into any requires expressions.
43+
bool TraverseRequiresExpr(RequiresExpr *,
44+
DataRecursionQueue * = nullptr) {
45+
return true;
46+
}
47+
4248
bool VisitBinaryOperator(BinaryOperator *BO) {
4349
if (BO->isAssignmentOp())
4450
Check.report(BO);

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ Changes in existing checks
232232
<clang-tidy/checks/bugprone/assert-side-effect>` check by detecting side
233233
effect from calling a method with non-const reference parameters.
234234

235+
- Improved :doc:`bugprone-assignment-in-if-condition
236+
<clang-tidy/checks/bugprone/assignment-in-if-condition>` check by ignoring
237+
assignments in the C++20 ``requires`` clause.
238+
235239
- Improved :doc:`bugprone-casting-through-void
236240
<clang-tidy/checks/bugprone/casting-through-void>` check by ignoring casts
237241
where source is already a ``void``` pointer, making middle ``void`` pointer

clang-tools-extra/docs/clang-tidy/checks/boost/use-ranges.rst

Lines changed: 113 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,128 @@ Example
1616
std::end(Items2));
1717

1818

19-
transforms to:
19+
Transforms to:
2020

2121
.. code-block:: c++
2222

2323
auto Iter1 = boost::range::find(Items, 0);
2424
auto AreSame = boost::range::equal(Items1, Items2);
2525

26+
Supported algorithms
27+
--------------------
28+
2629
Calls to the following std library algorithms are checked:
27-
``includes``,``set_union``,``set_intersection``,``set_difference``,
28-
``set_symmetric_difference``,``unique``,``lower_bound``,``stable_sort``,
29-
``equal_range``,``remove_if``,``sort``,``random_shuffle``,``remove_copy``,
30-
``stable_partition``,``remove_copy_if``,``count``,``copy_backward``,
31-
``reverse_copy``,``adjacent_find``,``remove``,``upper_bound``,``binary_search``,
32-
``replace_copy_if``,``for_each``,``generate``,``count_if``,``min_element``,
33-
``reverse``,``replace_copy``,``fill``,``unique_copy``,``transform``,``copy``,
34-
``replace``,``find``,``replace_if``,``find_if``,``partition``,``max_element``,
35-
``find_end``,``merge``,``partial_sort_copy``,``find_first_of``,``search``,
36-
``lexicographical_compare``,``equal``,``mismatch``,``next_permutation``,
37-
``prev_permutation``,``push_heap``,``pop_heap``,``make_heap``,``sort_heap``,
38-
``copy_if``,``is_permutation``,``is_partitioned``,``find_if_not``,
39-
``partition_copy``,``any_of``,``iota``,``all_of``,``partition_point``,
40-
``is_sorted``,``none_of``,``is_sorted_until``,``reduce``,``accumulate``,
41-
``parital_sum``,``adjacent_difference``.
30+
31+
``std::accumulate``,
32+
``std::adjacent_difference``,
33+
``std::adjacent_find``,
34+
``std::all_of``,
35+
``std::any_of``,
36+
``std::binary_search``,
37+
``std::copy_backward``,
38+
``std::copy_if``,
39+
``std::copy``,
40+
``std::count_if``,
41+
``std::count``,
42+
``std::equal_range``,
43+
``std::equal``,
44+
``std::fill``,
45+
``std::find_end``,
46+
``std::find_first_of``,
47+
``std::find_if_not``,
48+
``std::find_if``,
49+
``std::find``,
50+
``std::for_each``,
51+
``std::generate``,
52+
``std::includes``,
53+
``std::iota``,
54+
``std::is_partitioned``,
55+
``std::is_permutation``,
56+
``std::is_sorted_until``,
57+
``std::is_sorted``,
58+
``std::lexicographical_compare``,
59+
``std::lower_bound``,
60+
``std::make_heap``,
61+
``std::max_element``,
62+
``std::merge``,
63+
``std::min_element``,
64+
``std::mismatch``,
65+
``std::next_permutation``,
66+
``std::none_of``,
67+
``std::parital_sum``,
68+
``std::partial_sort_copy``,
69+
``std::partition_copy``,
70+
``std::partition_point``,
71+
``std::partition``,
72+
``std::pop_heap``,
73+
``std::prev_permutation``,
74+
``std::push_heap``,
75+
``std::random_shuffle``,
76+
``std::reduce``,
77+
``std::remove_copy_if``,
78+
``std::remove_copy``,
79+
``std::remove_if``,
80+
``std::remove``,
81+
``std::replace_copy_if``,
82+
``std::replace_copy``,
83+
``std::replace_if``,
84+
``std::replace``,
85+
``std::reverse_copy``,
86+
``std::reverse``,
87+
``std::search``,
88+
``std::set_difference``,
89+
``std::set_intersection``,
90+
``std::set_symmetric_difference``,
91+
``std::set_union``,
92+
``std::sort_heap``,
93+
``std::sort``,
94+
``std::stable_partition``,
95+
``std::stable_sort``,
96+
``std::transform``,
97+
``std::unique_copy``,
98+
``std::unique``,
99+
``std::upper_bound``.
42100

43101
The check will also look for the following functions from the
44102
``boost::algorithm`` namespace:
45-
``reduce``,``find_backward``,``find_not_backward``,``find_if_backward``,
46-
``find_if_not_backward``,``hex``,``hex_lower``,``unhex``,
47-
``is_partitioned_until``,``is_palindrome``,``copy_if``,``copy_while``,
48-
``copy_until``,``copy_if_while``,``copy_if_until``,``is_permutation``,
49-
``is_partitioned``,``one_of``,``one_of_equal``,``find_if_not``,
50-
``partition_copy``,``any_of``,``any_of_equal``,``iota``,``all_of``,
51-
``all_of_equal``,``partition_point``,``is_sorted_until``,``is_sorted``,
52-
``is_increasing``,``is_decreasing``,``is_strictly_increasing``,
53-
``is_strictly_decreasing``,``none_of``,``none_of_equal``,``clamp_range``,
54-
``apply_permutation``,``apply_reverse_permutation``.
103+
104+
``all_of_equal``,
105+
``any_of_equal``,
106+
``any_of``,
107+
``apply_permutation``,
108+
``apply_reverse_permutation``,
109+
``clamp_range``,
110+
``copy_if_until``,
111+
``copy_if_while``,
112+
``copy_if``,
113+
``copy_until``,
114+
``copy_while``,
115+
``find_backward``,
116+
``find_if_backward``,
117+
``find_if_not_backward``,
118+
``find_if_not``,
119+
``find_not_backward``,
120+
``hex_lower``,
121+
``hex``,
122+
``iota``, ``all_of``,
123+
``is_decreasing``,
124+
``is_increasing``,
125+
``is_palindrome``,
126+
``is_partitioned_until``,
127+
``is_partitioned``,
128+
``is_permutation``,
129+
``is_sorted_until``,
130+
``is_sorted``,
131+
``is_strictly_decreasing``,
132+
``is_strictly_increasing``,
133+
``none_of_equal``,
134+
``none_of``,
135+
``one_of_equal``,
136+
``one_of``,
137+
``partition_copy``,
138+
``partition_point``,
139+
``reduce``,
140+
``unhex``.
55141

56142
Reverse Iteration
57143
-----------------
@@ -64,7 +150,7 @@ fixed using the ``boost::adaptors::reverse`` adaptor.
64150
auto AreSame = std::equal(Items1.rbegin(), Items1.rend(),
65151
std::crbegin(Items2), std::crend(Items2));
66152

67-
transformst to:
153+
Transforms to:
68154

69155
.. code-block:: c++
70156

clang-tools-extra/docs/clang-tidy/checks/modernize/use-ranges.rst

Lines changed: 78 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,90 @@ Example
1616
std::begin(Items2), std::end(Items2));
1717

1818

19-
transforms to:
19+
Transforms to:
2020

2121
.. code-block:: c++
2222

2323
auto Iter1 = std::ranges::find(Items, 0);
2424
auto AreSame = std::ranges::equal(Items1, Items2);
2525

26+
Supported algorithms
27+
--------------------
28+
2629
Calls to the following std library algorithms are checked:
27-
``::std::all_of``,``::std::any_of``,``::std::none_of``,``::std::for_each``,
28-
``::std::find``,``::std::find_if``,``::std::find_if_not``,
29-
``::std::adjacent_find``,``::std::copy``,``::std::copy_if``,
30-
``::std::copy_backward``,``::std::move``,``::std::move_backward``,
31-
``::std::fill``,``::std::transform``,``::std::replace``,``::std::replace_if``,
32-
``::std::generate``,``::std::remove``,``::std::remove_if``,
33-
``::std::remove_copy``,``::std::remove_copy_if``,``::std::unique``,
34-
``::std::unique_copy``,``::std::sample``,``::std::partition_point``,
35-
``::std::lower_bound``,``::std::upper_bound``,``::std::equal_range``,
36-
``::std::binary_search``,``::std::push_heap``,``::std::pop_heap``,
37-
``::std::make_heap``,``::std::sort_heap``,``::std::next_permutation``,
38-
``::std::prev_permutation``,``::std::iota``,``::std::reverse``,
39-
``::std::reverse_copy``,``::std::shift_left``,``::std::shift_right``,
40-
``::std::is_partitioned``,``::std::partition``,``::std::partition_copy``,
41-
``::std::stable_partition``,``::std::sort``,``::std::stable_sort``,
42-
``::std::is_sorted``,``::std::is_sorted_until``,``::std::is_heap``,
43-
``::std::is_heap_until``,``::std::max_element``,``::std::min_element``,
44-
``::std::minmax_element``,``::std::uninitialized_copy``,
45-
``::std::uninitialized_fill``,``::std::uninitialized_move``,
46-
``::std::uninitialized_default_construct``,
47-
``::std::uninitialized_value_construct``,``::std::destroy``,
48-
``::std::partial_sort_copy``,``::std::includes``,
49-
``::std::set_union``,``::std::set_intersection``,``::std::set_difference``,
50-
``::std::set_symmetric_difference``,``::std::merge``,
51-
``::std::lexicographical_compare``,``::std::find_end``,``::std::search``,
52-
``::std::is_permutation``,``::std::equal``,``::std::mismatch``.
30+
31+
``std::adjacent_find``,
32+
``std::all_of``,
33+
``std::any_of``,
34+
``std::binary_search``,
35+
``std::copy_backward``,
36+
``std::copy_if``,
37+
``std::copy``,
38+
``std::destroy``,
39+
``std::equal_range``,
40+
``std::equal``,
41+
``std::fill``,
42+
``std::find_end``,
43+
``std::find_if_not``,
44+
``std::find_if``,
45+
``std::find``,
46+
``std::for_each``,
47+
``std::generate``,
48+
``std::includes``,
49+
``std::iota``,
50+
``std::is_heap_until``,
51+
``std::is_heap``,
52+
``std::is_partitioned``,
53+
``std::is_permutation``,
54+
``std::is_sorted_until``,
55+
``std::is_sorted``,
56+
``std::lexicographical_compare``,
57+
``std::lower_bound``,
58+
``std::make_heap``,
59+
``std::max_element``,
60+
``std::merge``,
61+
``std::min_element``,
62+
``std::minmax_element``,
63+
``std::mismatch``,
64+
``std::move_backward``,
65+
``std::move``,
66+
``std::next_permutation``,
67+
``std::none_of``,
68+
``std::partial_sort_copy``,
69+
``std::partition_copy``,
70+
``std::partition_point``,
71+
``std::partition``,
72+
``std::pop_heap``,
73+
``std::prev_permutation``,
74+
``std::push_heap``,
75+
``std::remove_copy_if``,
76+
``std::remove_copy``,
77+
``std::remove``, ``std::remove_if``,
78+
``std::replace_if``,
79+
``std::replace``,
80+
``std::reverse_copy``,
81+
``std::reverse``,
82+
``std::sample``,
83+
``std::search``,
84+
``std::set_difference``,
85+
``std::set_intersection``,
86+
``std::set_symmetric_difference``,
87+
``std::set_union``,
88+
``std::shift_left``,
89+
``std::shift_right``,
90+
``std::sort_heap``,
91+
``std::sort``,
92+
``std::stable_partition``,
93+
``std::stable_sort``,
94+
``std::transform``,
95+
``std::uninitialized_copy``,
96+
``std::uninitialized_default_construct``,
97+
``std::uninitialized_fill``,
98+
``std::uninitialized_move``,
99+
``std::uninitialized_value_construct``,
100+
``std::unique_copy``,
101+
``std::unique``,
102+
``std::upper_bound``.
53103

54104
Reverse Iteration
55105
-----------------
@@ -62,7 +112,7 @@ fixed using the ``std::views::reverse`` adaptor.
62112
auto AreSame = std::equal(Items1.rbegin(), Items1.rend(),
63113
std::crbegin(Items2), std::crend(Items2));
64114

65-
transformst to:
115+
Transforms to:
66116

67117
.. code-block:: c++
68118

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %check_clang_tidy -std=c++20 %s bugprone-assignment-in-if-condition %t
2+
3+
void testRequires() {
4+
if constexpr (requires(int &a) { a = 0; }) {
5+
}
6+
}

0 commit comments

Comments
 (0)