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-2024 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, to stderr. */
77
78 /* SARIF-based output, to a 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. */
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. */
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;
220class logical_location;
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:
405
406 void
408 const rich_location &richloc,
409 diagnostic_t diagnostic_kind,
410 diagnostic_source_effect_info *effect_info) const;
411
413 get_options () const { return m_options; }
414
417
418 file_cache &
419 get_file_cache () const { return m_file_cache; }
420
423 {
424 return m_escape_format;
425 }
426
427 text_art::theme *
429
434
439
440private:
445
446 /* Other data copied from diagnostic_context. */
447 text_art::theme *m_diagram_theme;
449};
450
451/* A collection of counters of diagnostics, per-kind
452 (e.g. "3 errors and 1 warning"), for use by both diagnostic_context
453 and by diagnostic_buffer. */
454
456{
458
459 void dump (FILE *out, int indent) const;
460 void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
461
462 int get_count (diagnostic_t kind) const { return m_count_for_kind[kind]; }
463
464 void move_to (diagnostic_counters &dest);
465 void clear ();
466
468};
469
470/* This class encapsulates the state of the diagnostics subsystem
471 as a whole (either directly, or via owned objects of other classes, to
472 avoid global variables).
473
474 It has responsibility for:
475 - being a central place for clients to report diagnostics
476 - reporting those diagnostics to zero or more output sinks
477 (e.g. text vs SARIF)
478 - providing a "dump" member function for a debug dump of the state of
479 the diagnostics subsytem
480 - direct vs buffered diagnostics (see class diagnostic_buffer)
481 - tracking the original argv of the program (for SARIF output)
482 - crash-handling
483
484 It delegates responsibility to various other classes:
485 - the various output sinks (instances of diagnostic_output_format
486 subclasses)
487 - formatting of messages (class pretty_printer)
488 - an optional urlifier to inject URLs into formatted messages
489 - counting the number of diagnostics reported of each kind
490 (class diagnostic_counters)
491 - calling out to a diagnostic_option_manager to determine if
492 a particular warning is enabled or disabled
493 - tracking pragmas that enable/disable warnings in a range of
494 source code
495 - a cache for use when quoting the user's source code (class file_cache)
496 - a text_art::theme
497 - an edit_context for generating patches from fix-it hints
498 - diagnostic_client_data_hooks for metadata.
499
500 Try to avoid adding new responsibilities to this class itself, to avoid
501 the "blob" anti-pattern. */
502
504{
505public:
506 /* Give access to m_text_callbacks. */
513
516 friend class diagnostic_buffer;
517
520
521 void initialize (int n_opts);
522 void color_init (int value);
523 void urls_init (int value);
524 void set_pretty_printer (std::unique_ptr<pretty_printer> pp);
525 void refresh_output_sinks ();
526
527 void finish ();
528
529 void dump (FILE *out) const;
530 void DEBUG_FUNCTION dump () const { dump (stderr); }
531
532 bool execution_failed_p () const;
533
534 void set_original_argv (unique_argv original_argv);
535 const char * const *get_original_argv ()
536 {
537 return const_cast<const char * const *> (m_original_argv);
538 }
539
544
545 void
547 bool should_skip_bom);
548
549 void begin_group ();
550 void end_group ();
551
552 void push_nesting_level ();
553 void pop_nesting_level ();
554
555 bool warning_enabled_at (location_t loc, diagnostic_option_id option_id);
556
558 {
559 return m_option_classifier.option_unspecified_p (option_id);
560 }
561
563 rich_location &richloc,
564 const diagnostic_metadata *metadata,
565 diagnostic_option_id option_id,
566 const char *gmsgid, ...)
569 rich_location &richloc,
570 const diagnostic_metadata *metadata,
571 diagnostic_option_id option_id,
572 const char *gmsgid, va_list *ap)
574
576 void report_verbatim (text_info &);
577
580 diagnostic_t new_kind,
581 location_t where)
582 {
584 option_id,
585 new_kind,
586 where);
587 }
588
589 void push_diagnostics (location_t where ATTRIBUTE_UNUSED)
590 {
592 }
593 void pop_diagnostics (location_t where)
594 {
595 m_option_classifier.pop (where);
596 }
597
598 void maybe_show_locus (const rich_location &richloc,
599 diagnostic_t diagnostic_kind,
600 pretty_printer &pp,
601 diagnostic_source_effect_info *effect_info);
602
603 void emit_diagram (const diagnostic_diagram &diagram);
604
605 /* Various setters for use by option-handling logic. */
606 void set_output_format (std::unique_ptr<diagnostic_output_format> output_format);
608 void set_client_data_hooks (std::unique_ptr<diagnostic_client_data_hooks> hooks);
609 void set_urlifier (std::unique_ptr<urlifier>);
611 void create_edit_context ();
613 {
615 }
616 void set_report_bug (bool val) { m_report_bug = val; }
621 void set_show_cwe (bool val) { m_show_cwe = val; }
622 void set_show_rules (bool val) { m_show_rules = val; }
623 void set_show_highlight_colors (bool val);
625 {
626 m_path_format = val;
627 }
628 void set_show_path_depths (bool val) { m_show_path_depths = val; }
630 void set_max_errors (int val) { m_max_errors = val; }
632 {
633 m_escape_format = val;
634 }
635
636 void set_format_decoder (printer_fn format_decoder);
638
639 /* Various accessors. */
641 {
643 }
644 bool show_path_depths_p () const { return m_show_path_depths; }
648 {
649 return m_escape_format;
650 }
651
652 file_cache &
654 {
656 return *m_file_cache;
657 }
658
660 {
661 return m_edit_context_ptr;
662 }
667 urlifier *get_urlifier () const { return m_urlifier; }
668
669 text_art::theme *get_diagram_theme () const { return m_diagrams.m_theme; }
670
672 {
674 }
676 {
677 return m_diagnostic_counters.get_count (kind);
678 }
679
680 /* Option-related member functions. */
681 inline bool option_enabled_p (diagnostic_option_id option_id) const
682 {
683 if (!m_option_mgr)
684 return true;
685 return m_option_mgr->option_enabled_p (option_id);
686 }
687
688 inline char *make_option_name (diagnostic_option_id option_id,
689 diagnostic_t orig_diag_kind,
690 diagnostic_t diag_kind) const
691 {
692 if (!m_option_mgr)
693 return nullptr;
694 return m_option_mgr->make_option_name (option_id,
695 orig_diag_kind,
696 diag_kind);
697 }
698
699 inline char *make_option_url (diagnostic_option_id option_id) const
700 {
701 if (!m_option_mgr)
702 return nullptr;
703 return m_option_mgr->make_option_url (option_id);
704 }
705
706 void
707 set_option_manager (std::unique_ptr<diagnostic_option_manager> mgr,
708 unsigned lang_mask);
709
710 unsigned get_lang_mask () const
711 {
712 return m_lang_mask;
713 }
714
715 bool diagnostic_impl (rich_location *, const diagnostic_metadata *,
716 diagnostic_option_id, const char *,
717 va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0);
718 bool diagnostic_n_impl (rich_location *, const diagnostic_metadata *,
719 diagnostic_option_id, unsigned HOST_WIDE_INT,
720 const char *, const char *, va_list *,
722
724 {
725 return m_diagnostic_groups.m_diagnostic_nesting_level;
726 }
727
728 char *build_indent_prefix () const;
729
730 int
731 pch_save (FILE *f)
732 {
733 return m_option_classifier.pch_save (f);
734 }
735
736 int
737 pch_restore (FILE *f)
738 {
740 }
741
742
750
751 std::unique_ptr<pretty_printer> clone_printer () const
752 {
753 return m_reference_printer->clone ();
754 }
755
760
761 void
762 add_sink (std::unique_ptr<diagnostic_output_format>);
763
764 bool supports_fnotice_on_stderr_p () const;
765
766private:
768
770
772
773 void check_max_errors (bool flush);
774 void action_after_output (diagnostic_t diag_kind);
775
776 /* Data members.
777 Ideally, all of these would be private. */
778
779private:
780 /* A reference instance of pretty_printer created by the client
781 and owned by the context. Used for cloning when creating/adding
782 output formats.
783 Owned by the context; this would be a std::unique_ptr if
784 diagnostic_context had a proper ctor. */
786
787 /* Cache of source code.
788 Owned by the context; this would be a std::unique_ptr if
789 diagnostic_context had a proper ctor. */
791
792 /* The number of times we have issued diagnostics. */
794
795 /* True if it has been requested that warnings be treated as errors. */
797
798 /* The number of option indexes that can be passed to warning() et
799 al. */
801
802 /* The stack of sets of overridden diagnostic option severities. */
804
805 /* True if we should print any CWE identifiers associated with
806 diagnostics. */
808
809 /* True if we should print any rules associated with diagnostics. */
811
812 /* How should diagnostic_path objects be printed. */
814
815 /* True if we should print stack depths when printing diagnostic paths. */
817
818 /* True if we should print the command line option which controls
819 each diagnostic, if known. */
821
822public:
823 /* True if we should raise a SIGABRT on errors. */
825
826 /* True if we should show the column number on diagnostics. */
828
829 /* True if pedwarns are errors. */
831
832 /* True if permerrors are warnings. */
834
835 /* The index of the option to associate with turning permerrors into
836 warnings. */
838
839 /* True if errors are fatal. */
841
842 /* True if all warnings should be disabled. */
844
845 /* True if warnings should be given in system headers. */
847
848private:
849 /* Maximum number of errors to report. */
851
852 /* Client-supplied callbacks for use in text output. */
853 struct {
854 /* This function is called before any message is printed out. It is
855 responsible for preparing message prefix and such. For example, it
856 might say:
857 In file included from "/usr/local/include/curses.h:5:
858 from "/home/gdr/src/nifty_printer.h:56:
859 ...
860 */
862
863 /* This function is called by diagnostic_show_locus in between
864 disjoint spans of source code, so that the context can print
865 something to indicate that a new span of source code has begun. */
867
868 /* This function is called after the diagnostic message is printed. */
871
872public:
873 /* Client hook to report an internal error. */
874 void (*m_internal_error) (diagnostic_context *, const char *, va_list *);
875
876 /* Client hook to adjust properties of the given diagnostic that we're
877 about to issue, such as its kind. */
879
880private:
881 /* Owned by the context; this would be a std::unique_ptr if
882 diagnostic_context had a proper ctor. */
884 unsigned m_lang_mask;
885
886 /* An optional hook for adding URLs to quoted text strings in
887 diagnostics. Only used for the main diagnostic message.
888 Owned by the context; this would be a std::unique_ptr if
889 diagnostic_context had a proper ctor. */
891
892public:
893 /* Auxiliary data for client. */
895
896 /* Used to detect that the last caret was printed at the same location. */
897 location_t m_last_location;
898
899private:
901
902public:
904
906
907private:
908 /* True if -freport-bug option is used. */
910
911 /* Used to specify additional diagnostic output to be emitted after the
912 rest of the diagnostic. This is for implementing
913 -fdiagnostics-parseable-fixits and GCC_EXTRA_DIAGNOSTIC_OUTPUT. */
915
916public:
917 /* What units to use when outputting the column number. */
919
920 /* The origin for the column number (1-based or 0-based typically). */
922
923 /* The size of the tabstop for tab expansion. */
925
926private:
927 /* How should non-ASCII/non-printable bytes be escaped when
928 a diagnostic suggests escaping the source code on output. */
930
931 /* If non-NULL, an edit_context to which fix-it hints should be
932 applied, for generating patches.
933 Owned by the context; this would be a std::unique_ptr if
934 diagnostic_context had a proper ctor. */
936
937 /* Fields relating to diagnostic groups. */
938 struct {
939 /* How many diagnostic_group instances are currently alive. */
941
942 /* How many nesting levels have been pushed within this group. */
944
945 /* How many diagnostics have been emitted since the bottommost
946 diagnostic_group was pushed. */
949
950 /* The various sinks to which diagnostics are to be outputted
951 (text vs structured formats such as SARIF).
952 The sinks are owned by the context; this would be a
953 std::vector<std::unique_ptr> if diagnostic_context had a
954 proper ctor. */
956
957 /* Callback to set the locations of call sites along the inlining
958 stack corresponding to a diagnostic location. Needed to traverse
959 the BLOCK_SUPERCONTEXT() chain hanging off the LOCATION_BLOCK()
960 of a diagnostic's location. */
962
963 /* A bundle of hooks for providing data to the context about its client
964 e.g. version information, plugins, etc.
965 Used by SARIF output to give metadata about the client that's
966 producing diagnostics.
967 Owned by the context; this would be a std::unique_ptr if
968 diagnostic_context had a proper ctor. */
970
971 /* Support for diagrams. */
972 struct
973 {
974 /* Theme to use when generating diagrams.
975 Can be NULL (if text art is disabled).
976 Owned by the context; this would be a std::unique_ptr if
977 diagnostic_context had a proper ctor. */
978 text_art::theme *m_theme;
979
981
982 /* Owned by the context. */
984
985 /* Borrowed pointer to the active diagnostic_buffer, if any.
986 If null (the default), then diagnostics that are reported to the
987 context are immediately issued to the output format.
988 If non-null, then diagnostics that are reported to the context
989 are buffered in the buffer, and may be issued to the output format
990 later (if the buffer is flushed), moved to other buffers, or
991 discarded (if the buffer is cleared). */
993};
994
995inline void
997{
998 context->m_inhibit_notes_p = true;
999}
1000
1001
1002/* Client supplied function to announce a diagnostic
1003 (for text-based diagnostic output). */
1009
1010/* Client supplied function called between disjoint spans of source code,
1011 so that the context can print
1012 something to indicate that a new span of source code has begun. */
1015{
1016 return context->m_text_callbacks.m_start_span;
1017}
1018
1019/* Client supplied function called after a diagnostic message is
1020 displayed (for text-based diagnostic output). */
1026
1027/* Extension hooks for client. */
1028#define diagnostic_context_auxiliary_data(DC) (DC)->m_client_aux_data
1029#define diagnostic_info_auxiliary_data(DI) (DI)->x_data
1030
1031/* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher. */
1032inline void
1034{
1035 context->m_abort_on_error = true;
1036}
1037
1038/* This diagnostic_context is used by front-ends that directly output
1039 diagnostic messages without going through `error', `warning',
1040 and similar functions. */
1042
1043/* The number of errors that have been issued so far. Ideally, these
1044 would take a diagnostic_context as an argument. */
1045#define errorcount global_dc->diagnostic_count (DK_ERROR)
1046/* Similarly, but for warnings. */
1047#define warningcount global_dc->diagnostic_count (DK_WARNING)
1048/* Similarly, but for warnings promoted to errors. */
1049#define werrorcount global_dc->diagnostic_count (DK_WERROR)
1050/* Similarly, but for sorrys. */
1051#define sorrycount global_dc->diagnostic_count (DK_SORRY)
1052
1053/* Returns nonzero if warnings should be emitted. */
1054#define diagnostic_report_warnings_p(DC, LOC) \
1055 (!(DC)->m_inhibit_warnings \
1056 && !(in_system_header_at (LOC) && !(DC)->m_warn_system_headers))
1057
1058/* Override the option index to be used for reporting a
1059 diagnostic. */
1060
1061inline void
1063 diagnostic_option_id option_id)
1064{
1065 info->option_id = option_id;
1066}
1067
1068/* Diagnostic related functions. */
1069
1070inline void
1072{
1073 context->initialize (n_opts);
1074}
1075
1076inline void
1078{
1079 context->color_init (value);
1080}
1081
1082inline void
1084{
1085 context->urls_init (value);
1086}
1087
1088inline void
1090{
1091 context->finish ();
1092}
1093
1094inline void
1096 rich_location *richloc,
1097 diagnostic_t diagnostic_kind,
1098 pretty_printer *pp,
1099 diagnostic_source_effect_info *effect_info = nullptr)
1100{
1101 gcc_assert (context);
1102 gcc_assert (richloc);
1103 gcc_assert (pp);
1104 context->maybe_show_locus (*richloc, diagnostic_kind, *pp, effect_info);
1105}
1106
1107/* Because we read source files a second time after the frontend did it the
1108 first time, we need to know how the frontend handled things like character
1109 set conversion and UTF-8 BOM stripping, in order to make everything
1110 consistent. This function needs to be called by each frontend that requires
1111 non-default behavior, to inform the diagnostics infrastructure how input is
1112 to be processed. The default behavior is to do no conversion and not to
1113 strip a UTF-8 BOM.
1114
1115 The callback should return the input charset to be used to convert the given
1116 file's contents to UTF-8, or it should return NULL if no conversion is needed
1117 for this file. SHOULD_SKIP_BOM only applies in case no conversion was
1118 performed, and if true, it will cause a UTF-8 BOM to be skipped at the
1119 beginning of the file. (In case a conversion was performed, the BOM is
1120 rather skipped as part of the conversion process.) */
1121
1122inline void
1125 bool should_skip_bom)
1126{
1127 context->initialize_input_context (ccb, should_skip_bom);
1128}
1129
1130/* Force diagnostics controlled by OPTIDX to be kind KIND. */
1131inline diagnostic_t
1133 diagnostic_option_id option_id,
1134 diagnostic_t kind,
1135 location_t where)
1136{
1137 return context->classify_diagnostic (option_id, kind, where);
1138}
1139
1140inline void
1142 location_t where)
1143{
1144 context->push_diagnostics (where);
1145}
1146inline void
1148 location_t where)
1149{
1150 context->pop_diagnostics (where);
1151}
1152
1153/* Report a diagnostic message (an error or a warning) as specified by
1154 DC. This function is *the* subroutine in terms of which front-ends
1155 should implement their specific diagnostic handling modules. The
1156 front-end independent format specifiers are exactly those described
1157 in the documentation of output_format.
1158 Return true if a diagnostic was printed, false otherwise. */
1159
1160inline bool
1163{
1164 context->begin_group ();
1165 bool warned = context->report_diagnostic (diagnostic);
1166 context->end_group ();
1167 return warned;
1168}
1169
1170#ifdef ATTRIBUTE_GCC_DIAG
1171extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *,
1172 rich_location *, diagnostic_t) ATTRIBUTE_GCC_DIAG(2,0);
1174 va_list *, rich_location *,
1176 ATTRIBUTE_GCC_DIAG(2,0);
1177#endif
1179 const diagnostic_info *);
1182 expanded_location);
1184 const diagnostic_info *,
1185 diagnostic_t);
1186void diagnostic_set_caret_max_width (diagnostic_context *context, int value);
1187
1188int get_terminal_width (void);
1189
1190/* Return the location associated to this diagnostic. Parameter WHICH
1191 specifies which location. By default, expand the first one. */
1192
1193inline location_t
1195{
1196 return diagnostic->message.get_location (which);
1197}
1198
1199/* Return the number of locations to be printed in DIAGNOSTIC. */
1200
1201inline unsigned int
1203{
1204 return diagnostic->message.m_richloc->get_num_locations ();
1205}
1206
1207/* Expand the location of this diagnostic. Use this function for
1208 consistency. Parameter WHICH specifies which location. By default,
1209 expand the first one. */
1210
1211inline expanded_location
1213{
1214 return diagnostic->richloc->get_expanded_location (which);
1215}
1216
1217/* This is somehow the right-side margin of a caret line, that is, we
1218 print at least these many characters after the position pointed at
1219 by the caret. */
1220const int CARET_LINE_MARGIN = 10;
1221
1222/* Return true if the two locations can be represented within the same
1223 caret line. This is used to build a prefix and also to determine
1224 whether to print one or two caret lines. */
1225
1226inline bool
1228 expanded_location s1, expanded_location s2)
1229{
1230 return (s2.column && s1.line == s2.line
1232 > abs (s1.column - s2.column)));
1233}
1234
1235extern const char *diagnostic_get_color_for_kind (diagnostic_t kind);
1236
1237/* Pure text formatting support functions. */
1238
1239extern char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1;
1240
1241/* Compute the number of digits in the decimal representation of an integer. */
1242extern int num_digits (int);
1243
1244inline bool
1245warning_enabled_at (location_t loc, diagnostic_option_id option_id)
1246{
1247 return global_dc->warning_enabled_at (loc, option_id);
1248}
1249
1250inline bool
1252{
1253 return global_dc->option_unspecified_p (option_id);
1254}
1255
1256extern char *get_cwe_url (int cwe);
1257
1258extern const char *get_diagnostic_kind_text (diagnostic_t kind);
1259
1260const char *maybe_line_and_column (int line, int col);
1261
1262#endif /* ! GCC_DIAGNOSTIC_H */
Definition vec.h:1656
Definition diagnostic-buffer.h:57
Definition diagnostic-client-data-hooks.h:31
Definition diagnostic.h:358
label_text get_location_text(const expanded_location &s, bool show_column, bool colorize) const
Definition diagnostic.cc:705
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:681
int converted_column(expanded_location s) const
Definition diagnostic.cc:693
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:504
void action_after_output(diagnostic_t diag_kind)
Definition diagnostic.cc:877
int diagnostic_count(diagnostic_t kind) const
Definition diagnostic.h:675
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:1303
int m_tabstop
Definition diagnostic.h:924
void initialize(int n_opts)
Definition diagnostic.cc:222
file_cache * m_file_cache
Definition diagnostic.h:790
bool execution_failed_p() const
Definition diagnostic.cc:458
void set_show_rules(bool val)
Definition diagnostic.h:622
void get_any_inlining_info(diagnostic_info *diagnostic)
Definition diagnostic.cc:1133
enum diagnostic_path_format m_path_format
Definition diagnostic.h:813
void finish()
Definition diagnostic.cc:382
void set_urlifier(std::unique_ptr< urlifier >)
Definition diagnostic.cc:534
pretty_printer * get_reference_printer() const
Definition diagnostic.h:756
void end_group()
Definition diagnostic.cc:1716
void error_recursion() ATTRIBUTE_NORETURN
Definition diagnostic.cc:1648
int m_diagnostic_nesting_level
Definition diagnostic.h:943
void set_escape_format(enum diagnostics_escape_format val)
Definition diagnostic.h:631
bool diagnostic_enabled(diagnostic_info *diagnostic)
Definition diagnostic.cc:1217
bool m_show_option_requested
Definition diagnostic.h:820
void set_set_locations_callback(set_locations_callback_t cb)
Definition diagnostic.h:540
void DEBUG_FUNCTION dump() const
Definition diagnostic.h:530
bool m_report_bug
Definition diagnostic.h:909
void refresh_output_sinks()
Definition diagnostic.cc:555
edit_context * get_edit_context() const
Definition diagnostic.h:659
void push_nesting_level()
Definition diagnostic.cc:1731
void set_format_decoder(printer_fn format_decoder)
Definition diagnostic.cc:565
void set_path_format(enum diagnostic_path_format val)
Definition diagnostic.h:624
friend diagnostic_text_starter_fn & diagnostic_text_starter(diagnostic_context *context)
Definition diagnostic.h:1005
void set_diagnostic_buffer(diagnostic_buffer *)
Definition diagnostic.cc:1842
void set_max_errors(int val)
Definition diagnostic.h:630
diagnostic_start_span_fn m_start_span
Definition diagnostic.h:866
int pch_restore(FILE *f)
Definition diagnostic.h:737
void set_option_manager(std::unique_ptr< diagnostic_option_manager > mgr, unsigned lang_mask)
Definition diagnostic.cc:525
enum diagnostics_extra_output_kind m_extra_output_kind
Definition diagnostic.h:914
bool m_inhibit_warnings
Definition diagnostic.h:843
int m_emission_count
Definition diagnostic.h:947
friend diagnostic_text_finalizer_fn & diagnostic_text_finalizer(diagnostic_context *context)
Definition diagnostic.h:1022
diagnostic_output_format & get_output_format(size_t idx) const
Definition diagnostic.cc:477
bool m_show_column
Definition diagnostic.h:827
void add_sink(std::unique_ptr< diagnostic_output_format >)
Definition diagnostic.cc:485
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:1602
diagnostic_option_classifier m_option_classifier
Definition diagnostic.h:803
void report_verbatim(text_info &)
Definition diagnostic.cc:1508
bool m_show_path_depths
Definition diagnostic.h:816
int & diagnostic_count(diagnostic_t kind)
Definition diagnostic.h:671
struct diagnostic_context::@18 m_diagrams
char * make_option_url(diagnostic_option_id option_id) const
Definition diagnostic.h:699
void push_diagnostics(location_t where)
Definition diagnostic.h:589
void begin_group()
Definition diagnostic.cc:1710
enum diagnostics_escape_format m_escape_format
Definition diagnostic.h:929
set_locations_callback_t m_set_locations_cb
Definition diagnostic.h:961
void set_output_format(std::unique_ptr< diagnostic_output_format > output_format)
Definition diagnostic.cc:469
void set_show_path_depths(bool val)
Definition diagnostic.h:628
char * make_option_name(diagnostic_option_id option_id, diagnostic_t orig_diag_kind, diagnostic_t diag_kind) const
Definition diagnostic.h:688
diagnostic_counters m_diagnostic_counters
Definition diagnostic.h:793
std::unique_ptr< pretty_printer > clone_printer() const
Definition diagnostic.h:751
const char *const * get_original_argv()
Definition diagnostic.h:535
urlifier * get_urlifier() const
Definition diagnostic.h:667
void set_pretty_printer(std::unique_ptr< pretty_printer > pp)
Definition diagnostic.cc:545
urlifier * m_urlifier
Definition diagnostic.h:890
bool m_warn_system_headers
Definition diagnostic.h:846
struct diagnostic_context::@17 m_diagnostic_groups
char * build_indent_prefix() const
void flush_diagnostic_buffer(diagnostic_buffer &)
Definition diagnostic.cc:1892
diagnostic_text_starter_fn m_begin_diagnostic
Definition diagnostic.h:861
enum diagnostic_path_format get_path_format() const
Definition diagnostic.h:646
int pch_save(FILE *f)
Definition diagnostic.h:731
pretty_printer * m_reference_printer
Definition diagnostic.h:785
char ** m_original_argv
Definition diagnostic.h:983
diagnostic_client_data_hooks * m_client_data_hooks
Definition diagnostic.h:969
void(* m_internal_error)(diagnostic_context *, const char *, va_list *)
Definition diagnostic.h:874
bool warning_enabled_at(location_t loc, diagnostic_option_id option_id)
Definition diagnostic.cc:1261
bool m_show_cwe
Definition diagnostic.h:807
diagnostic_text_finalizer_fn m_end_diagnostic
Definition diagnostic.h:869
void * m_client_aux_data
Definition diagnostic.h:894
void set_client_data_hooks(std::unique_ptr< diagnostic_client_data_hooks > hooks)
Definition diagnostic.cc:503
diagnostic_option_manager * m_option_mgr
Definition diagnostic.h:883
void set_prefixing_rule(diagnostic_prefixing_rule_t rule)
Definition diagnostic.cc:582
void set_warning_as_error_requested(bool val)
Definition diagnostic.h:612
location_t m_last_location
Definition diagnostic.h:897
void check_max_errors(bool flush)
Definition diagnostic.cc:854
friend diagnostic_start_span_fn & diagnostic_start_span(diagnostic_context *context)
Definition diagnostic.h:1014
unsigned get_lang_mask() const
Definition diagnostic.h:710
void pop_nesting_level()
Definition diagnostic.cc:1737
enum diagnostics_escape_format get_escape_format() const
Definition diagnostic.h:647
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:1280
void set_text_art_charset(enum diagnostic_text_art_charset charset)
Definition diagnostic.cc:1809
auto_vec< diagnostic_output_format * > m_output_sinks
Definition diagnostic.h:955
text_art::theme * m_theme
Definition diagnostic.h:978
bool m_inhibit_notes_p
Definition diagnostic.h:903
bool show_path_depths_p() const
Definition diagnostic.h:644
bool supports_fnotice_on_stderr_p() const
Definition diagnostic.cc:493
void color_init(int value)
Definition diagnostic.cc:310
bool m_warning_as_error_requested
Definition diagnostic.h:796
const diagnostic_client_data_hooks * get_client_data_hooks() const
Definition diagnostic.h:663
void set_show_option_requested(bool val)
Definition diagnostic.h:629
void set_original_argv(unique_argv original_argv)
Definition diagnostic.cc:511
void urls_init(int value)
Definition diagnostic.cc:341
bool bool bool report_diagnostic(diagnostic_info *)
Definition diagnostic.cc:1326
int m_n_opts
Definition diagnostic.h:800
bool diagnostic_impl(rich_location *, const diagnostic_metadata *, diagnostic_option_id, const char *, va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(5
Definition diagnostic.cc:1576
bool option_unspecified_p(diagnostic_option_id option_id) const
Definition diagnostic.h:557
diagnostic_t classify_diagnostic(diagnostic_option_id option_id, diagnostic_t new_kind, location_t where)
Definition diagnostic.h:579
file_cache & get_file_cache() const
Definition diagnostic.h:653
bool option_enabled_p(diagnostic_option_id option_id) const
Definition diagnostic.h:681
void pop_diagnostics(location_t where)
Definition diagnostic.h:593
bool m_pedantic_errors
Definition diagnostic.h:830
text_art::theme * get_diagram_theme() const
Definition diagnostic.h:669
int m_column_origin
Definition diagnostic.h:921
bool m_fatal_errors
Definition diagnostic.h:840
bool m_permissive
Definition diagnostic.h:833
struct diagnostic_context::@16 m_text_callbacks
void(* m_adjust_diagnostic_info)(diagnostic_context *, diagnostic_info *)
Definition diagnostic.h:878
unsigned m_lang_mask
Definition diagnostic.h:884
void create_edit_context()
Definition diagnostic.cc:599
void override_urlifier(urlifier *)
Definition diagnostic.cc:593
diagnostic_buffer * get_diagnostic_buffer() const
Definition diagnostic.h:744
enum diagnostics_column_unit m_column_unit
Definition diagnostic.h:918
void emit_diagram(const diagnostic_diagram &diagram)
Definition diagnostic.cc:1633
int m_lock
Definition diagnostic.h:900
void set_report_bug(bool val)
Definition diagnostic.h:616
bool m_show_rules
Definition diagnostic.h:810
void set_show_cwe(bool val)
Definition diagnostic.h:621
void clear_diagnostic_buffer(diagnostic_buffer &)
Definition diagnostic.cc:1876
bool bool int get_diagnostic_nesting_level() const
Definition diagnostic.h:723
int m_max_errors
Definition diagnostic.h:850
bool m_abort_on_error
Definition diagnostic.h:824
void maybe_show_locus(const rich_location &richloc, diagnostic_t diagnostic_kind, pretty_printer &pp, diagnostic_source_effect_info *effect_info)
Definition diagnostic-show-locus.cc:3266
edit_context * m_edit_context_ptr
Definition diagnostic.h:935
diagnostic_source_printing_options m_source_printing
Definition diagnostic.h:905
int m_opt_permissive
Definition diagnostic.h:837
bool warning_as_error_requested_p() const
Definition diagnostic.h:640
void(*) set_locations_callback_t(diagnostic_context *, diagnostic_info *)
Definition diagnostic.h:518
void set_extra_output_kind(enum diagnostics_extra_output_kind kind)
Definition diagnostic.h:617
int m_group_nesting_depth
Definition diagnostic.h:940
void set_show_highlight_colors(bool val)
Definition diagnostic.cc:573
diagnostic_buffer * m_diagnostic_buffer
Definition diagnostic.h:992
void initialize_input_context(diagnostic_input_charset_callback ccb, bool should_skip_bom)
Definition diagnostic.cc:373
Definition diagnostic-diagram.h:33
Definition diagnostic.h:382
diagnostic_location_print_policy(const diagnostic_context &dc)
Definition diagnostic.cc:727
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:197
diagnostic_t update_effective_level_from_pragmas(diagnostic_info *diagnostic) const
Definition diagnostic.cc:1162
vec< int > m_push_list
Definition diagnostic.h:301
void fini()
Definition diagnostic.cc:142
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:206
diagnostic_t classify_diagnostic(const diagnostic_context *context, diagnostic_option_id option_id, diagnostic_t new_kind, location_t where)
Definition diagnostic.cc:997
diagnostic_t * m_classify_diagnostic
Definition diagnostic.h:291
int pch_restore(FILE *)
Definition diagnostic.cc:174
diagnostic_t get_current_override(diagnostic_option_id option_id) const
Definition diagnostic.h:249
void init(int n_opts)
Definition diagnostic.cc:131
int pch_save(FILE *)
Definition diagnostic.cc:154
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:447
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:3311
file_cache & m_file_cache
Definition diagnostic.h:444
diagnostic_start_span_fn m_start_span_cb
Definition diagnostic.h:443
file_cache & get_file_cache() const
Definition diagnostic.h:419
text_art::theme * get_diagram_theme() const
Definition diagnostic.h:428
diagnostic_source_print_policy(const diagnostic_context &)
Definition diagnostic-show-locus.cc:3295
enum diagnostics_escape_format m_escape_format
Definition diagnostic.h:448
class diagnostic_location_print_policy m_location_policy
Definition diagnostic.h:442
const diagnostic_source_printing_options & get_options() const
Definition diagnostic.h:413
diagnostic_start_span_fn get_start_span_fn() const
Definition diagnostic.h:416
const diagnostic_source_printing_options & m_options
Definition diagnostic.h:441
const diagnostic_location_print_policy & get_location_policy() const
Definition diagnostic.h:435
enum diagnostics_escape_format get_escape_format() const
Definition diagnostic.h:422
const diagnostic_column_policy & get_column_policy() const
Definition diagnostic.h:430
Definition diagnostic-format-text.h:33
Definition edit-context.h:44
Definition input.h:136
Definition logical-location.h:55
Definition pretty-print.h:241
virtual std::unique_ptr< pretty_printer > clone() const
Definition pretty-print.cc:2522
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:105
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:100
void diagnostic_set_caret_max_width(diagnostic_context *context, int value)
Definition diagnostic.cc:117
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:1208
location_t diagnostic_location(const diagnostic_info *diagnostic, int which=0)
Definition diagnostic.h:1194
const int CARET_LINE_MARGIN
Definition diagnostic.h:1220
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:620
diagnostic_t diagnostic_classify_diagnostic(diagnostic_context *context, diagnostic_option_id option_id, diagnostic_t kind, location_t where)
Definition diagnostic.h:1132
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:1123
diagnostic_text_starter_fn & diagnostic_text_starter(diagnostic_context *context)
Definition diagnostic.h:1005
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:1083
void diagnostic_abort_on_error(diagnostic_context *context)
Definition diagnostic.h:1033
void diagnostic_show_locus(diagnostic_context *context, rich_location *richloc, diagnostic_t diagnostic_kind, pretty_printer *pp, diagnostic_source_effect_info *effect_info=nullptr)
Definition diagnostic.h:1095
diagnostic_text_finalizer_fn & diagnostic_text_finalizer(diagnostic_context *context)
Definition diagnostic.h:1022
void diagnostic_inhibit_notes(diagnostic_context *context)
Definition diagnostic.h:996
int get_terminal_width(void)
Definition diagnostic.cc:96
const char * diagnostic_get_color_for_kind(diagnostic_t kind)
Definition diagnostic.cc:646
void default_diagnostic_text_finalizer(diagnostic_text_output_format &, const diagnostic_info *, diagnostic_t)
Definition diagnostic-format-text.cc:714
void default_diagnostic_start_span_fn(const diagnostic_location_print_policy &, pretty_printer *, expanded_location)
Definition diagnostic.cc:977
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:1212
diagnostic_start_span_fn & diagnostic_start_span(diagnostic_context *context)
Definition diagnostic.h:1014
const char * get_diagnostic_kind_text(diagnostic_t kind)
Definition diagnostic.cc:751
int num_digits(int)
Definition diagnostic.cc:1524
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:1251
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:79
void diagnostic_finish(diagnostic_context *context)
Definition diagnostic.h:1089
bool warning_enabled_at(location_t loc, diagnostic_option_id option_id)
Definition diagnostic.h:1245
diagnostic_context * global_dc
Definition diagnostic-global-context.cc:34
unsigned int diagnostic_num_locations(const diagnostic_info *diagnostic)
Definition diagnostic.h:1202
void diagnostic_initialize(diagnostic_context *context, int n_opts)
Definition diagnostic.h:1071
void diagnostic_set_option_id(diagnostic_info *info, diagnostic_option_id option_id)
Definition diagnostic.h:1062
void diagnostic_color_init(diagnostic_context *context, int value=-1)
Definition diagnostic.h:1077
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:1147
void diagnostic_push_diagnostics(diagnostic_context *context, location_t where)
Definition diagnostic.h:1141
bool diagnostic_same_line(const diagnostic_context *context, expanded_location s1, expanded_location s2)
Definition diagnostic.h:1227
bool diagnostic_report_diagnostic(diagnostic_context *context, diagnostic_info *diagnostic)
Definition diagnostic.h:1161
void void void default_diagnostic_text_starter(diagnostic_text_output_format &, const diagnostic_info *)
Definition diagnostic-format-text.cc:705
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:456
void clear()
Definition diagnostic.cc:1940
diagnostic_counters()
Definition diagnostic.cc:1908
void move_to(diagnostic_counters &dest)
Definition diagnostic.cc:1932
int get_count(diagnostic_t kind) const
Definition diagnostic.h:462
int m_count_for_kind[DK_LAST_DIAGNOSTIC_KIND]
Definition diagnostic.h:467
void DEBUG_FUNCTION dump() const
Definition diagnostic.h:460
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:723
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