aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2023-11-06 14:28:41 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2023-11-06 14:28:41 -0500
commit579bb65cdd35a421d731b64ecc8a31064abc73a9 (patch)
treee330ce4cf9750be549b6e316200613f9d42b2658
parent7e3c58bfc1d957e48faf0752758da0fed811ed58 (diff)
downloadgcc-579bb65cdd35a421d731b64ecc8a31064abc73a9.zip
gcc-579bb65cdd35a421d731b64ecc8a31064abc73a9.tar.gz
gcc-579bb65cdd35a421d731b64ecc8a31064abc73a9.tar.bz2
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 <dmalcolm@redhat.com>
-rw-r--r--gcc/diagnostic.cc16
-rw-r--r--gcc/diagnostic.h17
2 files changed, 12 insertions, 21 deletions
diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index e917e6c..90103e1 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 cf21558..4ef031b 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) \