File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,12 @@ void AssignmentInIfConditionCheck::check(
39
39
return true ;
40
40
}
41
41
42
+ // Dont traverse into any requires expressions.
43
+ bool TraverseRequiresExpr (RequiresExpr *,
44
+ DataRecursionQueue * = nullptr ) {
45
+ return true ;
46
+ }
47
+
42
48
bool VisitBinaryOperator (BinaryOperator *BO) {
43
49
if (BO->isAssignmentOp ())
44
50
Check.report (BO);
Original file line number Diff line number Diff line change @@ -232,6 +232,10 @@ Changes in existing checks
232
232
<clang-tidy/checks/bugprone/assert-side-effect>` check by detecting side
233
233
effect from calling a method with non-const reference parameters.
234
234
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
+
235
239
- Improved :doc: `bugprone-casting-through-void
236
240
<clang-tidy/checks/bugprone/casting-through-void>` check by ignoring casts
237
241
where source is already a ``void` `` pointer, making middle ``void `` pointer
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments