From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: [pushed 1/4] diagnostics: eliminate diagnostic_kind_count
Date: Mon, 6 Nov 2023 14:49:32 -0500 [thread overview]
Message-ID: <20231106194935.2693735-1-dmalcolm@redhat.com> (raw)
No functional change intended.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r14-5166-g579bb65cdd35a4.
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.
---
gcc/diagnostic.cc | 16 ++++++++--------
gcc/diagnostic.h | 17 ++++-------------
2 files changed, 12 insertions(+), 21 deletions(-)
diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index e917e6ce4ac..90103e150f7 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 cf21558c7b2..4ef031b5d1c 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) \
--
2.26.3
next reply other threads:[~2023-11-06 19:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-06 19:49 David Malcolm [this message]
2023-11-06 19:49 ` [pushed 2/4] diagnostics: make diagnostic_context::m_urlifier private David Malcolm
2023-11-06 19:49 ` [pushed 3/4] diagnostics: introduce class diagnostic_option_classifier David Malcolm
2023-11-06 19:49 ` [pushed 4/4] diagnostics: split out struct diagnostic_source_printing_options David Malcolm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231106194935.2693735-1-dmalcolm@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).