From: David Malcolm Date: Mon, 6 Nov 2023 19:28:41 +0000 (-0500) Subject: diagnostics: eliminate diagnostic_kind_count X-Git-Tag: basepoints/gcc-15~4973 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=579bb65cdd35a421d731b64ecc8a31064abc73a9;p=thirdparty%2Fgcc.git diagnostics: eliminate diagnostic_kind_count No functional change intended. gcc/ChangeLog: * diagnostic.cc (diagnostic_context::check_max_errors): Replace uses of diagnostic_kind_count with simple field acesss. (diagnostic_context::report_diagnostic): Likewise. (diagnostic_text_output_format::~diagnostic_text_output_format): Replace use of diagnostic_kind_count with diagnostic_context::diagnostic_count. * diagnostic.h (diagnostic_kind_count): Delete. (errorcount): Replace use of diagnostic_kind_count with diagnostic_context::diagnostic_count. (warningcount): Likewise. (werrorcount): Likewise. (sorrycount): Likewise. Signed-off-by: David Malcolm --- diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc index e917e6ce4ac7..90103e150f79 100644 --- a/gcc/diagnostic.cc +++ b/gcc/diagnostic.cc @@ -651,9 +651,9 @@ diagnostic_context::check_max_errors (bool flush) if (!m_max_errors) return; - int count = (diagnostic_kind_count (this, DK_ERROR) - + diagnostic_kind_count (this, DK_SORRY) - + diagnostic_kind_count (this, DK_WERROR)); + int count = (m_diagnostic_count[DK_ERROR] + + m_diagnostic_count[DK_SORRY] + + m_diagnostic_count[DK_WERROR]); if (count >= m_max_errors) { @@ -1547,8 +1547,8 @@ diagnostic_context::report_diagnostic (diagnostic_info *diagnostic) error has already occurred. This is counteracted by abort_on_error. */ if (!CHECKING_P - && (diagnostic_kind_count (this, DK_ERROR) > 0 - || diagnostic_kind_count (this, DK_SORRY) > 0) + && (m_diagnostic_count[DK_ERROR] > 0 + || m_diagnostic_count[DK_SORRY] > 0) && !m_abort_on_error) { expanded_location s @@ -1563,9 +1563,9 @@ diagnostic_context::report_diagnostic (diagnostic_info *diagnostic) diagnostic->message.m_args_ptr); } if (diagnostic->kind == DK_ERROR && orig_diag_kind == DK_WARNING) - ++diagnostic_kind_count (this, DK_WERROR); + ++m_diagnostic_count[DK_WERROR]; else - ++diagnostic_kind_count (this, diagnostic->kind); + ++m_diagnostic_count[diagnostic->kind]; /* Is this the initial diagnostic within the stack of groups? */ if (m_diagnostic_groups.m_emission_count == 0) @@ -2336,7 +2336,7 @@ auto_diagnostic_group::~auto_diagnostic_group () diagnostic_text_output_format::~diagnostic_text_output_format () { /* Some of the errors may actually have been warnings. */ - if (diagnostic_kind_count (&m_context, DK_WERROR)) + if (m_context.diagnostic_count (DK_WERROR)) { /* -Werror was given. */ if (m_context.warning_as_error_requested_p ()) diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index cf21558c7b2f..4ef031b5d1ca 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -701,24 +701,15 @@ extern diagnostic_context *global_dc; ready for use. */ #define diagnostic_ready_p() (global_dc->printer != NULL) -/* The total count of a KIND of diagnostics emitted so far. */ - -inline int & -diagnostic_kind_count (diagnostic_context *context, - diagnostic_t kind) -{ - return context->diagnostic_count (kind); -} - /* The number of errors that have been issued so far. Ideally, these would take a diagnostic_context as an argument. */ -#define errorcount diagnostic_kind_count (global_dc, DK_ERROR) +#define errorcount global_dc->diagnostic_count (DK_ERROR) /* Similarly, but for warnings. */ -#define warningcount diagnostic_kind_count (global_dc, DK_WARNING) +#define warningcount global_dc->diagnostic_count (DK_WARNING) /* Similarly, but for warnings promoted to errors. */ -#define werrorcount diagnostic_kind_count (global_dc, DK_WERROR) +#define werrorcount global_dc->diagnostic_count (DK_WERROR) /* Similarly, but for sorrys. */ -#define sorrycount diagnostic_kind_count (global_dc, DK_SORRY) +#define sorrycount global_dc->diagnostic_count (DK_SORRY) /* Returns nonzero if warnings should be emitted. */ #define diagnostic_report_warnings_p(DC, LOC) \