|
5 | 5 | void general(unsigned flags, bool value) { |
6 | 6 | (flags << 1) | value; |
7 | 7 | flags = (flags << 1) | value; |
| 8 | + flags = (flags << 1) | (flags << 2) | value; |
| 9 | + flags = (flags << 1) | (flags << 2) | (flags << 4) | value; |
8 | 10 | } |
9 | 11 |
|
10 | | -void take(bool value) {} |
| 12 | +// TODO: compound operators |
11 | 13 |
|
12 | | -// TODO: (flags << 1) | (flags << 2) | value |
| 14 | +void take(bool value) {} |
13 | 15 |
|
14 | 16 | template<bool bb = true | 1> |
15 | 17 | // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
@@ -39,6 +41,15 @@ void assign_to_boolean(unsigned flags, bool value) { |
39 | 41 | take((flags << 1) | value); |
40 | 42 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
41 | 43 | // CHECK-FIXES: take((flags << 1) || value); |
| 44 | + result = (flags << 1) | (flags << 2) | value; |
| 45 | + // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 46 | + // CHECK-MESSAGES: :[[@LINE-2]]:42: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 47 | + // CHECK-FIXES: result = (flags << 1) || (flags << 2) || value; |
| 48 | + result = (flags << 1) | (flags << 2) | (flags << 4) | value; |
| 49 | + // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 50 | + // CHECK-MESSAGES: :[[@LINE-2]]:42: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 51 | + // CHECK-MESSAGES: :[[@LINE-3]]:57: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 52 | + // CHECK-FIXES: result = (flags << 1) || (flags << 2) || (flags << 4) || value; |
42 | 53 | } |
43 | 54 |
|
44 | 55 | template<bool bb = (true | 1)> |
@@ -69,6 +80,15 @@ void assign_to_boolean_parens(unsigned flags, bool value) { |
69 | 80 | take(((flags << 1) | value)); |
70 | 81 | // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
71 | 82 | // CHECK-FIXES: take(((flags << 1) || value)); |
| 83 | + result = ((flags << 1) | (flags << 2) | value); |
| 84 | + // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 85 | + // CHECK-MESSAGES: :[[@LINE-2]]:43: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 86 | + // CHECK-FIXES: result = ((flags << 1) || (flags << 2) || value); |
| 87 | + result = ((flags << 1) | (flags << 2) | (flags << 4) | value); |
| 88 | + // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 89 | + // CHECK-MESSAGES: :[[@LINE-2]]:43: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 90 | + // CHECK-MESSAGES: :[[@LINE-3]]:58: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 91 | + // CHECK-FIXES: result = ((flags << 1) || (flags << 2) || (flags << 4) || value); |
72 | 92 | } |
73 | 93 |
|
74 | 94 | template<bool bb = ((true | 1))> |
@@ -99,6 +119,15 @@ void assign_to_boolean_parens2(unsigned flags, bool value) { |
99 | 119 | take((((flags << 1) | value))); |
100 | 120 | // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
101 | 121 | // CHECK-FIXES: take((((flags << 1) || value))); |
| 122 | + result = (((flags << 1) | (flags << 2) | value)); |
| 123 | + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 124 | + // CHECK-MESSAGES: :[[@LINE-2]]:44: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 125 | + // CHECK-FIXES: result = (((flags << 1) || (flags << 2) || value)); |
| 126 | + result = (((flags << 1) | (flags << 2) | (flags << 4) | value)); |
| 127 | + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 128 | + // CHECK-MESSAGES: :[[@LINE-2]]:44: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 129 | + // CHECK-MESSAGES: :[[@LINE-3]]:59: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 130 | + // CHECK-FIXES: result = (((flags << 1) || (flags << 2) || (flags << 4) || value)); |
102 | 131 | } |
103 | 132 |
|
104 | 133 | // functional cast |
@@ -130,6 +159,15 @@ void assign_to_boolean_fcast(unsigned flags, bool value) { |
130 | 159 | take(bool((flags << 1) | value)); |
131 | 160 | // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
132 | 161 | // CHECK-FIXES: take(bool((flags << 1) || value)); |
| 162 | + result = bool((flags << 1) | (flags << 2) | value); |
| 163 | + // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 164 | + // CHECK-MESSAGES: :[[@LINE-2]]:47: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 165 | + // CHECK-FIXES: result = bool((flags << 1) || (flags << 2) || value); |
| 166 | + result = bool((flags << 1) | (flags << 2) | (flags << 4) | value); |
| 167 | + // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 168 | + // CHECK-MESSAGES: :[[@LINE-2]]:47: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 169 | + // CHECK-MESSAGES: :[[@LINE-3]]:62: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 170 | + // CHECK-FIXES: result = bool((flags << 1) || (flags << 2) || (flags << 4) || value); |
133 | 171 | } |
134 | 172 |
|
135 | 173 | // C-style cast |
@@ -161,6 +199,15 @@ void assign_to_boolean_ccast(unsigned flags, bool value) { |
161 | 199 | take(bool((flags << 1) | value)); |
162 | 200 | // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
163 | 201 | // CHECK-FIXES: take(bool((flags << 1) || value)); |
| 202 | + result = (bool)((flags << 1) | (flags << 2) | value); |
| 203 | + // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 204 | + // CHECK-MESSAGES: :[[@LINE-2]]:49: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 205 | + // CHECK-FIXES: result = (bool)((flags << 1) || (flags << 2) || value); |
| 206 | + result = (bool)((flags << 1) | (flags << 2) | (flags << 4) | value); |
| 207 | + // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 208 | + // CHECK-MESSAGES: :[[@LINE-2]]:49: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 209 | + // CHECK-MESSAGES: :[[@LINE-3]]:64: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 210 | + // CHECK-FIXES: result = (bool)((flags << 1) || (flags << 2) || (flags << 4) || value); |
164 | 211 | } |
165 | 212 |
|
166 | 213 | // static_cast |
@@ -192,6 +239,15 @@ void assign_to_boolean_scast(unsigned flags, bool value) { |
192 | 239 | take(static_cast<bool>((flags << 1) | value)); |
193 | 240 | // CHECK-MESSAGES: :[[@LINE-1]]:41: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
194 | 241 | // CHECK-FIXES: take(static_cast<bool>((flags << 1) || value)); |
| 242 | + result = static_cast<bool>((flags << 1) | (flags << 2) | value); |
| 243 | + // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 244 | + // CHECK-MESSAGES: :[[@LINE-2]]:60: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 245 | + // CHECK-FIXES: result = static_cast<bool>((flags << 1) || (flags << 2) || value); |
| 246 | + result = static_cast<bool>((flags << 1) | (flags << 2) | (flags << 4) | value); |
| 247 | + // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 248 | + // CHECK-MESSAGES: :[[@LINE-2]]:60: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 249 | + // CHECK-MESSAGES: :[[@LINE-3]]:75: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation] |
| 250 | + // CHECK-FIXES: result = static_cast<bool>((flags << 1) || (flags << 2) || (flags << 4) || value); |
195 | 251 | } |
196 | 252 |
|
197 | 253 |
|
0 commit comments