[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
Sun Apr 20 11:45:51 PDT 2025
================
@@ -122,7 +122,10 @@ void UseDesignatedInitializersCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
initListExpr(
hasType(cxxRecordDecl(RestrictToPODTypes ? isPOD() : isAggregate(),
- unless(HasBaseWithFields))
+ unless(anyOf(HasBaseWithFields,
+ IgnoreSingleElementAggregates
+ ? hasName("::std::array")
----------------
carlosgalvezp wrote:
The condition seem wrong? "If `IgnoreSingleElementAggregates` is true, then ignore `std::array`. Shouldn't it be the other way around?
Regardless, I believe we want to always ignore `std::array`, regardless of `IgnoreSingleElementAggregates`, since the private member is never intended to be used by the caller.
So I would just simplify to `unless(anyOf(HasBaseWithFields, hasName("::std::array")))
https://github.com/llvm/llvm-project/pull/134774
More information about the cfe-commits
mailing list