File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ void ok_eq (int a) {
2+ if (a == 0 ) {} // CHECK-MESSAGES-NOT: readability-constant-operand-order
3+ // CHECK-LEFT-MESSAGES: warning: constant operand should be on the Left side
4+ // CHECK-LEFT-FIXES: if (0 == a) {} //
5+ }
6+
7+
8+ void swap_eq (int a) {
9+ if (0 == a) {} // CHECK-MESSAGES: warning: constant operand should be on the Right side
10+ // CHECK-FIXES: if (a == 0) {} //
11+ }
12+
13+ void swap_asym (int a) {
14+ if (0 < a) {} // CHECK-MESSAGES: warning:
15+ // CHECK-FIXES: if (a > 0) {} //
16+ }
17+
18+ void null_ptr (int *p) {
19+ if (nullptr == p) {} // CHECK-MESSAGES: warning:
20+ // CHECK-FIXES: if (p == nullptr) {} //
21+ }
22+
23+ // No-fix when side effects:
24+ int g ();
25+ void side_effects (int a) {
26+ if (0 == g ()) {} // CHECK-MESSAGES: warning:
27+ // CHECK-FIXES-NOT: if (g() == 0)
28+ }
29+
30+ // Config variant: allow Left and only ==,!=
31+ void left_ok (int a) {
32+ if (0 == a) {} // CHECK-MESSAGES: warning:
33+ // CHECK-FIXES: if (a == 0) {} //
34+ // CHECK-LEFT-MESSAGES-NOT: readability-constant-operand-order
35+ }
You can’t perform that action at this time.
0 commit comments