From cb9460988970ed984af69089cce5f2c6fef547c3 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 18 Nov 2024 11:38:46 -0500 Subject: [PATCH] Suppress readability-redundant-member-init (#4538) This initializes the DriverResult::per_file_success field explicitly with `= {}` in order to encode that DriverResult can be constucted via aggregate initialization while omitting the per_file_success field. This prevents -Wmissing-designated-field-initializers from firing in newer clang versions when constructing DriverResult like: ``` return {.success = false}; ``` Newer clang-tidy warns that the `= {}` is redundant however it is not, as its marking which fields need to be explicitly initialized. So we suppress it. --- .clang-tidy | 5 ++++- toolchain/driver/driver_subcommand.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 1e2cd556f8af..92a7b199da44 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -48,6 +48,9 @@ WarningsAsErrors: '*' # explicit value. # - `readability-function-cognitive-complexity` warns too frequently. # - `readability-magic-numbers` warns in reasonably documented situations. +# - `readability-redundant-member-init` warns on `= {}` which is also used to +# indicate which fields do not need to be explicitly initialized in aggregate +# initialization. # - `readability-suspicious-call-argument` warns when callers use similar names # as different parameters. # @@ -80,7 +83,7 @@ Checks: -readability-else-after-return, -readability-enum-initial-value, -readability-function-cognitive-complexity, -readability-identifier-length, -readability-implicit-bool-conversion, -readability-magic-numbers, - -readability-make-member-function-const, + -readability-make-member-function-const, -readability-redundant-member-init, -readability-static-definition-in-anonymous-namespace, -readability-suspicious-call-argument, -readability-use-anyofallof CheckOptions: diff --git a/toolchain/driver/driver_subcommand.h b/toolchain/driver/driver_subcommand.h index de31584234d0..9c90f9594157 100644 --- a/toolchain/driver/driver_subcommand.h +++ b/toolchain/driver/driver_subcommand.h @@ -20,7 +20,7 @@ struct DriverResult { // Per-file success results. May be empty if files aren't individually // processed. - llvm::SmallVector> per_file_success; + llvm::SmallVector> per_file_success = {}; }; // A subcommand for the driver.