From patchwork Tue Nov 14 19:13:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 165057 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a59:b0:164:83eb:24d7 with SMTP id 25csp2144211rwb; Tue, 14 Nov 2023 11:13:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEyGIWxZAnzSXYguz/dMmRycrFvAFjV1JcJZIb1fksKxi3NlAsXxhYhO9ral9i1cU5DFoTN X-Received: by 2002:a05:620a:2941:b0:775:6785:3051 with SMTP id n1-20020a05620a294100b0077567853051mr4078580qkp.50.1699989223429; Tue, 14 Nov 2023 11:13:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699989223; cv=pass; d=google.com; s=arc-20160816; b=onpJSziPJO5qpukR45SSMLrEJYBSxbyCLYwwlYl+LKDCpDuxwZ9t6Mi02+9h3iFk5L XS/eRLwFwgKQxxNgfn9+ukpr3FKni7cjG89vIiCpgELC12zjg8K8ls8oYzd8iHeZUveK Yw/FCQu7W084wIJXYppWa1XhWdRhIOYKQrjhdmR2w3iSJ16HqTo/ALm3zrf3ojWVlQwj DkZjqS9EABRsHpYKa4E1VwQfNmJp6l74NGW1hetAHugdik0jHoV/Og4yAHOMoK7mNW7w haHxYAwWzUf9ckloKXiQS0bwfl0F7UFVXtud7GIJQ5b6deBcVeZg3gNHP+1jRR0qq4hZ VlNg== 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=0rR6PyUxBXR236wf5/tgXHiYLNCkTq0j6svC5uMlOz4=; fh=NXemEfxTRbZtBxUkxR2ehQUaYlcDfMdzPkO8MChVQE4=; b=oxZns/g2L2nkyGes8Ub5AsQjNJdiMAEqgI2jFZPD5jGxSvz8Y7L0FlSjmjoyvrin/+ MPyCRN7y/z5nDiIEtyRU7Avpr5sPZo2b5o8Wa4+VjQwPZEP5bbq0NH3x65F3b3bFupzY RINEb9cxebfkMIC0z4wlAAGDVwRsEyHvkxMyRjUSahcaT71jPdaWAeVOe59aWJ+/nIrq 2ZDa1hYa2k8TWW5CA4eSTOarJqx5P9NPu75KJTObeYOOzXc6+++cpjiE/LjsdnisSogX nmoNDd9iEzMf8abnMjVPrLo2gjDcAbPO3dFnWCky7IjfjejUC8uOxBhd3NeBVq7CjPzT J1HQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AK6F48Ec; 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 dl6-20020a05620a1d0600b0077419b27787si7641276qkb.177.2023.11.14.11.13.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 11:13:43 -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=AK6F48Ec; 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 B27DD385840D for ; Tue, 14 Nov 2023 19:13:41 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id EA2F53858409 for ; Tue, 14 Nov 2023 19:13:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EA2F53858409 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 EA2F53858409 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699989198; cv=none; b=LyY/vN9BlOXmGDFAtI8rB5S2GIdZ5ZyV/bg4Qt/g22XJDYV3yOj/mqJeWz2D9hJ2PT1lEr1HV99s5EmimV6uWUyPCA325bOqo0aesvuaykxtBxdwsubap6zSynWFw4p8dOt4E3Unuu28iWzi4JEVLTskNhdP+JxeL9+Yl49hIRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699989198; c=relaxed/simple; bh=z5sBVDjbCzWjL/1aeUTHL3lNq58nZItcRdFexCDLE0I=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=X4QSUkaIu9Om8joJJZZ9DapPwSTe32XnHYdTUGRMuZEKwswcAR3NpLZW3TOqxkWNlEwPsSG/8qNWxrGFwDg1q5yZbCa8f8ot3Ustb3EljdcVbeqdYlW+G+oUeLXRrpYPE48PwooZN/CvmxWtsY3rMdG6YKKEPViubD23dVihJh8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699989196; 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=0rR6PyUxBXR236wf5/tgXHiYLNCkTq0j6svC5uMlOz4=; b=AK6F48EcYBbPxHVdI2noS92/SWUlDOPVaOtMo+zbotIm6YWfm4cD/AaiURGyryPCS3+Hp5 e/hZnRKX54KpbIi2/N7jaL02prhLUjStIXaSzCyRpCB94eDyBrCKAOcL3TTM+DD96/i+9H tIxcw6xc5AXIvelqCVMxfdXZrYDqeo4= 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-241-2WafzGaPPguo-vjuAN2G5A-1; Tue, 14 Nov 2023 14:13:15 -0500 X-MC-Unique: 2WafzGaPPguo-vjuAN2G5A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 D3E593C0009E for ; Tue, 14 Nov 2023 19:13:14 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.10.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id A90BC1121306; Tue, 14 Nov 2023 19:13:14 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed] diagnostics: make m_text_callbacks private Date: Tue, 14 Nov 2023 14:13:13 -0500 Message-Id: <20231114191313.3709388-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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_H4, 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: 1782567899693324663 X-GMAIL-MSGID: 1782567899693324663 No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-5458-g07e568d77f364e. gcc/ChangeLog: * diagnostic-show-locus.cc (diagnostic_context::show_locus): Update for renaming of text callbacks fields. * diagnostic.cc (diagnostic_context::initialize): Likewise. * diagnostic.h (class diagnostic_context): Add "friend" for accessors to m_text_callbacks. (diagnostic_context::m_text_callbacks): Make private, and add an "m_" prefix to field names. (diagnostic_starter): Convert from macro to inline function. (diagnostic_start_span): New. (diagnostic_finalizer): Convert from macro to inline function. gcc/fortran/ChangeLog: * error.cc (gfc_diagnostics_init): Use diagnostic_start_span. gcc/ChangeLog: * selftest-diagnostic.cc (test_diagnostic_context::test_diagnostic_context): Use diagnostic_start_span. * tree-diagnostic-path.cc (struct event_range): Likewise. gcc/testsuite: * gcc.dg/plugin/diagnostic_group_plugin.c: Use diagnostic_start_span. --- gcc/diagnostic-show-locus.cc | 2 +- gcc/diagnostic.cc | 6 +-- gcc/diagnostic.h | 37 ++++++++++++++++--- gcc/fortran/error.cc | 2 +- gcc/selftest-diagnostic.cc | 2 +- .../gcc.dg/plugin/diagnostic_group_plugin.c | 2 +- gcc/tree-diagnostic-path.cc | 2 +- 7 files changed, 39 insertions(+), 14 deletions(-) diff --git a/gcc/diagnostic-show-locus.cc b/gcc/diagnostic-show-locus.cc index 169f59cb0573..563d2826f249 100644 --- a/gcc/diagnostic-show-locus.cc +++ b/gcc/diagnostic-show-locus.cc @@ -2904,7 +2904,7 @@ diagnostic_context::show_locus (const rich_location &richloc, { expanded_location exploc = layout.get_expanded_location (line_span); - m_text_callbacks.start_span (this, exploc); + m_text_callbacks.m_start_span (this, exploc); } } /* Iterate over the lines within this span (using linenum_arith_t to diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc index 24212b9668eb..ccca2d2150f7 100644 --- a/gcc/diagnostic.cc +++ b/gcc/diagnostic.cc @@ -235,9 +235,9 @@ diagnostic_context::initialize (int n_opts) m_warn_system_headers = false; m_max_errors = 0; m_internal_error = nullptr; - m_text_callbacks.begin_diagnostic = default_diagnostic_starter; - m_text_callbacks.start_span = default_diagnostic_start_span_fn; - m_text_callbacks.end_diagnostic = default_diagnostic_finalizer; + m_text_callbacks.m_begin_diagnostic = default_diagnostic_starter; + m_text_callbacks.m_start_span = default_diagnostic_start_span_fn; + m_text_callbacks.m_end_diagnostic = default_diagnostic_finalizer; m_option_enabled = nullptr; m_option_state = nullptr; m_option_name = nullptr; diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 2489855ae4a4..57c5ed4f582a 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -352,6 +352,14 @@ struct diagnostic_source_printing_options class diagnostic_context { public: + /* Give access to m_text_callbacks. */ + friend diagnostic_starter_fn & + diagnostic_starter (diagnostic_context *context); + friend diagnostic_start_span_fn & + diagnostic_start_span (diagnostic_context *context); + friend diagnostic_finalizer_fn & + diagnostic_finalizer (diagnostic_context *context); + typedef void (*ice_handler_callback_t) (diagnostic_context *); typedef void (*set_locations_callback_t) (diagnostic_context *, diagnostic_info *); @@ -574,7 +582,6 @@ private: /* Maximum number of errors to report. */ int m_max_errors; -public: /* Client-supplied callbacks for use in text output. */ struct { /* This function is called before any message is printed out. It is @@ -584,17 +591,18 @@ public: from "/home/gdr/src/nifty_printer.h:56: ... */ - diagnostic_starter_fn begin_diagnostic; + diagnostic_starter_fn m_begin_diagnostic; /* This function is called by diagnostic_show_locus in between disjoint spans of source code, so that the context can print something to indicate that a new span of source code has begun. */ - diagnostic_start_span_fn start_span; + diagnostic_start_span_fn m_start_span; /* This function is called after the diagnostic message is printed. */ - diagnostic_finalizer_fn end_diagnostic; + diagnostic_finalizer_fn m_end_diagnostic; } m_text_callbacks; +public: /* Client hook to report an internal error. */ void (*m_internal_error) (diagnostic_context *, const char *, va_list *); @@ -734,11 +742,28 @@ diagnostic_inhibit_notes (diagnostic_context * context) /* Client supplied function to announce a diagnostic (for text-based diagnostic output). */ -#define diagnostic_starter(DC) (DC)->m_text_callbacks.begin_diagnostic +inline diagnostic_starter_fn & +diagnostic_starter (diagnostic_context *context) +{ + return context->m_text_callbacks.m_begin_diagnostic; +} + +/* Client supplied function called between disjoint spans of source code, + so that the context can print + something to indicate that a new span of source code has begun. */ +inline diagnostic_start_span_fn & +diagnostic_start_span (diagnostic_context *context) +{ + return context->m_text_callbacks.m_start_span; +} /* Client supplied function called after a diagnostic message is displayed (for text-based diagnostic output). */ -#define diagnostic_finalizer(DC) (DC)->m_text_callbacks.end_diagnostic +inline diagnostic_finalizer_fn & +diagnostic_finalizer (diagnostic_context *context) +{ + return context->m_text_callbacks.m_end_diagnostic; +} /* Extension hooks for client. */ #define diagnostic_context_auxiliary_data(DC) (DC)->m_client_aux_data diff --git a/gcc/fortran/error.cc b/gcc/fortran/error.cc index ca31775c2dc3..2ac51e95e4da 100644 --- a/gcc/fortran/error.cc +++ b/gcc/fortran/error.cc @@ -1637,7 +1637,7 @@ void gfc_diagnostics_init (void) { diagnostic_starter (global_dc) = gfc_diagnostic_starter; - global_dc->m_text_callbacks.start_span = gfc_diagnostic_start_span; + diagnostic_start_span (global_dc) = gfc_diagnostic_start_span; diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer; diagnostic_format_decoder (global_dc) = gfc_format_decoder; global_dc->m_source_printing.caret_chars[0] = '1'; diff --git a/gcc/selftest-diagnostic.cc b/gcc/selftest-diagnostic.cc index 37e98ed33047..f9a1852f7680 100644 --- a/gcc/selftest-diagnostic.cc +++ b/gcc/selftest-diagnostic.cc @@ -39,7 +39,7 @@ test_diagnostic_context::test_diagnostic_context () m_source_printing.enabled = true; m_source_printing.show_labels_p = true; m_show_column = true; - m_text_callbacks.start_span = start_span_cb; + diagnostic_start_span (this) = start_span_cb; m_source_printing.min_margin_width = 6; m_source_printing.max_width = 80; } diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c index e8903ba6ee32..ce0b3225dfca 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c @@ -224,7 +224,7 @@ plugin_init (struct plugin_name_args *plugin_info, return 1; diagnostic_starter (global_dc) = test_diagnostic_starter; - global_dc->m_text_callbacks.start_span = test_diagnostic_start_span_fn; + diagnostic_start_span (global_dc) = test_diagnostic_start_span_fn; global_dc->set_output_format (new test_output_format (*global_dc)); pass_info.pass = new pass_test_groups (g); diff --git a/gcc/tree-diagnostic-path.cc b/gcc/tree-diagnostic-path.cc index d2345c8dae74..3cd9c210feaa 100644 --- a/gcc/tree-diagnostic-path.cc +++ b/gcc/tree-diagnostic-path.cc @@ -206,7 +206,7 @@ struct event_range = linemap_client_expand_location_to_spelling_point (line_table, initial_loc, LOCATION_ASPECT_CARET); if (exploc.file != LOCATION_FILE (dc->m_last_location)) - dc->m_text_callbacks.start_span (dc, exploc); + diagnostic_start_span (dc) (dc, exploc); } /* If we have an UNKNOWN_LOCATION (or BUILTINS_LOCATION) as the