[clang-tools-extra] [clang-tidy] Add `modernize-redundant-zero-initializer` (PR #209367)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 27 10:48:19 PDT 2026


================
@@ -0,0 +1,17 @@
+// RUN: %check_clang_tidy -std=c17 -check-suffixes=C17 %s modernize-redundant-zero-initializer %t
+// RUN: %check_clang_tidy -std=c23-or-later -check-suffixes=C23 %s modernize-redundant-zero-initializer %t
+
+char a[12] = {0};
+// CHECK-MESSAGES-C23: :[[@LINE-1]]:14: warning: redundant zero initializer; replace with empty braces [modernize-redundant-zero-initializer]
+// CHECK-FIXES-C23: char a[12] = {};
+
+int b[5] = {0};
+// CHECK-MESSAGES-C23: :[[@LINE-1]]:12: warning: redundant zero initializer; replace with empty braces
+// CHECK-FIXES-C23: int b[5] = {};
+
+// Negatives.
----------------
vbvictor wrote:

redundant comments

https://github.com/llvm/llvm-project/pull/209367


More information about the cfe-commits mailing list