From patchwork Mon Nov 6 19:49:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 162153 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2890518vqu; Mon, 6 Nov 2023 11:50:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJIgAiAV6eyUfIFV7lY5RXWS0HsJhEiwKRLlUa1EsUVxziGTjpZB4rcRikNmy1X93nHXFX X-Received: by 2002:a05:622a:7:b0:41e:24f6:d4d3 with SMTP id x7-20020a05622a000700b0041e24f6d4d3mr31283501qtw.58.1699300206631; Mon, 06 Nov 2023 11:50:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699300206; cv=pass; d=google.com; s=arc-20160816; b=ipQOVPh01WJU/n+dCuyBwnAU7DGbBvHW3rrlVfejCIBLISnp8bwUfffBPsY+NtIxkV 102kjo05UxtASeiX+F8orWUxo5XtNtasLDmPWAvBKgRDMPfq54Ceh9YbwbiAPeA2SN9z Dwy2gfVFAUL9yIlIByfWn8FU9KFxZ5QaKZT/FhVcAhBbX60CeO3b6QmmKkWvZBDB6qmN ndzP45tYl0dWBH0VJ5HfJw/l97nhIfs0Htdu+iblBddAqQzYq+a+UIZsAGqbrlnhE+a7 gOwEV6QJXA2h8oH9qtQwUzKzlox45Ee/uV11q3f6Mo/3m/yWr7p4XAl4HY7kIyEqhcZW OgSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=ysWW20/+abTGRybz84jJpLhK6ZGoAcuqiECqawsw5ds=; fh=NXemEfxTRbZtBxUkxR2ehQUaYlcDfMdzPkO8MChVQE4=; b=TCDKkQgBEb19Kz8JH3tAS9FanU38TixkS7JQDyHKne37xybOLtLA+VWZpnAaFna0n0 +GpLc3NnRGLz8rgzm8/tDydB5/V20nV0e1VMpuM9WpdUZ5csPEk7NT3ZVtlm06f43lM/ Mus8Ick8QDBByMw0i3wpzdKaCsYCw2Df8RE4Y2wh7UKXm9ewaYzJngilLQVbzCHLcNi0 4K5oDnSrzD17DhVbVWyblJXplwBHzogGW6DH62IIddemtPYTN5wIHg+1B9Kr5ZzSsvSm jyQmolWDToqvoikE7Hri9qPOunlSP2xUKa+sgf47aMYLuvvRJj1MEeKHgRx7g3AKgDAZ 3hdQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b6JrxH7B; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w12-20020a05622a134c00b00419661ee8efsi5626639qtk.86.2023.11.06.11.50.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 11:50:06 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b6JrxH7B; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EC0AA3857030 for ; Mon, 6 Nov 2023 19:50:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id B06043858C2C for ; Mon, 6 Nov 2023 19:49:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B06043858C2C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B06043858C2C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699300181; cv=none; b=PLaGxFbqCrgqphRbRQWkICDG9Yn/7shqBxFJ3KP+6UU7+xYqG5wYEixR1JQPHQKEw+TQaQDbMpi1kjHvWp+MbVBVDLUFU+qUuLk0U/ECTLBPm25rn+6HBVa6Oh0E6pnqsS8S5WaNV/MkMPPt3xygX0juRm0zMpv0IuQfAIHQIx4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699300181; c=relaxed/simple; bh=kqpXlBVzOdC4U+PffhsdzcTj14Njgbag8D++De+T6jU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=SJ2knJVbhkDKSr1xkQnxKCxHCh7LqEpaMFvFAFrywhcxsArp0HOp+n+BGtZuQG74ISAQejFeL74yKGLkrLlcqjm/I9rurNOdaenzF2qf3e+G16Sqg56TzL9go1vMzxzSMI5egJ4uiZy8Gfai/972kLh5yYhOJRlF72G2D0yHCIc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699300180; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ysWW20/+abTGRybz84jJpLhK6ZGoAcuqiECqawsw5ds=; b=b6JrxH7BNHGwxDHPtqqIIPO9zUaxTswmAOIek19mKGs6j+HzFBQMHNFM+jpy3NzmnT7Sbb PU9/iLQMRTkNdscLQENdHZah/BHkn6zD2qTMXhhPP+WAB0ecx1ThvvllNV4gXdkjucO1pk ejVfmrBLozZ9Sqxs5Ee+XVVXc6RagV4= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-TTJPrZwCPvuuL3nqphrGcw-1; Mon, 06 Nov 2023 14:49:38 -0500 X-MC-Unique: TTJPrZwCPvuuL3nqphrGcw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 14FD82808FE0 for ; Mon, 6 Nov 2023 19:49:38 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.8.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id E47AC25C0; Mon, 6 Nov 2023 19:49:37 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed 1/4] diagnostics: eliminate diagnostic_kind_count Date: Mon, 6 Nov 2023 14:49:32 -0500 Message-Id: <20231106194935.2693735-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781845413672785867 X-GMAIL-MSGID: 1781845413672785867 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) \