================
@@ -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) };
----------------
Anshul200677 wrote:
@vbvictor I've updated the implementation to generate valid C++ code. It now
correctly inserts a space and ensures the statement ends with a semicolon
(e.g., { int i = 0; foo(i); };).
https://github.com/llvm/llvm-project/pull/172220
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits