================
@@ -1035,3 +1035,36 @@ void instantiate() {
   ignoreInstantiations<true>();
   ignoreInstantiations<false>();
 }
+
+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); };
+}
+
+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) {
+  }
+}
+
+// This matches the "RAII" and "Cond" logic from the deleted C++17 file
+// to ensure we don't regress or crash on these complex cases.
----------------
zeyi2 wrote:

IMO you should not remove the 
`clang-tools-extra/test/clang-tidy/checkers/readability/simplify-boolean-expr-cxx17.cpp`
 file. They are divided to handle different scenarios.

E.g. This file uses `// RUN: %check_clang_tidy %s 
readability-simplify-boolean-expr %t`, while the file you deleted adds 
`-std=c++17` to verify behaviours in a different C++ standard.

https://github.com/llvm/llvm-project/pull/172220
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to