From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 61A3E3882AFE for ; Tue, 18 Jun 2024 15:08:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 61A3E3882AFE 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 61A3E3882AFE 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=1718723317; cv=none; b=EMP20/obZ9g+UmohyIJTYbJxgjmT3Ige2hF6Ra4jKA8AGieuJiAEDshvfMtiQJWANLsLUrzR3z5xmRewDXWFyN4reaaN+bNn1jKO8rMwzlJx4ppney+ruFQXzkfTWf+R40l5yW/ja5wB9MvPy9Zkz2PSvvaVCc1zu/urAA+zEvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718723317; c=relaxed/simple; bh=UqrOojjFZCPy3IJskksINzqXjT/0uaBP6jrsUk3D4v4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=oa8JhsDSF80oCb8UVsxZsM7gvNAAQIFKT6nulyxuyd6Z5QANpIAi7MgUJI6Swl0cLzGNX7Mqg6oQFXclg6I7RU/olZo2OrWnhZuzmUkCf28EoulpwYOusp+HNMpCBk3SoA0igSMu/Y3YxTuGMi5L6Nt9EvDeuRjSPcAyIQHeDAY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718723313; 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: in-reply-to:in-reply-to:references:references; bh=yjejPzfqbnXtlvmXhbRfDeddKu/A1FwrL1ux5XOar0g=; b=QLTOAwcQFZY1Yq25zdnmFbkU9FE/eLfrhz5//xIFnIms8o7oCCoWhMiEEQxVFyep2ba5WK G6TRlpecGJ2ZxguJiqEqdy8yLWhj3fmPfB0pNDiDte3WRRaDjs3d7PLYXLkSOnk25jBVZc Q4sYUsMdVwQWZcyEfDsUHIJcbdvTueg= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-368-CbVdBHBEN3qcZ2HxBeIssQ-1; Tue, 18 Jun 2024 11:08:30 -0400 X-MC-Unique: CbVdBHBEN3qcZ2HxBeIssQ-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BBA2C19560BD for ; Tue, 18 Jun 2024 15:08:29 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.10.107]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 019211956052; Tue, 18 Jun 2024 15:08:28 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 6/7] diagnostics: eliminate diagnostic_context::m_print_path callback Date: Tue, 18 Jun 2024 11:08:18 -0400 Message-Id: <20240618150819.946820-7-dmalcolm@redhat.com> In-Reply-To: <20240618150819.946820-1-dmalcolm@redhat.com> References: <20240618150819.946820-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.4 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,RCVD_IN_SBL_CSS,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 List-Id: No functional change intended. gcc/ChangeLog: * diagnostic-format-json.cc (diagnostic_output_format_init_json): Replace clearing of diagnostic_context::m_print_path callback with setting the path format to DPF_NONE. * diagnostic-format-sarif.cc (diagnostic_output_format_init_sarif): Likewise. * diagnostic.cc (diagnostic_context::show_any_path): Replace call to diagnostic_context::m_print_path callback with a direct call to diagnostic_context::print_path. * diagnostic.h (diagnostic_context::print_path): New decl. (diagnostic_context::m_print_path): Delete callback. * tree-diagnostic-path.cc (default_tree_diagnostic_path_printer): Convert to... (diagnostic_context::print_path): ...this. * tree-diagnostic.cc (tree_diagnostics_defaults): Delete initialization of m_print_path. * tree-diagnostic.h (default_tree_diagnostic_path_printer): Delete decl. Signed-off-by: David Malcolm --- gcc/diagnostic-format-json.cc | 4 ++-- gcc/diagnostic-format-sarif.cc | 4 +++- gcc/diagnostic.cc | 3 +-- gcc/diagnostic.h | 4 ++-- gcc/tree-diagnostic-path.cc | 23 +++++++++++------------ gcc/tree-diagnostic.cc | 1 - gcc/tree-diagnostic.h | 3 --- 7 files changed, 19 insertions(+), 23 deletions(-) diff --git a/gcc/diagnostic-format-json.cc b/gcc/diagnostic-format-json.cc index 2bdc2c13d37..ec03ac15aeb 100644 --- a/gcc/diagnostic-format-json.cc +++ b/gcc/diagnostic-format-json.cc @@ -395,8 +395,8 @@ private: static void diagnostic_output_format_init_json (diagnostic_context *context) { - /* Override callbacks. */ - context->m_print_path = nullptr; /* handled in json_end_diagnostic. */ + /* Suppress normal textual path output. */ + context->set_path_format (DPF_NONE); /* The metadata is handled in JSON format, rather than as text. */ context->set_show_cwe (false); diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc index 79116f051bc..5f438dd38a8 100644 --- a/gcc/diagnostic-format-sarif.cc +++ b/gcc/diagnostic-format-sarif.cc @@ -1991,8 +1991,10 @@ private: static void diagnostic_output_format_init_sarif (diagnostic_context *context) { + /* Suppress normal textual path output. */ + context->set_path_format (DPF_NONE); + /* Override callbacks. */ - context->m_print_path = nullptr; /* handled in sarif_end_diagnostic. */ context->set_ice_handler_callback (sarif_ice_handler); /* The metadata is handled in SARIF format, rather than as text. */ diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc index 844eb8e1048..471135f16de 100644 --- a/gcc/diagnostic.cc +++ b/gcc/diagnostic.cc @@ -915,8 +915,7 @@ diagnostic_context::show_any_path (const diagnostic_info &diagnostic) if (!path) return; - if (m_print_path) - m_print_path (this, path); + print_path (path); } /* class diagnostic_event. */ diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index ff2aa3dd9a3..c6846525da3 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -583,6 +583,8 @@ private: pretty_printer *pp, diagnostic_source_effect_info *effect_info); + void print_path (const diagnostic_path *path); + /* Data members. Ideally, all of these would be private and have "m_" prefixes. */ @@ -712,8 +714,6 @@ private: urlifier *m_urlifier; public: - void (*m_print_path) (diagnostic_context *, const diagnostic_path *); - /* Auxiliary data for client. */ void *m_client_aux_data; diff --git a/gcc/tree-diagnostic-path.cc b/gcc/tree-diagnostic-path.cc index adaaf30b84f..35f8ea2b8b6 100644 --- a/gcc/tree-diagnostic-path.cc +++ b/gcc/tree-diagnostic-path.cc @@ -884,17 +884,16 @@ print_path_summary_as_text (const path_summary *ps, diagnostic_context *dc, } /* end of anonymous namespace for path-printing code. */ -/* Print PATH to CONTEXT, according to CONTEXT's path_format. */ +/* Print PATH according to this context's path_format. */ void -default_tree_diagnostic_path_printer (diagnostic_context *context, - const diagnostic_path *path) +diagnostic_context::print_path (const diagnostic_path *path) { gcc_assert (path); const unsigned num_events = path->num_events (); - switch (context->get_path_format ()) + switch (get_path_format ()) { case DPF_NONE: /* Do nothing. */ @@ -909,7 +908,7 @@ default_tree_diagnostic_path_printer (diagnostic_context *context, label_text event_text (event.get_desc (false)); gcc_assert (event_text.get ()); diagnostic_event_id_t event_id (i); - if (context->show_path_depths_p ()) + if (this->show_path_depths_p ()) { int stack_depth = event.get_stack_depth (); /* -fdiagnostics-path-format=separate-events doesn't print @@ -941,13 +940,13 @@ default_tree_diagnostic_path_printer (diagnostic_context *context, { /* Consolidate related events. */ path_summary summary (*path, true, - context->m_source_printing.show_event_links_p); - char *saved_prefix = pp_take_prefix (context->printer); - pp_set_prefix (context->printer, NULL); - print_path_summary_as_text (&summary, context, - context->show_path_depths_p ()); - pp_flush (context->printer); - pp_set_prefix (context->printer, saved_prefix); + m_source_printing.show_event_links_p); + char *saved_prefix = pp_take_prefix (this->printer); + pp_set_prefix (this->printer, NULL); + print_path_summary_as_text (&summary, this, + show_path_depths_p ()); + pp_flush (this->printer); + pp_set_prefix (this->printer, saved_prefix); } break; } diff --git a/gcc/tree-diagnostic.cc b/gcc/tree-diagnostic.cc index f236f3db0b2..fc78231dfa4 100644 --- a/gcc/tree-diagnostic.cc +++ b/gcc/tree-diagnostic.cc @@ -179,7 +179,6 @@ tree_diagnostics_defaults (diagnostic_context *context) diagnostic_starter (context) = default_tree_diagnostic_starter; diagnostic_finalizer (context) = default_diagnostic_finalizer; diagnostic_format_decoder (context) = default_tree_printer; - context->m_print_path = default_tree_diagnostic_path_printer; context->set_set_locations_callback (set_inlining_locations); context->set_client_data_hooks (make_compiler_data_hooks ()); } diff --git a/gcc/tree-diagnostic.h b/gcc/tree-diagnostic.h index 648d6e6ab91..6ebac381ace 100644 --- a/gcc/tree-diagnostic.h +++ b/gcc/tree-diagnostic.h @@ -55,7 +55,4 @@ void tree_diagnostics_defaults (diagnostic_context *context); bool default_tree_printer (pretty_printer *, text_info *, const char *, int, bool, bool, bool, bool *, const char **); -extern void default_tree_diagnostic_path_printer (diagnostic_context *, - const diagnostic_path *); - #endif /* ! GCC_TREE_DIAGNOSTIC_H */ -- 2.26.3