[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:20 PDT 2026


================
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "RedundantZeroInitializerCheck.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
+namespace {
+// Matches an explicitly written ``{<single element>}`` list. ``isExplicit()``
+// excludes compiler-synthesized subobject lists (e.g. from brace elision in a
+// multi-dimensional array), which are not written with braces in the source.
+AST_MATCHER(InitListExpr, isSingleElementBracedList) {
+  return Node.isExplicit() && Node.getNumInits() == 1;
+}
+
+// Matches an initializer list inside a macro expansion.
----------------
vbvictor wrote:

Remove redundant obvious comments

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


More information about the cfe-commits mailing list