1 // RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t -- -config="{CheckOptions: [{key: "readability-simplify-boolean-expr.ChainedConditionalAssignment", value: 1}]}" --
2
chained_conditional_compound_assignment(int i)3 void chained_conditional_compound_assignment(int i) {
4 bool b;
5 if (i < 0) {
6 b = true;
7 } else if (i < 10) {
8 b = false;
9 } else if (i > 20) {
10 b = true;
11 } else {
12 b = false;
13 }
14 // CHECK-MESSAGES: :[[@LINE-4]]:9: warning: redundant boolean literal in conditional assignment [readability-simplify-boolean-expr]
15 // CHECK-FIXES: {{^}} } else if (i < 10) {{{$}}
16 // CHECK-FIXES-NEXT: {{^}} b = false;{{$}}
17 // CHECK-FIXES-NEXT: {{^}} } else b = i > 20;{{$}}
18 }
19
chained_conditional_assignment(int i)20 void chained_conditional_assignment(int i) {
21 bool b;
22 if (i < 0)
23 b = true;
24 else if (i < 10)
25 b = false;
26 else if (i > 20)
27 b = true;
28 else
29 b = false;
30 // CHECK-MESSAGES: :[[@LINE-3]]:9: warning: {{.*}} in conditional assignment
31 // CHECK-FIXES: {{^}} else if (i < 10)
32 // CHECK-FIXES-NEXT: {{^}} b = false;
33 // CHECK-FIXES-NEXT: {{^}} else b = i > 20;
34 }
35