================
@@ -1035,3 +1035,19 @@ void instantiate() {
ignoreInstantiations<true>();
ignoreInstantiations<false>();
}
+
+void if_with_init_statement() {
+ bool x = true;
+ if (bool y = x; y == true) {
+ // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: redundant boolean literal
supplied to boolean operator [readability-simplify-boolean-expr]
+ // CHECK-FIXES: if (bool y = x; y) {
+ }
+}
+
+void test_init_stmt_true() {
+ void foo(int i);
+ if (int i = 0; true)
+ foo(i);
+ // CHECK-MESSAGES: :[[@LINE-2]]:18: warning: redundant boolean literal in if
statement condition [readability-simplify-boolean-expr]
+ // CHECK-FIXES: { int i = 0;foo(i) };
----------------
vbvictor wrote:
Actually, I don't get this transformation.
Did we transform this piece
```cpp
void foo(int i)
if (int i = 0; true)
foo(i);
```
to this?
```
void foo(int i)
{ int i = 0;foo(i) };
```
Can we omit braces then.
https://github.com/llvm/llvm-project/pull/172220
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits