diff mbox series

[pushed:,r15-4935] diagnostics: update leading comment for class diagnostic_context

Message ID 20241104195356.2889615-1-dmalcolm@redhat.com
State New
Headers show
Series [pushed:,r15-4935] diagnostics: update leading comment for class diagnostic_context | expand

Commit Message

David Malcolm Nov. 4, 2024, 7:53 p.m. UTC
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 <dmalcolm@redhat.com>
---
 gcc/diagnostic.h | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)
diff mbox series

Patch

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: