GCC Middle and Back End API Reference
diagnostic.h
Go to the documentation of this file.
1/* Various declarations for language-independent diagnostics subroutines.
2 Copyright (C) 2000-2025 Free Software Foundation, Inc.
3 Contributed by Gabriel Dos Reis <gdr@codesourcery.com>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_DIAGNOSTIC_H
22#define GCC_DIAGNOSTIC_H
23
24#include "unique-argv.h"
25#include "rich-location.h"
26#include "pretty-print.h"
27#include "diagnostic-core.h"
28
29namespace text_art
30{
31 class theme;
32} // namespace text_art
33
34/* An enum for controlling what units to use for the column number
35 when diagnostics are output, used by the -fdiagnostics-column-unit option.
36 Tabs will be expanded or not according to the value of -ftabstop. The origin
37 (default 1) is controlled by -fdiagnostics-column-origin. */
38
40{
41 /* The default from GCC 11 onwards: display columns. */
43
44 /* The behavior in GCC 10 and earlier: simple bytes. */
46};
47
48/* An enum for controlling how to print non-ASCII characters/bytes when
49 a diagnostic suggests escaping the source code on output. */
50
52{
53 /* Escape non-ASCII Unicode characters in the form <U+XXXX> and
54 non-UTF-8 bytes in the form <XX>. */
56
57 /* Escape non-ASCII bytes in the form <XX> (thus showing the underlying
58 encoding of non-ASCII Unicode characters). */
60};
61
62/* Enum for overriding the standard output format. */
63
65{
66 /* The default: textual output. */
68
69 /* JSON-based output, to stderr. */
71
72 /* JSON-based output, to a file. */
74
75 /* SARIF-based output, as JSON to stderr. */
77
78 /* SARIF-based output, to a JSON file. */
80};
81
82/* An enum for controlling how diagnostic_paths should be printed. */
84{
85 /* Don't print diagnostic_paths. */
87
88 /* Print diagnostic_paths by emitting a separate "note" for every event
89 in the path. */
91
92 /* Print diagnostic_paths by consolidating events together where they
93 are close enough, and printing such runs of events with multiple
94 calls to diagnostic_show_locus, showing the individual events in
95 each run via labels in the source. */
97};
98
99/* An enum for capturing values of GCC_EXTRA_DIAGNOSTIC_OUTPUT,
100 and for -fdiagnostics-parseable-fixits. */
101
103{
104 /* No extra output, or an unrecognized value. */
106
107 /* Emit fix-it hints using the "fixits-v1" format, equivalent to
108 -fdiagnostics-parseable-fixits. */
110
111 /* Emit fix-it hints using the "fixits-v2" format. */
113};
114
115/* Values for -fdiagnostics-text-art-charset=. */
116
118{
119 /* No text art diagrams shall be emitted. */
121
122 /* Use pure ASCII for text art diagrams. */
124
125 /* Use ASCII + conservative use of other unicode characters
126 in text art diagrams. */
128
129 /* Use Emoji. */
131};
132
133/* A diagnostic is described by the MESSAGE to send, the FILE and LINE of
134 its context and its KIND (ice, error, warning, note, ...) See complete
135 list in diagnostic.def. */
137{
139 : message (), richloc (), metadata (), x_data (), kind (), option_id (),
140 m_iinfo ()
141 { }
142
143 /* Text to be formatted. */
145
146 /* The location at which the diagnostic is to be reported. */
147 rich_location *richloc;
148
149 /* An optional bundle of metadata associated with the diagnostic
150 (or NULL). */
152
153 /* Auxiliary data for client. */
154 void *x_data;
155 /* The kind of diagnostic it is about. */
157 /* Which OPT_* directly controls this diagnostic. */
159
160 /* Inlining context containing locations for each call site along
161 the inlining stack. */
163 {
164 /* Locations along the inlining stack. */
166 /* The abstract origin of the location. */
167 void *m_ao;
168 /* Set if every M_ILOCS element is in a system header. */
171};
172
173/* Forward declarations. */
176
178 const diagnostic_info *);
179
180typedef void
183 expanded_location);
184
186 const diagnostic_info *,
188
189/* Abstract base class for the diagnostic subsystem to make queries
190 about command-line options. */
191
193{
194public:
196
197 /* Return 1 if option OPTION_ID is enabled, 0 if it is disabled,
198 or -1 if it isn't a simple on-off switch
199 (or if the value is unknown, typically set later in target). */
200 virtual int option_enabled_p (diagnostic_option_id option_id) const = 0;
201
202 /* Return malloced memory for the name of the option OPTION_ID
203 which enabled a diagnostic, originally of type ORIG_DIAG_KIND but
204 possibly converted to DIAG_KIND by options such as -Werror.
205 May return NULL if no name is to be printed.
206 May be passed 0 as well as the index of a particular option. */
207 virtual char *make_option_name (diagnostic_option_id option_id,
208 diagnostic_t orig_diag_kind,
209 diagnostic_t diag_kind) const = 0;
210
211 /* Return malloced memory for a URL describing the option that controls
212 a diagnostic.
213 May return NULL if no URL is available.
214 May be passed 0 as well as the index of a particular option. */
215 virtual char *make_option_url (diagnostic_option_id option_id) const = 0;
216};
217
218class edit_context;
226
227/* A stack of sets of classifications: each entry in the stack is
228 a mapping from option index to diagnostic severity that can be changed
229 via pragmas. The stack can be pushed and popped. */
230
232{
233public:
234 void init (int n_opts);
235 void fini ();
236
237 /* Save all diagnostic classifications in a stack. */
238 void push ();
239
240 /* Restore the topmost classification set off the stack. If the stack
241 is empty, revert to the state based on command line parameters. */
242 void pop (location_t where);
243
245 {
246 return get_current_override (option_id) == DK_UNSPECIFIED;
247 }
248
250 {
251 gcc_assert (option_id.m_idx < m_n_opts);
252 return m_classify_diagnostic[option_id.m_idx];
253 }
254
257 diagnostic_option_id option_id,
258 diagnostic_t new_kind,
259 location_t where);
260
263
264 int pch_save (FILE *);
265 int pch_restore (FILE *);
266
267private:
268 /* Each time a diagnostic's classification is changed with a pragma,
269 we record the change and the location of the change in an array of
270 these structs. */
272 {
273 location_t location;
274
275 /* For DK_POP, this is the index of the corresponding push (as stored
276 in m_push_list).
277 Otherwise, this is an option index. */
279
281 };
282
284
285 /* For each option index that can be passed to warning() et al
286 (OPT_* from options.h when using this code with the core GCC
287 options), this array may contain a new kind that the diagnostic
288 should be changed to before reporting, or DK_UNSPECIFIED to leave
289 it as the reported kind, or DK_IGNORED to not report it at
290 all. */
292
293 /* History of all changes to the classifications above. This list
294 is stored in location-order, so we can search it, either
295 binary-wise or end-to-front, to find the most recent
296 classification for a given diagnostic, given the location of the
297 diagnostic. */
299
300 /* For pragma push/pop. */
302};
303
304/* A bundle of options relating to printing the user's source code
305 (potentially with a margin, underlining, labels, etc). */
306
308{
309 /* True if we should print the source line with a caret indicating
310 the location.
311 Corresponds to -fdiagnostics-show-caret. */
313
314 /* Maximum width of the source line printed. */
316
317 /* Character used at the caret when printing source locations. */
318 char caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES];
319
320 /* When printing source code, should the characters at carets and ranges
321 be colorized? (assuming colorization is on at all).
322 This should be true for frontends that generate range information
323 (so that the ranges of code are colorized),
324 and false for frontends that merely specify points within the
325 source code (to avoid e.g. colorizing just the first character in
326 a token, which would look strange). */
328
329 /* When printing source code, should labelled ranges be printed?
330 Corresponds to -fdiagnostics-show-labels. */
332
333 /* When printing source code, should there be a left-hand margin
334 showing line numbers?
335 Corresponds to -fdiagnostics-show-line-numbers. */
337
338 /* If printing source code, what should the minimum width of the margin
339 be? Line numbers will be right-aligned, and padded to this width.
340 Corresponds to -fdiagnostics-minimum-margin-width=VALUE. */
342
343 /* Usable by plugins; if true, print a debugging ruler above the
344 source output. */
346
347 /* When printing events in an inline path, should we print lines
348 visualizing links between related events (e.g. for CFG paths)?
349 Corresponds to -fdiagnostics-show-event-links. */
351};
352
353/* A bundle of state for determining column numbers in diagnostics
354 (tab stops, whether to start at 0 or 1, etc).
355 Uses a file_cache to handle tabs. */
356
358{
359public:
361
362 int converted_column (expanded_location s) const;
363
364 label_text get_location_text (const expanded_location &s,
365 bool show_column,
366 bool colorize) const;
367
368 int get_tabstop () const { return m_tabstop; }
369
370private:
375};
376
377/* A bundle of state for printing locations within diagnostics
378 (e.g. "FILENAME:LINE:COLUMN"), to isolate the interactions between
379 diagnostic_context and the start_span callbacks. */
380
396
397/* A bundle of state for printing source within a diagnostic,
398 to isolate the interactions between diagnostic_context and the
399 implementation of diagnostic_show_locus. */
400
402{
403public:
407
408 void
410 const rich_location &richloc,
411 diagnostic_t diagnostic_kind,
412 diagnostic_source_effect_info *effect_info) const;
413
415 get_options () const { return m_options; }
416
419
420 file_cache &
421 get_file_cache () const { return m_file_cache; }
422
425 {
426 return m_escape_format;
427 }
428
429 text_art::theme *
431
433 {
434 return m_location_policy.get_column_policy ();
435 }
436
441
442private:
447
448 /* Other data copied from diagnostic_context. */
449 text_art::theme *m_diagram_theme;
451};
452
453/* A collection of counters of diagnostics, per-kind
454 (e.g. "3 errors and 1 warning"), for use by both diagnostic_context
455 and by diagnostic_buffer. */
456
458{
460
461 void dump (FILE *out, int indent) const;
462 void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
463
464 int get_count (diagnostic_t kind) const { return m_count_for_kind[kind]; }
465
466 void move_to (diagnostic_counters &dest);
467 void clear ();
468
470};
471
472/* This class encapsulates the state of the diagnostics subsystem
473 as a whole (either directly, or via owned objects of other classes, to
474 avoid global variables).
475
476 It has responsibility for:
477 - being a central place for clients to report diagnostics
478 - reporting those diagnostics to zero or more output sinks
479 (e.g. text vs SARIF)
480 - providing a "dump" member function for a debug dump of the state of
481 the diagnostics subsytem
482 - direct vs buffered diagnostics (see class diagnostic_buffer)
483 - tracking the original argv of the program (for SARIF output)
484 - crash-handling
485
486 It delegates responsibility to various other classes:
487 - the various output sinks (instances of diagnostic_output_format
488 subclasses)
489 - formatting of messages (class pretty_printer)
490 - an optional urlifier to inject URLs into formatted messages
491 - counting the number of diagnostics reported of each kind
492 (class diagnostic_counters)
493 - calling out to a diagnostic_option_manager to determine if
494 a particular warning is enabled or disabled
495 - tracking pragmas that enable/disable warnings in a range of
496 source code
497 - a cache for use when quoting the user's source code (class file_cache)
498 - a text_art::theme
499 - an edit_context for generating patches from fix-it hints
500 - diagnostic_client_data_hooks for metadata.
501
502 Try to avoid adding new responsibilities to this class itself, to avoid
503 the "blob" anti-pattern. */
504
506{
507public:
508 /* Give access to m_text_callbacks. */
515
518 friend class diagnostic_buffer;
519
522
523 void initialize (int n_opts);
524 void color_init (int value);
525 void urls_init (int value);
526 void set_pretty_printer (std::unique_ptr<pretty_printer> pp);
527 void refresh_output_sinks ();
528
529 void finish ();
530
531 void dump (FILE *out) const;
532 void DEBUG_FUNCTION dump () const { dump (stderr); }
533
534 bool execution_failed_p () const;
535
536 void set_original_argv (unique_argv original_argv);
537 const char * const *get_original_argv ()
538 {
539 return const_cast<const char * const *> (m_original_argv);
540 }
541
546
547 void
549 bool should_skip_bom);
550
551 void begin_group ();
552 void end_group ();
553
554 void push_nesting_level ();
555 void pop_nesting_level ();
556
557 bool warning_enabled_at (location_t loc, diagnostic_option_id option_id);
558
560 {
561 return m_option_classifier.option_unspecified_p (option_id);
562 }
563
565 rich_location &richloc,
566 const diagnostic_metadata *metadata,
567 diagnostic_option_id option_id,
568 const char *gmsgid, ...)
571 rich_location &richloc,
572 const diagnostic_metadata *metadata,
573 diagnostic_option_id option_id,
574 const char *gmsgid, va_list *ap)
576
578 void report_verbatim (text_info &);
579
582 diagnostic_t new_kind,
583 location_t where)
584 {
585 return m_option_classifier.classify_diagnostic (this,
586 option_id,
587 new_kind,
588 where);
589 }
590
591 void push_diagnostics (location_t where ATTRIBUTE_UNUSED)
592 {
593 m_option_classifier.push ();
594 }
595 void pop_diagnostics (location_t where)
596 {
597 m_option_classifier.pop (where);
598 }
599
600 void maybe_show_locus (const rich_location &richloc,
602 diagnostic_t diagnostic_kind,
603 pretty_printer &pp,
604 diagnostic_source_effect_info *effect_info);
605
606 void emit_diagram (const diagnostic_diagram &diagram);
607
608 /* Various setters for use by option-handling logic. */
609 void set_output_format (std::unique_ptr<diagnostic_output_format> output_format);
611 void set_client_data_hooks (std::unique_ptr<diagnostic_client_data_hooks> hooks);
612
613 void push_owned_urlifier (std::unique_ptr<urlifier>);
614 void push_borrowed_urlifier (const urlifier &);
615 void pop_urlifier ();
616
617 void create_edit_context ();
619 {
621 }
622 void set_report_bug (bool val) { m_report_bug = val; }
627 void set_show_cwe (bool val) { m_show_cwe = val; }
628 void set_show_rules (bool val) { m_show_rules = val; }
629 void set_show_highlight_colors (bool val);
631 {
632 m_path_format = val;
633 }
634 void set_show_path_depths (bool val) { m_show_path_depths = val; }
636 void set_max_errors (int val) { m_max_errors = val; }
638 {
639 m_escape_format = val;
640 }
641
642 void set_format_decoder (printer_fn format_decoder);
644
645 /* Various accessors. */
647 {
649 }
650 bool show_path_depths_p () const { return m_show_path_depths; }
654 {
655 return m_escape_format;
656 }
657
658 file_cache &
660 {
662 return *m_file_cache;
663 }
664
666 {
667 return m_edit_context_ptr;
668 }
673
676
677 const urlifier *get_urlifier () const;
678
679 text_art::theme *get_diagram_theme () const { return m_diagrams.m_theme; }
680
682 {
683 return m_diagnostic_counters.m_count_for_kind[kind];
684 }
686 {
687 return m_diagnostic_counters.get_count (kind);
688 }
689
690 /* Option-related member functions. */
691 inline bool option_enabled_p (diagnostic_option_id option_id) const
692 {
693 if (!m_option_mgr)
694 return true;
695 return m_option_mgr->option_enabled_p (option_id);
696 }
697
698 inline char *make_option_name (diagnostic_option_id option_id,
699 diagnostic_t orig_diag_kind,
700 diagnostic_t diag_kind) const
701 {
702 if (!m_option_mgr)
703 return nullptr;
704 return m_option_mgr->make_option_name (option_id,
705 orig_diag_kind,
706 diag_kind);
707 }
708
709 inline char *make_option_url (diagnostic_option_id option_id) const
710 {
711 if (!m_option_mgr)
712 return nullptr;
713 return m_option_mgr->make_option_url (option_id);
714 }
715
716 void
717 set_option_manager (std::unique_ptr<diagnostic_option_manager> mgr,
718 unsigned lang_mask);
719
720 unsigned get_lang_mask () const
721 {
722 return m_lang_mask;
723 }
724
725 bool diagnostic_impl (rich_location *, const diagnostic_metadata *,
726 diagnostic_option_id, const char *,
727 va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0);
728 bool diagnostic_n_impl (rich_location *, const diagnostic_metadata *,
729 diagnostic_option_id, unsigned HOST_WIDE_INT,
730 const char *, const char *, va_list *,
732
734 {
735 return m_diagnostic_groups.m_diagnostic_nesting_level;
736 }
737
738 char *build_indent_prefix () const;
739
740 int
741 pch_save (FILE *f)
742 {
743 return m_option_classifier.pch_save (f);
744 }
745
746 int
747 pch_restore (FILE *f)
748 {
749 return m_option_classifier.pch_restore (f);
750 }
751
752
760
761 std::unique_ptr<pretty_printer> clone_printer () const
762 {
763 return m_reference_printer->clone ();
764 }
765
770
771 void
772 add_sink (std::unique_ptr<diagnostic_output_format>);
773
775
776 bool supports_fnotice_on_stderr_p () const;
777
778 /* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher. */
779 void
781 {
782 m_abort_on_error = val;
783 }
784
785private:
787
789
791
792 void check_max_errors (bool flush);
793 void action_after_output (diagnostic_t diag_kind);
794
795 /* Data members.
796 Ideally, all of these would be private. */
797
798private:
799 /* A reference instance of pretty_printer created by the client
800 and owned by the context. Used for cloning when creating/adding
801 output formats.
802 Owned by the context; this would be a std::unique_ptr if
803 diagnostic_context had a proper ctor. */
805
806 /* Cache of source code.
807 Owned by the context; this would be a std::unique_ptr if
808 diagnostic_context had a proper ctor. */
810
811 /* The number of times we have issued diagnostics. */
813
814 /* True if it has been requested that warnings be treated as errors. */
816
817 /* The number of option indexes that can be passed to warning() et
818 al. */
820
821 /* The stack of sets of overridden diagnostic option severities. */
823
824 /* True if we should print any CWE identifiers associated with
825 diagnostics. */
827
828 /* True if we should print any rules associated with diagnostics. */
830
831 /* How should diagnostic_path objects be printed. */
833
834 /* True if we should print stack depths when printing diagnostic paths. */
836
837 /* True if we should print the command line option which controls
838 each diagnostic, if known. */
840
841 /* True if we should raise a SIGABRT on errors. */
843
844public:
845 /* True if we should show the column number on diagnostics. */
847
848 /* True if pedwarns are errors. */
850
851 /* True if permerrors are warnings. */
853
854 /* The option to associate with turning permerrors into warnings,
855 if any. */
857
858 /* True if errors are fatal. */
860
861 /* True if all warnings should be disabled. */
863
864 /* True if warnings should be given in system headers. */
866
867private:
868 /* Maximum number of errors to report. */
870
871 /* Client-supplied callbacks for use in text output. */
872 struct {
873 /* This function is called before any message is printed out. It is
874 responsible for preparing message prefix and such. For example, it
875 might say:
876 In file included from "/usr/local/include/curses.h:5:
877 from "/home/gdr/src/nifty_printer.h:56:
878 ...
879 */
881
882 /* This function is called by diagnostic_show_locus in between
883 disjoint spans of source code, so that the context can print
884 something to indicate that a new span of source code has begun. */
886
887 /* This function is called after the diagnostic message is printed. */
890
891public:
892 /* Client hook to report an internal error. */
893 void (*m_internal_error) (diagnostic_context *, const char *, va_list *);
894
895 /* Client hook to adjust properties of the given diagnostic that we're
896 about to issue, such as its kind. */
898
899private:
900 /* Owned by the context; this would be a std::unique_ptr if
901 diagnostic_context had a proper ctor. */
903 unsigned m_lang_mask;
904
905 /* A stack of optional hooks for adding URLs to quoted text strings in
906 diagnostics. Only used for the main diagnostic message.
907 Typically a single one owner by the context, but can be temporarily
908 overridden by a borrowed urlifier (e.g. on-stack). */
915
916public:
917 /* Auxiliary data for client. */
919
920 /* Used to detect that the last caret was printed at the same location. */
921 location_t m_last_location;
922
923private:
925
926public:
928
930
931private:
932 /* True if -freport-bug option is used. */
934
935 /* Used to specify additional diagnostic output to be emitted after the
936 rest of the diagnostic. This is for implementing
937 -fdiagnostics-parseable-fixits and GCC_EXTRA_DIAGNOSTIC_OUTPUT. */
939
940public:
941 /* What units to use when outputting the column number. */
943
944 /* The origin for the column number (1-based or 0-based typically). */
946
947 /* The size of the tabstop for tab expansion. */
949
950private:
951 /* How should non-ASCII/non-printable bytes be escaped when
952 a diagnostic suggests escaping the source code on output. */
954
955 /* If non-NULL, an edit_context to which fix-it hints should be
956 applied, for generating patches.
957 Owned by the context; this would be a std::unique_ptr if
958 diagnostic_context had a proper ctor. */
960
961 /* Fields relating to diagnostic groups. */
962 struct {
963 /* How many diagnostic_group instances are currently alive. */
965
966 /* How many nesting levels have been pushed within this group. */
968
969 /* How many diagnostics have been emitted since the bottommost
970 diagnostic_group was pushed. */
972
973 /* The "group+diagnostic" nesting depth from which to inhibit notes. */
976
977 void inhibit_notes_in_group (bool inhibit = true);
978 bool notes_inhibited_in_group () const;
979
980 /* The various sinks to which diagnostics are to be outputted
981 (text vs structured formats such as SARIF).
982 The sinks are owned by the context; this would be a
983 std::vector<std::unique_ptr> if diagnostic_context had a
984 proper ctor. */
986
987 /* Callback to set the locations of call sites along the inlining
988 stack corresponding to a diagnostic location. Needed to traverse
989 the BLOCK_SUPERCONTEXT() chain hanging off the LOCATION_BLOCK()
990 of a diagnostic's location. */
992
993 /* A bundle of hooks for providing data to the context about its client
994 e.g. version information, plugins, etc.
995 Used by SARIF output to give metadata about the client that's
996 producing diagnostics.
997 Owned by the context; this would be a std::unique_ptr if
998 diagnostic_context had a proper ctor. */
1000
1001 /* Support for diagrams. */
1002 struct
1003 {
1004 /* Theme to use when generating diagrams.
1005 Can be NULL (if text art is disabled).
1006 Owned by the context; this would be a std::unique_ptr if
1007 diagnostic_context had a proper ctor. */
1008 text_art::theme *m_theme;
1009
1011
1012 /* Owned by the context. */
1014
1015 /* Borrowed pointer to the active diagnostic_buffer, if any.
1016 If null (the default), then diagnostics that are reported to the
1017 context are immediately issued to the output format.
1018 If non-null, then diagnostics that are reported to the context
1019 are buffered in the buffer, and may be issued to the output format
1020 later (if the buffer is flushed), moved to other buffers, or
1021 discarded (if the buffer is cleared). */
1023};
1024
1025inline void
1027{
1028 context->m_inhibit_notes_p = true;
1029}
1030
1031
1032/* Client supplied function to announce a diagnostic
1033 (for text-based diagnostic output). */
1039
1040/* Client supplied function called between disjoint spans of source code,
1041 so that the context can print
1042 something to indicate that a new span of source code has begun. */
1045{
1046 return context->m_text_callbacks.m_start_span;
1047}
1048
1049/* Client supplied function called after a diagnostic message is
1050 displayed (for text-based diagnostic output). */
1056
1057/* Extension hooks for client. */
1058#define diagnostic_context_auxiliary_data(DC) (DC)->m_client_aux_data
1059#define diagnostic_info_auxiliary_data(DI) (DI)->x_data
1060
1061/* This diagnostic_context is used by front-ends that directly output
1062 diagnostic messages without going through `error', `warning',
1063 and similar functions. */
1065
1066/* The number of errors that have been issued so far. Ideally, these
1067 would take a diagnostic_context as an argument. */
1068#define errorcount global_dc->diagnostic_count (DK_ERROR)
1069/* Similarly, but for warnings. */
1070#define warningcount global_dc->diagnostic_count (DK_WARNING)
1071/* Similarly, but for warnings promoted to errors. */
1072#define werrorcount global_dc->diagnostic_count (DK_WERROR)
1073/* Similarly, but for sorrys. */
1074#define sorrycount global_dc->diagnostic_count (DK_SORRY)
1075
1076/* Returns nonzero if warnings should be emitted. */
1077#define diagnostic_report_warnings_p(DC, LOC) \
1078 (!(DC)->m_inhibit_warnings \
1079 && !(in_system_header_at (LOC) && !(DC)->m_warn_system_headers))
1080
1081/* Override the option index to be used for reporting a
1082 diagnostic. */
1083
1084inline void
1086 diagnostic_option_id option_id)
1087{
1088 info->option_id = option_id;
1089}
1090
1091/* Diagnostic related functions. */
1092
1093inline void
1095{
1096 context->initialize (n_opts);
1097}
1098
1099inline void
1101{
1102 context->color_init (value);
1103}
1104
1105inline void
1107{
1108 context->urls_init (value);
1109}
1110
1111inline void
1113{
1114 context->finish ();
1115}
1116
1117inline void
1120 rich_location *richloc,
1121 diagnostic_t diagnostic_kind,
1122 pretty_printer *pp,
1123 diagnostic_source_effect_info *effect_info = nullptr)
1124{
1125 gcc_assert (context);
1126 gcc_assert (richloc);
1127 gcc_assert (pp);
1128 context->maybe_show_locus (*richloc, opts, diagnostic_kind, *pp, effect_info);
1129}
1130
1131/* Because we read source files a second time after the frontend did it the
1132 first time, we need to know how the frontend handled things like character
1133 set conversion and UTF-8 BOM stripping, in order to make everything
1134 consistent. This function needs to be called by each frontend that requires
1135 non-default behavior, to inform the diagnostics infrastructure how input is
1136 to be processed. The default behavior is to do no conversion and not to
1137 strip a UTF-8 BOM.
1138
1139 The callback should return the input charset to be used to convert the given
1140 file's contents to UTF-8, or it should return NULL if no conversion is needed
1141 for this file. SHOULD_SKIP_BOM only applies in case no conversion was
1142 performed, and if true, it will cause a UTF-8 BOM to be skipped at the
1143 beginning of the file. (In case a conversion was performed, the BOM is
1144 rather skipped as part of the conversion process.) */
1145
1146inline void
1149 bool should_skip_bom)
1150{
1151 context->initialize_input_context (ccb, should_skip_bom);
1152}
1153
1154/* Force diagnostics controlled by OPTIDX to be kind KIND. */
1155inline diagnostic_t
1157 diagnostic_option_id option_id,
1158 diagnostic_t kind,
1159 location_t where)
1160{
1161 return context->classify_diagnostic (option_id, kind, where);
1162}
1163
1164inline void
1166 location_t where)
1167{
1168 context->push_diagnostics (where);
1169}
1170inline void
1172 location_t where)
1173{
1174 context->pop_diagnostics (where);
1175}
1176
1177/* Report a diagnostic message (an error or a warning) as specified by
1178 DC. This function is *the* subroutine in terms of which front-ends
1179 should implement their specific diagnostic handling modules. The
1180 front-end independent format specifiers are exactly those described
1181 in the documentation of output_format.
1182 Return true if a diagnostic was printed, false otherwise. */
1183
1184inline bool
1187{
1188 context->begin_group ();
1189 bool warned = context->report_diagnostic (diagnostic);
1190 context->end_group ();
1191 return warned;
1192}
1193
1194#ifdef ATTRIBUTE_GCC_DIAG
1195extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *,
1196 rich_location *, diagnostic_t) ATTRIBUTE_GCC_DIAG(2,0);
1198 va_list *, rich_location *,
1200 ATTRIBUTE_GCC_DIAG(2,0);
1201#endif
1203 const diagnostic_info *);
1206 expanded_location);
1208 const diagnostic_info *,
1209 diagnostic_t);
1210void diagnostic_set_caret_max_width (diagnostic_context *context, int value);
1211
1212int get_terminal_width (void);
1213
1214/* Return the location associated to this diagnostic. Parameter WHICH
1215 specifies which location. By default, expand the first one. */
1216
1217inline location_t
1219{
1220 return diagnostic->message.get_location (which);
1221}
1222
1223/* Return the number of locations to be printed in DIAGNOSTIC. */
1224
1225inline unsigned int
1227{
1228 return diagnostic->message.m_richloc->get_num_locations ();
1229}
1230
1231/* Expand the location of this diagnostic. Use this function for
1232 consistency. Parameter WHICH specifies which location. By default,
1233 expand the first one. */
1234
1235inline expanded_location
1237{
1238 return diagnostic->richloc->get_expanded_location (which);
1239}
1240
1241/* This is somehow the right-side margin of a caret line, that is, we
1242 print at least these many characters after the position pointed at
1243 by the caret. */
1244const int CARET_LINE_MARGIN = 10;
1245
1246/* Return true if the two locations can be represented within the same
1247 caret line. This is used to build a prefix and also to determine
1248 whether to print one or two caret lines. */
1249
1250inline bool
1252 expanded_location s1, expanded_location s2)
1253{
1254 return (s2.column && s1.line == s2.line
1256 > abs (s1.column - s2.column)));
1257}
1258
1259extern const char *diagnostic_get_color_for_kind (diagnostic_t kind);
1260
1261/* Pure text formatting support functions. */
1262
1263extern char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1;
1264
1265/* Compute the number of digits in the decimal representation of an integer. */
1266extern int num_digits (int);
1267
1268inline bool
1269warning_enabled_at (location_t loc, diagnostic_option_id option_id)
1270{
1271 return global_dc->warning_enabled_at (loc, option_id);
1272}
1273
1274inline bool
1276{
1277 return global_dc->option_unspecified_p (option_id);
1278}
1279
1280extern char *get_cwe_url (int cwe);
1281
1282extern const char *get_diagnostic_kind_text (diagnostic_t kind);
1283
1284const char *maybe_line_and_column (int line, int col);
1285
1286#endif /* ! GCC_DIAGNOSTIC_H */
Definition vec.h:1667
Definition diagnostic-buffer.h:57
Definition diagnostic-client-data-hooks.h:33
Definition diagnostic.h:358
label_text get_location_text(const expanded_location &s, bool show_column, bool colorize) const
Definition diagnostic.cc:758
enum diagnostics_column_unit m_column_unit
Definition diagnostic.h:372
int m_column_origin
Definition diagnostic.h:373
diagnostic_column_policy(const diagnostic_context &dc)
Definition diagnostic.cc:734
int converted_column(expanded_location s) const
Definition diagnostic.cc:746
int m_tabstop
Definition diagnostic.h:374
int get_tabstop() const
Definition diagnostic.h:368
file_cache & m_file_cache
Definition diagnostic.h:371
Definition diagnostic.h:506
struct diagnostic_context::@012375117275062000312167204021321243213276373064 m_diagnostic_groups
void action_after_output(diagnostic_t diag_kind)
Definition diagnostic.cc:931
void push_owned_urlifier(std::unique_ptr< urlifier >)
Definition diagnostic.cc:557
friend class diagnostic_source_print_policy
Definition diagnostic.h:516
int diagnostic_count(diagnostic_t kind) const
Definition diagnostic.h:685
bool bool emit_diagnostic_with_group_va(diagnostic_t kind, rich_location &richloc, const diagnostic_metadata *metadata, diagnostic_option_id option_id, const char *gmsgid, va_list *ap) ATTRIBUTE_GCC_DIAG(6
Definition diagnostic.cc:1401
int m_tabstop
Definition diagnostic.h:948
void initialize(int n_opts)
Definition diagnostic.cc:221
bool notes_inhibited_in_group() const
Definition diagnostic.cc:1038
file_cache * m_file_cache
Definition diagnostic.h:809
bool execution_failed_p() const
Definition diagnostic.cc:475
void set_show_rules(bool val)
Definition diagnostic.h:628
void get_any_inlining_info(diagnostic_info *diagnostic)
Definition diagnostic.cc:1231
enum diagnostic_path_format m_path_format
Definition diagnostic.h:832
void finish()
Definition diagnostic.cc:383
pretty_printer * get_reference_printer() const
Definition diagnostic.h:766
void end_group()
Definition diagnostic.cc:1827
void error_recursion() ATTRIBUTE_NORETURN
Definition diagnostic.cc:1759
int m_diagnostic_nesting_level
Definition diagnostic.h:967
void set_escape_format(enum diagnostics_escape_format val)
Definition diagnostic.h:637
bool diagnostic_enabled(diagnostic_info *diagnostic)
Definition diagnostic.cc:1315
struct diagnostic_context::@025320134223110177324072134063066351130257375203 m_text_callbacks
void(* set_locations_callback_t)(diagnostic_context *, diagnostic_info *)
Definition diagnostic.h:520
bool m_show_option_requested
Definition diagnostic.h:839
void set_set_locations_callback(set_locations_callback_t cb)
Definition diagnostic.h:542
void DEBUG_FUNCTION dump() const
Definition diagnostic.h:532
bool m_report_bug
Definition diagnostic.h:933
void inhibit_notes_in_group(bool inhibit=true)
Definition diagnostic.cc:1008
void remove_all_output_sinks()
Definition diagnostic.cc:485
void refresh_output_sinks()
Definition diagnostic.cc:616
edit_context * get_edit_context() const
Definition diagnostic.h:665
void push_nesting_level()
Definition diagnostic.cc:1844
void set_format_decoder(printer_fn format_decoder)
Definition diagnostic.cc:626
void set_path_format(enum diagnostic_path_format val)
Definition diagnostic.h:630
friend diagnostic_text_starter_fn & diagnostic_text_starter(diagnostic_context *context)
Definition diagnostic.h:1035
void set_diagnostic_buffer(diagnostic_buffer *)
Definition diagnostic.cc:1955
void set_max_errors(int val)
Definition diagnostic.h:636
diagnostic_start_span_fn m_start_span
Definition diagnostic.h:885
friend class diagnostic_text_output_format
Definition diagnostic.h:517
int pch_restore(FILE *f)
Definition diagnostic.h:747
void set_option_manager(std::unique_ptr< diagnostic_option_manager > mgr, unsigned lang_mask)
Definition diagnostic.cc:548
enum diagnostics_extra_output_kind m_extra_output_kind
Definition diagnostic.h:938
bool m_inhibit_warnings
Definition diagnostic.h:862
int m_emission_count
Definition diagnostic.h:971
friend diagnostic_text_finalizer_fn & diagnostic_text_finalizer(diagnostic_context *context)
Definition diagnostic.h:1052
diagnostic_output_format & get_output_format(size_t idx) const
Definition diagnostic.cc:500
bool m_show_column
Definition diagnostic.h:846
void add_sink(std::unique_ptr< diagnostic_output_format >)
Definition diagnostic.cc:508
bool bool diagnostic_n_impl(rich_location *, const diagnostic_metadata *, diagnostic_option_id, unsigned HOST_WIDE_INT, const char *, const char *, va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(7
Definition diagnostic.cc:1713
struct diagnostic_context::@144115345167042231333361231316114173002254305105 m_diagrams
diagnostic_option_classifier m_option_classifier
Definition diagnostic.h:822
diagnostic_option_id m_opt_permissive
Definition diagnostic.h:856
void report_verbatim(text_info &)
Definition diagnostic.cc:1619
bool m_show_path_depths
Definition diagnostic.h:835
int & diagnostic_count(diagnostic_t kind)
Definition diagnostic.h:681
char * make_option_url(diagnostic_option_id option_id) const
Definition diagnostic.h:709
void push_diagnostics(location_t where)
Definition diagnostic.h:591
void begin_group()
Definition diagnostic.cc:1821
enum diagnostics_escape_format m_escape_format
Definition diagnostic.h:953
set_locations_callback_t m_set_locations_cb
Definition diagnostic.h:991
void set_output_format(std::unique_ptr< diagnostic_output_format > output_format)
Definition diagnostic.cc:493
void set_show_path_depths(bool val)
Definition diagnostic.h:634
char * make_option_name(diagnostic_option_id option_id, diagnostic_t orig_diag_kind, diagnostic_t diag_kind) const
Definition diagnostic.h:698
diagnostic_counters m_diagnostic_counters
Definition diagnostic.h:812
std::unique_ptr< pretty_printer > clone_printer() const
Definition diagnostic.h:761
const char *const * get_original_argv()
Definition diagnostic.h:537
void set_pretty_printer(std::unique_ptr< pretty_printer > pp)
Definition diagnostic.cc:606
bool m_warn_system_headers
Definition diagnostic.h:865
char * build_indent_prefix() const
void flush_diagnostic_buffer(diagnostic_buffer &)
Definition diagnostic.cc:2005
diagnostic_text_starter_fn m_begin_diagnostic
Definition diagnostic.h:880
enum diagnostic_path_format get_path_format() const
Definition diagnostic.h:652
int pch_save(FILE *f)
Definition diagnostic.h:741
pretty_printer * m_reference_printer
Definition diagnostic.h:804
char ** m_original_argv
Definition diagnostic.h:1013
diagnostic_client_data_hooks * m_client_data_hooks
Definition diagnostic.h:999
void(* m_internal_error)(diagnostic_context *, const char *, va_list *)
Definition diagnostic.h:893
bool warning_enabled_at(location_t loc, diagnostic_option_id option_id)
Definition diagnostic.cc:1359
bool m_show_cwe
Definition diagnostic.h:826
diagnostic_text_finalizer_fn m_end_diagnostic
Definition diagnostic.h:888
void pop_urlifier()
Definition diagnostic.cc:573
void * m_client_aux_data
Definition diagnostic.h:918
void set_client_data_hooks(std::unique_ptr< diagnostic_client_data_hooks > hooks)
Definition diagnostic.cc:526
diagnostic_option_manager * m_option_mgr
Definition diagnostic.h:902
void set_prefixing_rule(diagnostic_prefixing_rule_t rule)
Definition diagnostic.cc:643
void set_warning_as_error_requested(bool val)
Definition diagnostic.h:618
location_t m_last_location
Definition diagnostic.h:921
void check_max_errors(bool flush)
Definition diagnostic.cc:907
friend diagnostic_start_span_fn & diagnostic_start_span(diagnostic_context *context)
Definition diagnostic.h:1044
unsigned get_lang_mask() const
Definition diagnostic.h:720
void push_borrowed_urlifier(const urlifier &)
Definition diagnostic.cc:565
auto_vec< urlifier_stack_node > * m_urlifier_stack
Definition diagnostic.h:914
void pop_nesting_level()
Definition diagnostic.cc:1850
enum diagnostics_escape_format get_escape_format() const
Definition diagnostic.h:653
int m_inhibiting_notes_from
Definition diagnostic.h:974
bool emit_diagnostic_with_group(diagnostic_t kind, rich_location &richloc, const diagnostic_metadata *metadata, diagnostic_option_id option_id, const char *gmsgid,...) ATTRIBUTE_GCC_DIAG(6
Definition diagnostic.cc:1378
const logical_location_manager * get_logical_location_manager() const
Definition diagnostic.cc:584
void set_text_art_charset(enum diagnostic_text_art_charset charset)
Definition diagnostic.cc:1922
auto_vec< diagnostic_output_format * > m_output_sinks
Definition diagnostic.h:985
const urlifier * get_urlifier() const
Definition diagnostic.cc:592
text_art::theme * m_theme
Definition diagnostic.h:1008
bool m_inhibit_notes_p
Definition diagnostic.h:927
bool show_path_depths_p() const
Definition diagnostic.h:650
bool supports_fnotice_on_stderr_p() const
Definition diagnostic.cc:516
void color_init(int value)
Definition diagnostic.cc:311
bool m_warning_as_error_requested
Definition diagnostic.h:815
const diagnostic_client_data_hooks * get_client_data_hooks() const
Definition diagnostic.h:669
void set_show_option_requested(bool val)
Definition diagnostic.h:635
void set_original_argv(unique_argv original_argv)
Definition diagnostic.cc:534
void urls_init(int value)
Definition diagnostic.cc:342
friend class diagnostic_buffer
Definition diagnostic.h:518
bool bool bool report_diagnostic(diagnostic_info *)
Definition diagnostic.cc:1424
int m_n_opts
Definition diagnostic.h:819
bool diagnostic_impl(rich_location *, const diagnostic_metadata *, diagnostic_option_id, const char *, va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(5
Definition diagnostic.cc:1687
bool option_unspecified_p(diagnostic_option_id option_id) const
Definition diagnostic.h:559
diagnostic_t classify_diagnostic(diagnostic_option_id option_id, diagnostic_t new_kind, location_t where)
Definition diagnostic.h:581
file_cache & get_file_cache() const
Definition diagnostic.h:659
bool option_enabled_p(diagnostic_option_id option_id) const
Definition diagnostic.h:691
void pop_diagnostics(location_t where)
Definition diagnostic.h:595
bool m_pedantic_errors
Definition diagnostic.h:849
text_art::theme * get_diagram_theme() const
Definition diagnostic.h:679
int m_column_origin
Definition diagnostic.h:945
bool m_fatal_errors
Definition diagnostic.h:859
bool m_permissive
Definition diagnostic.h:852
void maybe_show_locus(const rich_location &richloc, const diagnostic_source_printing_options &opts, diagnostic_t diagnostic_kind, pretty_printer &pp, diagnostic_source_effect_info *effect_info)
Definition diagnostic-show-locus.cc:3267
void(* m_adjust_diagnostic_info)(diagnostic_context *, diagnostic_info *)
Definition diagnostic.h:897
unsigned m_lang_mask
Definition diagnostic.h:903
void create_edit_context()
Definition diagnostic.cc:652
diagnostic_buffer * get_diagnostic_buffer() const
Definition diagnostic.h:754
enum diagnostics_column_unit m_column_unit
Definition diagnostic.h:942
void emit_diagram(const diagnostic_diagram &diagram)
Definition diagnostic.cc:1744
int m_lock
Definition diagnostic.h:924
void set_report_bug(bool val)
Definition diagnostic.h:622
bool m_show_rules
Definition diagnostic.h:829
void set_show_cwe(bool val)
Definition diagnostic.h:627
void clear_diagnostic_buffer(diagnostic_buffer &)
Definition diagnostic.cc:1989
bool bool int get_diagnostic_nesting_level() const
Definition diagnostic.h:733
int m_max_errors
Definition diagnostic.h:869
bool m_abort_on_error
Definition diagnostic.h:842
edit_context * m_edit_context_ptr
Definition diagnostic.h:959
diagnostic_source_printing_options m_source_printing
Definition diagnostic.h:929
void set_abort_on_error(bool val)
Definition diagnostic.h:780
bool warning_as_error_requested_p() const
Definition diagnostic.h:646
void set_extra_output_kind(enum diagnostics_extra_output_kind kind)
Definition diagnostic.h:623
int m_group_nesting_depth
Definition diagnostic.h:964
void set_show_highlight_colors(bool val)
Definition diagnostic.cc:634
diagnostic_buffer * m_diagnostic_buffer
Definition diagnostic.h:1022
void initialize_input_context(diagnostic_input_charset_callback ccb, bool should_skip_bom)
Definition diagnostic.cc:374
Definition diagnostic-diagram.h:33
Definition diagnostic.h:382
diagnostic_location_print_policy(const diagnostic_context &dc)
Definition diagnostic.cc:780
bool m_show_column
Definition diagnostic.h:394
bool show_column_p() const
Definition diagnostic.h:387
const diagnostic_column_policy & get_column_policy() const
Definition diagnostic.h:390
diagnostic_column_policy m_column_policy
Definition diagnostic.h:393
Definition diagnostic-metadata.h:33
Definition diagnostic.h:232
void push()
Definition diagnostic.cc:196
diagnostic_t update_effective_level_from_pragmas(diagnostic_info *diagnostic) const
Definition diagnostic.cc:1260
vec< int > m_push_list
Definition diagnostic.h:301
void fini()
Definition diagnostic.cc:141
int m_n_opts
Definition diagnostic.h:283
vec< diagnostic_classification_change_t > m_classification_history
Definition diagnostic.h:298
void pop(location_t where)
Definition diagnostic.cc:205
diagnostic_t classify_diagnostic(const diagnostic_context *context, diagnostic_option_id option_id, diagnostic_t new_kind, location_t where)
Definition diagnostic.cc:1095
diagnostic_t * m_classify_diagnostic
Definition diagnostic.h:291
int pch_restore(FILE *)
Definition diagnostic.cc:173
diagnostic_t get_current_override(diagnostic_option_id option_id) const
Definition diagnostic.h:249
void init(int n_opts)
Definition diagnostic.cc:130
int pch_save(FILE *)
Definition diagnostic.cc:153
bool option_unspecified_p(diagnostic_option_id option_id) const
Definition diagnostic.h:244
Definition diagnostic.h:193
virtual ~diagnostic_option_manager()
Definition diagnostic.h:195
virtual int option_enabled_p(diagnostic_option_id option_id) const =0
virtual char * make_option_name(diagnostic_option_id option_id, diagnostic_t orig_diag_kind, diagnostic_t diag_kind) const =0
virtual char * make_option_url(diagnostic_option_id option_id) const =0
Definition diagnostic-format.h:33
Definition diagnostic-label-effects.h:41
Definition diagnostic.h:402
text_art::theme * m_diagram_theme
Definition diagnostic.h:449
void print(pretty_printer &pp, const rich_location &richloc, diagnostic_t diagnostic_kind, diagnostic_source_effect_info *effect_info) const
Definition diagnostic-show-locus.cc:3325
file_cache & m_file_cache
Definition diagnostic.h:446
diagnostic_start_span_fn m_start_span_cb
Definition diagnostic.h:445
file_cache & get_file_cache() const
Definition diagnostic.h:421
text_art::theme * get_diagram_theme() const
Definition diagnostic.h:430
diagnostic_source_print_policy(const diagnostic_context &)
Definition diagnostic-show-locus.cc:3297
enum diagnostics_escape_format m_escape_format
Definition diagnostic.h:450
class diagnostic_location_print_policy m_location_policy
Definition diagnostic.h:444
const diagnostic_source_printing_options & get_options() const
Definition diagnostic.h:415
diagnostic_start_span_fn get_start_span_fn() const
Definition diagnostic.h:418
const diagnostic_source_printing_options & m_options
Definition diagnostic.h:443
const diagnostic_location_print_policy & get_location_policy() const
Definition diagnostic.h:437
enum diagnostics_escape_format get_escape_format() const
Definition diagnostic.h:424
const diagnostic_column_policy & get_column_policy() const
Definition diagnostic.h:432
Definition diagnostic-format-text.h:33
Definition edit-context.h:44
Definition input.h:136
Definition logical-location.h:91
Definition pretty-print.h:241
Definition pretty-print-urlifier.h:27
const char *(* diagnostic_input_charset_callback)(const char *)
Definition coretypes.h:171
void ATTRIBUTE_NORETURN
Definition diagnostic-core.h:108
diagnostic_t
Definition diagnostic-core.h:29
@ DK_LAST_DIAGNOSTIC_KIND
Definition diagnostic-core.h:90
#define ATTRIBUTE_GCC_DIAG(m, n)
Definition diagnostic-core.h:103
diagnostic_context * global_dc
Definition diagnostic-global-context.cc:34
int num_digits(int value)
Definition diagnostic.cc:1635
void diagnostic_set_caret_max_width(diagnostic_context *context, int value)
Definition diagnostic.cc:116
void diagnostic_set_info(diagnostic_info *, const char *, va_list *, rich_location *, diagnostic_t) ATTRIBUTE_GCC_DIAG(2
char * get_cwe_url(int cwe)
Definition diagnostic.cc:1306
location_t diagnostic_location(const diagnostic_info *diagnostic, int which=0)
Definition diagnostic.h:1218
const int CARET_LINE_MARGIN
Definition diagnostic.h:1244
diagnostics_escape_format
Definition diagnostic.h:52
@ DIAGNOSTICS_ESCAPE_FORMAT_BYTES
Definition diagnostic.h:59
@ DIAGNOSTICS_ESCAPE_FORMAT_UNICODE
Definition diagnostic.h:55
diagnostic_text_art_charset
Definition diagnostic.h:118
@ DIAGNOSTICS_TEXT_ART_CHARSET_ASCII
Definition diagnostic.h:123
@ DIAGNOSTICS_TEXT_ART_CHARSET_NONE
Definition diagnostic.h:120
@ DIAGNOSTICS_TEXT_ART_CHARSET_UNICODE
Definition diagnostic.h:127
@ DIAGNOSTICS_TEXT_ART_CHARSET_EMOJI
Definition diagnostic.h:130
const char * maybe_line_and_column(int line, int col)
Definition diagnostic-format-text.cc:622
diagnostic_t diagnostic_classify_diagnostic(diagnostic_context *context, diagnostic_option_id option_id, diagnostic_t kind, location_t where)
Definition diagnostic.h:1156
void(* diagnostic_text_finalizer_fn)(diagnostic_text_output_format &, const diagnostic_info *, diagnostic_t)
Definition diagnostic.h:185
diagnostic_path_format
Definition diagnostic.h:84
@ DPF_NONE
Definition diagnostic.h:86
@ DPF_SEPARATE_EVENTS
Definition diagnostic.h:90
@ DPF_INLINE_EVENTS
Definition diagnostic.h:96
void diagnostic_initialize_input_context(diagnostic_context *context, diagnostic_input_charset_callback ccb, bool should_skip_bom)
Definition diagnostic.h:1147
diagnostic_text_starter_fn & diagnostic_text_starter(diagnostic_context *context)
Definition diagnostic.h:1035
diagnostics_extra_output_kind
Definition diagnostic.h:103
@ EXTRA_DIAGNOSTIC_OUTPUT_none
Definition diagnostic.h:105
@ EXTRA_DIAGNOSTIC_OUTPUT_fixits_v2
Definition diagnostic.h:112
@ EXTRA_DIAGNOSTIC_OUTPUT_fixits_v1
Definition diagnostic.h:109
diagnostics_output_format
Definition diagnostic.h:65
@ DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE
Definition diagnostic.h:79
@ DIAGNOSTICS_OUTPUT_FORMAT_JSON_STDERR
Definition diagnostic.h:70
@ DIAGNOSTICS_OUTPUT_FORMAT_TEXT
Definition diagnostic.h:67
@ DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR
Definition diagnostic.h:76
@ DIAGNOSTICS_OUTPUT_FORMAT_JSON_FILE
Definition diagnostic.h:73
void diagnostic_urls_init(diagnostic_context *context, int value=-1)
Definition diagnostic.h:1106
diagnostic_text_finalizer_fn & diagnostic_text_finalizer(diagnostic_context *context)
Definition diagnostic.h:1052
void diagnostic_inhibit_notes(diagnostic_context *context)
Definition diagnostic.h:1026
int get_terminal_width(void)
Definition diagnostic.cc:95
const char * diagnostic_get_color_for_kind(diagnostic_t kind)
Definition diagnostic.cc:699
void default_diagnostic_text_finalizer(diagnostic_text_output_format &, const diagnostic_info *, diagnostic_t)
Definition diagnostic-format-text.cc:716
void default_diagnostic_start_span_fn(const diagnostic_location_print_policy &, pretty_printer *, expanded_location)
Definition diagnostic.cc:1075
diagnostics_column_unit
Definition diagnostic.h:40
@ DIAGNOSTICS_COLUMN_UNIT_BYTE
Definition diagnostic.h:45
@ DIAGNOSTICS_COLUMN_UNIT_DISPLAY
Definition diagnostic.h:42
expanded_location diagnostic_expand_location(const diagnostic_info *diagnostic, int which=0)
Definition diagnostic.h:1236
diagnostic_start_span_fn & diagnostic_start_span(diagnostic_context *context)
Definition diagnostic.h:1044
const char * get_diagnostic_kind_text(diagnostic_t kind)
Definition diagnostic.cc:804
void(* diagnostic_text_starter_fn)(diagnostic_text_output_format &, const diagnostic_info *)
Definition diagnostic.h:177
bool option_unspecified_p(diagnostic_option_id option_id)
Definition diagnostic.h:1275
void(* diagnostic_start_span_fn)(const diagnostic_location_print_policy &, pretty_printer *, expanded_location)
Definition diagnostic.h:181
char * build_message_string(const char *,...) ATTRIBUTE_PRINTF_1
Definition diagnostic.cc:78
void diagnostic_finish(diagnostic_context *context)
Definition diagnostic.h:1112
bool warning_enabled_at(location_t loc, diagnostic_option_id option_id)
Definition diagnostic.h:1269
unsigned int diagnostic_num_locations(const diagnostic_info *diagnostic)
Definition diagnostic.h:1226
void diagnostic_initialize(diagnostic_context *context, int n_opts)
Definition diagnostic.h:1094
void diagnostic_set_option_id(diagnostic_info *info, diagnostic_option_id option_id)
Definition diagnostic.h:1085
void diagnostic_color_init(diagnostic_context *context, int value=-1)
Definition diagnostic.h:1100
void diagnostic_show_locus(diagnostic_context *context, const diagnostic_source_printing_options &opts, rich_location *richloc, diagnostic_t diagnostic_kind, pretty_printer *pp, diagnostic_source_effect_info *effect_info=nullptr)
Definition diagnostic.h:1118
void void diagnostic_set_info_translated(diagnostic_info *, const char *, va_list *, rich_location *, diagnostic_t) ATTRIBUTE_GCC_DIAG(2
void diagnostic_pop_diagnostics(diagnostic_context *context, location_t where)
Definition diagnostic.h:1171
void diagnostic_push_diagnostics(diagnostic_context *context, location_t where)
Definition diagnostic.h:1165
bool diagnostic_same_line(const diagnostic_context *context, expanded_location s1, expanded_location s2)
Definition diagnostic.h:1251
bool diagnostic_report_diagnostic(diagnostic_context *context, diagnostic_info *diagnostic)
Definition diagnostic.h:1185
void void void default_diagnostic_text_starter(diagnostic_text_output_format &, const diagnostic_info *)
Definition diagnostic-format-text.cc:707
Definition diagnostic-diagram.h:25
bool(* printer_fn)(pretty_printer *, text_info *, const char *, int, bool, bool, bool, bool *, pp_token_list &)
Definition pretty-print.h:190
diagnostic_prefixing_rule_t
Definition pretty-print.h:66
static void const char va_list ap
Definition read-md.cc:205
Definition diagnostic.h:910
bool m_owned
Definition diagnostic.h:912
urlifier * m_urlifier
Definition diagnostic.h:911
Definition diagnostic.h:458
void clear()
Definition diagnostic.cc:2053
diagnostic_counters()
Definition diagnostic.cc:2021
void move_to(diagnostic_counters &dest)
Definition diagnostic.cc:2045
int get_count(diagnostic_t kind) const
Definition diagnostic.h:464
int m_count_for_kind[DK_LAST_DIAGNOSTIC_KIND]
Definition diagnostic.h:469
void DEBUG_FUNCTION dump() const
Definition diagnostic.h:462
Definition diagnostic.h:163
void * m_ao
Definition diagnostic.h:167
auto_vec< location_t, 8 > m_ilocs
Definition diagnostic.h:165
bool m_allsyslocs
Definition diagnostic.h:169
Definition diagnostic.h:137
const diagnostic_metadata * metadata
Definition diagnostic.h:151
diagnostic_info()
Definition diagnostic.h:138
void * x_data
Definition diagnostic.h:154
diagnostic_t kind
Definition diagnostic.h:156
struct diagnostic_info::inlining_info m_iinfo
text_info message
Definition diagnostic.h:144
rich_location * richloc
Definition diagnostic.h:147
diagnostic_option_id option_id
Definition diagnostic.h:158
Definition diagnostic-core.h:72
int m_idx
Definition diagnostic-core.h:84
Definition diagnostic.h:308
bool enabled
Definition diagnostic.h:312
bool show_line_numbers_p
Definition diagnostic.h:336
bool show_event_links_p
Definition diagnostic.h:350
int max_width
Definition diagnostic.h:315
char caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES]
Definition diagnostic.h:318
bool show_ruler_p
Definition diagnostic.h:345
bool show_labels_p
Definition diagnostic.h:331
bool colorize_source_p
Definition diagnostic.h:327
int min_margin_width
Definition diagnostic.h:341
Definition libgdiagnostics.cc:907
Definition pretty-print.h:34
Definition unique-argv.h:28
Definition vec.h:450
#define gcc_assert(EXPR)
Definition system.h:814
#define DEBUG_FUNCTION
Definition system.h:1236