[clang-tools-extra] [clang-tidy] Avoid diagnosing std::array initializations for modernize-use-designated-initializers (PR #134774)

Carlos Galvez via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 9 11:59:11 PDT 2025


================
@@ -119,13 +119,18 @@ UseDesignatedInitializersCheck::UseDesignatedInitializersCheck(
 void UseDesignatedInitializersCheck::registerMatchers(MatchFinder *Finder) {
   const auto HasBaseWithFields =
       hasAnyBase(hasType(cxxRecordDecl(has(fieldDecl()))));
+
+  // see #133715
+  const auto IsSTLArray =
+      hasType(qualType(hasDeclaration(recordDecl(hasName("::std::array")))));
+
   Finder->addMatcher(
       initListExpr(
           hasType(cxxRecordDecl(RestrictToPODTypes ? isPOD() : isAggregate(),
                                 unless(HasBaseWithFields))
----------------
carlosgalvezp wrote:

Shouldn't we put the condition here instead? Since we already are inside a cxxRecordDecl, we can just check the `hasName` in it?

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


More information about the cfe-commits mailing list