From patchwork Mon Nov 4 19:53:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 2006458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZeNRnJ7x; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xj2HP6L6rz1xyM for ; Tue, 5 Nov 2024 06:54:41 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8B0AC3857723 for ; Mon, 4 Nov 2024 19:54:35 +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 ESMTP id 1172D3858C2B for ; Mon, 4 Nov 2024 19:54:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1172D3858C2B 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 1172D3858C2B 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=1730750045; cv=none; b=nXfE0bt842ueNjhgN4AExoriJNqE6ODv7IGDFHUNSwF0ZsvZVhz8ZbUsZn/Ri/O15N2KnXUX+iKEuIQjytES5AISWnsnRxb4NCmCF6Ug/vsUlGWEQcLuVKKaNswTpyWGRwq7El2wZsubpVRJi1Y8gvdhl9kaJPoG+9M+78Rdgx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730750045; c=relaxed/simple; bh=L0HNquK4S1uHgotIHAMCzCl9awSo8Sp8cPDc19NnncI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=k51CICJiEM3ZjSwBNL/ULtcd6+u+hHVmZ/FmQk0pLmgx8BFaxsd+AdYHl9HCG6IRW4jpFPLgiBey/EyuMUfC4qMiDa4R/wGCnPCaUTKOva//bJFPuRRT+dmuJqsnGP0rU6Q53txNTRq7593r/9F6HlXikTdvh0EJ2pYDJXVEGUk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730750041; 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=torHdVBEWnz1liT28Y+vuE5k/CSvA+wxUISIWoxUXhc=; b=ZeNRnJ7xqpYmR55uBht9C5D8OIun+7HKWvhiszunW+8VkqFM5G3YyqBc3USLT0vto/crp7 UCfOKz2sAau/RWbEZpU4AjzJo/DJa7/MJ5Fxzfrwc/pPiVVRyInsj8ovkHLW7/v33DjDJJ epkyuLsQ69jr6R16mjk1xERuAtTRY28= 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-517-OCx8z0C3NLa0JZaNotGVbw-1; Mon, 04 Nov 2024 14:54:00 -0500 X-MC-Unique: OCx8z0C3NLa0JZaNotGVbw-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 9098C1955F45 for ; Mon, 4 Nov 2024 19:53:59 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.88.51]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 97CE1300018D; Mon, 4 Nov 2024 19:53:58 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed: r15-4935] diagnostics: update leading comment for class diagnostic_context Date: Mon, 4 Nov 2024 14:53:56 -0500 Message-ID: <20241104195356.2889615-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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~incoming=patchwork.ozlabs.org@gcc.gnu.org No functional change intended. Pushed to trunk as r15-4935-gb8ac365db7fac9. gcc/ChangeLog: * diagnostic.h (class diagnostic_context): Update leading comment. Signed-off-by: David Malcolm --- gcc/diagnostic.h | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 46478c9a52b7..a0056b41b2df 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -475,8 +475,39 @@ struct diagnostic_counters int m_count_for_kind[DK_LAST_DIAGNOSTIC_KIND]; }; -/* This data structure bundles altogether any information relevant to - the context of a diagnostic message. */ +/* This class encapsulates the state of the diagnostics subsystem + as a whole (either directly, or via owned objects of other classes, to + avoid global variables). + + It has responsibility for: + - being a central place for clients to report diagnostics + - reporting those diagnostics to zero or more output sinks + (e.g. text vs SARIF) + - proving a "dump" member function for a debug dump of the state of + the diagnostics subsytem + - direct vs buffered diagnostics (see class diagnostic_buffer) + - tracking the original argv of the program (for SARIF output) + - crash-handling + + It delegates responsibility to various other classes: + - the various output sinks (instances of diagnostic_output_format + subclasses) + - formatting of messages (class pretty_printer) + - an optional urlifier to inject URLs into formatted messages + - counting the number of diagnostics reported of each kind + (class diagnostic_counters) + - calling out to a diagnostic_option_manager to determine if + a particular warning is enabled or disabled + - tracking pragmas that enable/disable warnings in a range of + source code + - a cache for use when quoting the user's source code (class file_cache) + - a text_art::theme + - an edit_context for generating patches from fix-it hints + - diagnostic_client_data_hooks for metadata. + + Try to avoid adding new responsibilities to this class itself, to avoid + the "blob" anti-pattern. */ + class diagnostic_context { public: