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, 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. */
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;
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:
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 void set_urlifier (std::unique_ptr<urlifier>);
614 void create_edit_context ();
616 {
618 }
619 void set_report_bug (bool val) { m_report_bug = val; }
624 void set_show_cwe (bool val) { m_show_cwe = val; }
625 void set_show_rules (bool val) { m_show_rules = val; }
626 void set_show_highlight_colors (bool val);
628 {
629 m_path_format = val;
630 }
631 void set_show_path_depths (bool val) { m_show_path_depths = val; }
633 void set_max_errors (int val) { m_max_errors = val; }
635 {
636 m_escape_format = val;
637 }
638
639 void set_format_decoder (printer_fn format_decoder);
641
642 /* Various accessors. */
644 {
646 }
647 bool show_path_depths_p () const { return m_show_path_depths; }
651 {
652 return m_escape_format;
653 }
654
655 file_cache &
657 {
659 return *m_file_cache;
660 }
661
663 {
664 return m_edit_context_ptr;
665 }
670 urlifier *get_urlifier () const { return m_urlifier; }
671
672 text_art::theme *get_diagram_theme () const { return m_diagrams.m_theme; }
673
675 {
676 return m_diagnostic_counters.m_count_for_kind[kind];
677 }
679 {
680 return m_diagnostic_counters.get_count (kind);
681 }
682
683 /* Option-related member functions. */
684 inline bool option_enabled_p (diagnostic_option_id option_id) const
685 {
686 if (!m_option_mgr)
687 return true;
688 return m_option_mgr->option_enabled_p (option_id);
689 }
690
691 inline char *make_option_name (diagnostic_option_id option_id,
692 diagnostic_t orig_diag_kind,
693 diagnostic_t diag_kind) const
694 {
695 if (!m_option_mgr)
696 return nullptr;
697 return m_option_mgr->make_option_name (option_id,
698 orig_diag_kind,
699 diag_kind);
700 }
701
702 inline char *make_option_url (diagnostic_option_id option_id) const
703 {
704 if (!m_option_mgr)
705 return nullptr;
706 return m_option_mgr->make_option_url (option_id);
707 }
708
709 void
710 set_option_manager (std::unique_ptr<diagnostic_option_manager> mgr,
711 unsigned lang_mask);
712
713 unsigned get_lang_mask () const
714 {
715 return m_lang_mask;
716 }
717
718 bool diagnostic_impl (rich_location *, const diagnostic_metadata *,
719 diagnostic_option_id, const char *,
720 va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0);
721 bool diagnostic_n_impl (rich_location *, const diagnostic_metadata *,
722 diagnostic_option_id, unsigned HOST_WIDE_INT,
723 const char *, const char *, va_list *,
725
727 {
728 return m_diagnostic_groups.m_diagnostic_nesting_level;
729 }
730
731 char *build_indent_prefix () const;
732
733 int
734 pch_save (FILE *f)
735 {
736 return m_option_classifier.pch_save (f);
737 }
738
739 int
740 pch_restore (FILE *f)
741 {
742 return m_option_classifier.pch_restore (f);
743 }
744
745
753
754 std::unique_ptr<pretty_printer> clone_printer () const
755 {
756 return m_reference_printer->clone ();
757 }
758
763
764 void
765 add_sink (std::unique_ptr<diagnostic_output_format>);
766
768
769 bool supports_fnotice_on_stderr_p () const;
770
771private:
773
775
777
778 void check_max_errors (bool flush);
779 void action_after_output (diagnostic_t diag_kind);
780
781 /* Data members.
782 Ideally, all of these would be private. */
783
784private:
785 /* A reference instance of pretty_printer created by the client
786 and owned by the context. Used for cloning when creating/adding
787 output formats.
788 Owned by the context; this would be a std::unique_ptr if
789 diagnostic_context had a proper ctor. */
791
792 /* Cache of source code.
793 Owned by the context; this would be a std::unique_ptr if
794 diagnostic_context had a proper ctor. */
796
797 /* The number of times we have issued diagnostics. */
799
800 /* True if it has been requested that warnings be treated as errors. */
802
803 /* The number of option indexes that can be passed to warning() et
804 al. */
806
807 /* The stack of sets of overridden diagnostic option severities. */
809
810 /* True if we should print any CWE identifiers associated with
811 diagnostics. */
813
814 /* True if we should print any rules associated with diagnostics. */
816
817 /* How should diagnostic_path objects be printed. */
819
820 /* True if we should print stack depths when printing diagnostic paths. */
822
823 /* True if we should print the command line option which controls
824 each diagnostic, if known. */
826
827public:
828 /* True if we should raise a SIGABRT on errors. */
830
831 /* True if we should show the column number on diagnostics. */
833
834 /* True if pedwarns are errors. */
836
837 /* True if permerrors are warnings. */
839
840 /* The index of the option to associate with turning permerrors into
841 warnings. */
843
844 /* True if errors are fatal. */
846
847 /* True if all warnings should be disabled. */
849
850 /* True if warnings should be given in system headers. */
852
853private:
854 /* Maximum number of errors to report. */
856
857 /* Client-supplied callbacks for use in text output. */
858 struct {
859 /* This function is called before any message is printed out. It is
860 responsible for preparing message prefix and such. For example, it
861 might say:
862 In file included from "/usr/local/include/curses.h:5:
863 from "/home/gdr/src/nifty_printer.h:56:
864 ...
865 */
867
868 /* This function is called by diagnostic_show_locus in between
869 disjoint spans of source code, so that the context can print
870 something to indicate that a new span of source code has begun. */
872
873 /* This function is called after the diagnostic message is printed. */
876
877public:
878 /* Client hook to report an internal error. */
879 void (*m_internal_error) (diagnostic_context *, const char *, va_list *);
880
881 /* Client hook to adjust properties of the given diagnostic that we're
882 about to issue, such as its kind. */
884
885private:
886 /* Owned by the context; this would be a std::unique_ptr if
887 diagnostic_context had a proper ctor. */
889 unsigned m_lang_mask;
890
891 /* An optional hook for adding URLs to quoted text strings in
892 diagnostics. Only used for the main diagnostic message.
893 Owned by the context; this would be a std::unique_ptr if
894 diagnostic_context had a proper ctor. */
896
897public:
898 /* Auxiliary data for client. */
900
901 /* Used to detect that the last caret was printed at the same location. */
902 location_t m_last_location;
903
904private:
906
907public:
909
911
912private:
913 /* True if -freport-bug option is used. */
915
916 /* Used to specify additional diagnostic output to be emitted after the
917 rest of the diagnostic. This is for implementing
918 -fdiagnostics-parseable-fixits and GCC_EXTRA_DIAGNOSTIC_OUTPUT. */
920
921public:
922 /* What units to use when outputting the column number. */
924
925 /* The origin for the column number (1-based or 0-based typically). */
927
928 /* The size of the tabstop for tab expansion. */
930
931private:
932 /* How should non-ASCII/non-printable bytes be escaped when
933 a diagnostic suggests escaping the source code on output. */
935
936 /* If non-NULL, an edit_context to which fix-it hints should be
937 applied, for generating patches.
938 Owned by the context; this would be a std::unique_ptr if
939 diagnostic_context had a proper ctor. */
941
942 /* Fields relating to diagnostic groups. */
943 struct {
944 /* How many diagnostic_group instances are currently alive. */
946
947 /* How many nesting levels have been pushed within this group. */
949
950 /* How many diagnostics have been emitted since the bottommost
951 diagnostic_group was pushed. */
954
955 /* The various sinks to which diagnostics are to be outputted
956 (text vs structured formats such as SARIF).
957 The sinks are owned by the context; this would be a
958 std::vector<std::unique_ptr> if diagnostic_context had a
959 proper ctor. */
961
962 /* Callback to set the locations of call sites along the inlining
963 stack corresponding to a diagnostic location. Needed to traverse
964 the BLOCK_SUPERCONTEXT() chain hanging off the LOCATION_BLOCK()
965 of a diagnostic's location. */
967
968 /* A bundle of hooks for providing data to the context about its client
969 e.g. version information, plugins, etc.
970 Used by SARIF output to give metadata about the client that's
971 producing diagnostics.
972 Owned by the context; this would be a std::unique_ptr if
973 diagnostic_context had a proper ctor. */
975
976 /* Support for diagrams. */
977 struct
978 {
979 /* Theme to use when generating diagrams.
980 Can be NULL (if text art is disabled).
981 Owned by the context; this would be a std::unique_ptr if
982 diagnostic_context had a proper ctor. */
983 text_art::theme *m_theme;
984
986
987 /* Owned by the context. */
989
990 /* Borrowed pointer to the active diagnostic_buffer, if any.
991 If null (the default), then diagnostics that are reported to the
992 context are immediately issued to the output format.
993 If non-null, then diagnostics that are reported to the context
994 are buffered in the buffer, and may be issued to the output format
995 later (if the buffer is flushed), moved to other buffers, or
996 discarded (if the buffer is cleared). */
998};
999
1000inline void
1002{
1003 context->m_inhibit_notes_p = true;
1004}
1005
1006
1007/* Client supplied function to announce a diagnostic
1008 (for text-based diagnostic output). */
1014
1015/* Client supplied function called between disjoint spans of source code,
1016 so that the context can print
1017 something to indicate that a new span of source code has begun. */
1020{
1021 return context->m_text_callbacks.m_start_span;
1022}
1023
1024/* Client supplied function called after a diagnostic message is
1025 displayed (for text-based diagnostic output). */
1031
1032/* Extension hooks for client. */
1033#define diagnostic_context_auxiliary_data(DC) (DC)->m_client_aux_data
1034#define diagnostic_info_auxiliary_data(DI) (DI)->x_data
1035
1036/* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher. */
1037inline void
1039{
1040 context->m_abort_on_error = true;
1041}
1042
1043/* This diagnostic_context is used by front-ends that directly output
1044 diagnostic messages without going through `error', `warning',
1045 and similar functions. */
1047
1048/* The number of errors that have been issued so far. Ideally, these
1049 would take a diagnostic_context as an argument. */
1050#define errorcount global_dc->diagnostic_count (DK_ERROR)
1051/* Similarly, but for warnings. */
1052#define warningcount global_dc->diagnostic_count (DK_WARNING)
1053/* Similarly, but for warnings promoted to errors. */
1054#define werrorcount global_dc->diagnostic_count (DK_WERROR)
1055/* Similarly, but for sorrys. */
1056#define sorrycount global_dc->diagnostic_count (DK_SORRY)
1057
1058/* Returns nonzero if warnings should be emitted. */
1059#define diagnostic_report_warnings_p(DC, LOC) \
1060 (!(DC)->m_inhibit_warnings \
1061 && !(in_system_header_at (LOC) && !(DC)->m_warn_system_headers))
1062
1063/* Override the option index to be used for reporting a
1064 diagnostic. */
1065
1066inline void
1068 diagnostic_option_id option_id)
1069{
1070 info->option_id = option_id;
1071}
1072
1073/* Diagnostic related functions. */
1074
1075inline void
1077{
1078 context->initialize (n_opts);
1079}
1080
1081inline void
1083{
1084 context->color_init (value);
1085}
1086
1087inline void
1089{
1090 context->urls_init (value);
1091}
1092
1093inline void
1095{
1096 context->finish ();
1097}
1098
1099inline void
1102 rich_location *richloc,
1103 diagnostic_t diagnostic_kind,
1104 pretty_printer *pp,
1105 diagnostic_source_effect_info *effect_info = nullptr)
1106{
1107 gcc_assert (context);
1108 gcc_assert (richloc);
1109 gcc_assert (pp);
1110 context->maybe_show_locus (*richloc, opts, diagnostic_kind, *pp, effect_info);
1111}
1112
1113/* Because we read source files a second time after the frontend did it the
1114 first time, we need to know how the frontend handled things like character
1115 set conversion and UTF-8 BOM stripping, in order to make everything
1116 consistent. This function needs to be called by each frontend that requires
1117 non-default behavior, to inform the diagnostics infrastructure how input is
1118 to be processed. The default behavior is to do no conversion and not to
1119 strip a UTF-8 BOM.
1120
1121 The callback should return the input charset to be used to convert the given
1122 file's contents to UTF-8, or it should return NULL if no conversion is needed
1123 for this file. SHOULD_SKIP_BOM only applies in case no conversion was
1124 performed, and if true, it will cause a UTF-8 BOM to be skipped at the
1125 beginning of the file. (In case a conversion was performed, the BOM is
1126 rather skipped as part of the conversion process.) */
1127
1128inline void
1131 bool should_skip_bom)
1132{
1133 context->initialize_input_context (ccb, should_skip_bom);
1134}
1135
1136/* Force diagnostics controlled by OPTIDX to be kind KIND. */
1137inline diagnostic_t
1139 diagnostic_option_id option_id,
1140 diagnostic_t kind,
1141 location_t where)
1142{
1143 return context->classify_diagnostic (option_id, kind, where);
1144}
1145
1146inline void
1148 location_t where)
1149{
1150 context->push_diagnostics (where);
1151}
1152inline void
1154 location_t where)
1155{
1156 context->pop_diagnostics (where);
1157}
1158
1159/* Report a diagnostic message (an error or a warning) as specified by
1160 DC. This function is *the* subroutine in terms of which front-ends
1161 should implement their specific diagnostic handling modules. The
1162 front-end independent format specifiers are exactly those described
1163 in the documentation of output_format.
1164 Return true if a diagnostic was printed, false otherwise. */
1165
1166inline bool
1169{
1170 context->begin_group ();
1171 bool warned = context->report_diagnostic (diagnostic);
1172 context->end_group ();
1173 return warned;
1174}
1175
1176#ifdef ATTRIBUTE_GCC_DIAG
1177extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *,
1178 rich_location *, diagnostic_t) ATTRIBUTE_GCC_DIAG(2,0);
1180 va_list *, rich_location *,
1182 ATTRIBUTE_GCC_DIAG(2,0);
1183#endif
1185 const diagnostic_info *);
1188 expanded_location);
1190 const diagnostic_info *,
1191 diagnostic_t);
1192void diagnostic_set_caret_max_width (diagnostic_context *context, int value);
1193
1194int get_terminal_width (void);
1195
1196/* Return the location associated to this diagnostic. Parameter WHICH
1197 specifies which location. By default, expand the first one. */
1198
1199inline location_t
1201{
1202 return diagnostic->message.get_location (which);
1203}
1204
1205/* Return the number of locations to be printed in DIAGNOSTIC. */
1206
1207inline unsigned int
1209{
1210 return diagnostic->message.m_richloc->get_num_locations ();
1211}
1212
1213/* Expand the location of this diagnostic. Use this function for
1214 consistency. Parameter WHICH specifies which location. By default,
1215 expand the first one. */
1216
1217inline expanded_location
1219{
1220 return diagnostic->richloc->get_expanded_location (which);
1221}
1222
1223/* This is somehow the right-side margin of a caret line, that is, we
1224 print at least these many characters after the position pointed at
1225 by the caret. */
1226const int CARET_LINE_MARGIN = 10;
1227
1228/* Return true if the two locations can be represented within the same
1229 caret line. This is used to build a prefix and also to determine
1230 whether to print one or two caret lines. */
1231
1232inline bool
1234 expanded_location s1, expanded_location s2)
1235{
1236 return (s2.column && s1.line == s2.line
1238 > abs (s1.column - s2.column)));
1239}
1240
1241extern const char *diagnostic_get_color_for_kind (diagnostic_t kind);
1242
1243/* Pure text formatting support functions. */
1244
1245extern char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1;
1246
1247/* Compute the number of digits in the decimal representation of an integer. */
1248extern int num_digits (int);
1249
1250inline bool
1251warning_enabled_at (location_t loc, diagnostic_option_id option_id)
1252{
1253 return global_dc->warning_enabled_at (loc, option_id);
1254}
1255
1256inline bool
1258{
1259 return global_dc->option_unspecified_p (option_id);
1260}
1261
1262extern char *get_cwe_url (int cwe);
1263
1264extern const char *get_diagnostic_kind_text (diagnostic_t kind);
1265
1266const char *maybe_line_and_column (int line, int col);
1267
1268#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:723
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:699
int converted_column(expanded_location s) const
Definition diagnostic.cc:711
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:895
friend class diagnostic_source_print_policy
Definition diagnostic.h:516
int diagnostic_count(diagnostic_t kind) const
Definition diagnostic.h:678
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:1321
int m_tabstop
Definition diagnostic.h:929
void initialize(int n_opts)
Definition diagnostic.cc:222
file_cache * m_file_cache
Definition diagnostic.h:795
bool execution_failed_p() const
Definition diagnostic.cc:470
void set_show_rules(bool val)
Definition diagnostic.h:625
void get_any_inlining_info(diagnostic_info *diagnostic)
Definition diagnostic.cc:1151
enum diagnostic_path_format m_path_format
Definition diagnostic.h:818
void finish()
Definition diagnostic.cc:383
void set_urlifier(std::unique_ptr< urlifier >)
Definition diagnostic.cc:552
pretty_printer * get_reference_printer() const
Definition diagnostic.h:759
void end_group()
Definition diagnostic.cc:1734
void error_recursion() ATTRIBUTE_NORETURN
Definition diagnostic.cc:1666
int m_diagnostic_nesting_level
Definition diagnostic.h:948
void set_escape_format(enum diagnostics_escape_format val)
Definition diagnostic.h:634
bool diagnostic_enabled(diagnostic_info *diagnostic)
Definition diagnostic.cc:1235
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:825
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:914
void remove_all_output_sinks()
Definition diagnostic.cc:480
void refresh_output_sinks()
Definition diagnostic.cc:573
edit_context * get_edit_context() const
Definition diagnostic.h:662
void push_nesting_level()
Definition diagnostic.cc:1749
void set_format_decoder(printer_fn format_decoder)
Definition diagnostic.cc:583
void set_path_format(enum diagnostic_path_format val)
Definition diagnostic.h:627
friend diagnostic_text_starter_fn & diagnostic_text_starter(diagnostic_context *context)
Definition diagnostic.h:1010
void set_diagnostic_buffer(diagnostic_buffer *)
Definition diagnostic.cc:1860
void set_max_errors(int val)
Definition diagnostic.h:633
diagnostic_start_span_fn m_start_span
Definition diagnostic.h:871
friend class diagnostic_text_output_format
Definition diagnostic.h:517
int pch_restore(FILE *f)
Definition diagnostic.h:740
void set_option_manager(std::unique_ptr< diagnostic_option_manager > mgr, unsigned lang_mask)
Definition diagnostic.cc:543
enum diagnostics_extra_output_kind m_extra_output_kind
Definition diagnostic.h:919
bool m_inhibit_warnings
Definition diagnostic.h:848
int m_emission_count
Definition diagnostic.h:952
friend diagnostic_text_finalizer_fn & diagnostic_text_finalizer(diagnostic_context *context)
Definition diagnostic.h:1027
diagnostic_output_format & get_output_format(size_t idx) const
Definition diagnostic.cc:495
bool m_show_column
Definition diagnostic.h:832
void add_sink(std::unique_ptr< diagnostic_output_format >)
Definition diagnostic.cc:503
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:1620
struct diagnostic_context::@144115345167042231333361231316114173002254305105 m_diagrams
diagnostic_option_classifier m_option_classifier
Definition diagnostic.h:808
void report_verbatim(text_info &)
Definition diagnostic.cc:1526
bool m_show_path_depths
Definition diagnostic.h:821
int & diagnostic_count(diagnostic_t kind)
Definition diagnostic.h:674
char * make_option_url(diagnostic_option_id option_id) const
Definition diagnostic.h:702
void push_diagnostics(location_t where)
Definition diagnostic.h:591
void begin_group()
Definition diagnostic.cc:1728
enum diagnostics_escape_format m_escape_format
Definition diagnostic.h:934
set_locations_callback_t m_set_locations_cb
Definition diagnostic.h:966
void set_output_format(std::unique_ptr< diagnostic_output_format > output_format)
Definition diagnostic.cc:488
void set_show_path_depths(bool val)
Definition diagnostic.h:631
char * make_option_name(diagnostic_option_id option_id, diagnostic_t orig_diag_kind, diagnostic_t diag_kind) const
Definition diagnostic.h:691
diagnostic_counters m_diagnostic_counters
Definition diagnostic.h:798
std::unique_ptr< pretty_printer > clone_printer() const
Definition diagnostic.h:754
const char *const * get_original_argv()
Definition diagnostic.h:537
urlifier * get_urlifier() const
Definition diagnostic.h:670
void set_pretty_printer(std::unique_ptr< pretty_printer > pp)
Definition diagnostic.cc:563
urlifier * m_urlifier
Definition diagnostic.h:895
bool m_warn_system_headers
Definition diagnostic.h:851
char * build_indent_prefix() const
void flush_diagnostic_buffer(diagnostic_buffer &)
Definition diagnostic.cc:1910
diagnostic_text_starter_fn m_begin_diagnostic
Definition diagnostic.h:866
enum diagnostic_path_format get_path_format() const
Definition diagnostic.h:649
int pch_save(FILE *f)
Definition diagnostic.h:734
pretty_printer * m_reference_printer
Definition diagnostic.h:790
char ** m_original_argv
Definition diagnostic.h:988
diagnostic_client_data_hooks * m_client_data_hooks
Definition diagnostic.h:974
void(* m_internal_error)(diagnostic_context *, const char *, va_list *)
Definition diagnostic.h:879
bool warning_enabled_at(location_t loc, diagnostic_option_id option_id)
Definition diagnostic.cc:1279
bool m_show_cwe
Definition diagnostic.h:812
diagnostic_text_finalizer_fn m_end_diagnostic
Definition diagnostic.h:874
void * m_client_aux_data
Definition diagnostic.h:899
void set_client_data_hooks(std::unique_ptr< diagnostic_client_data_hooks > hooks)
Definition diagnostic.cc:521
diagnostic_option_manager * m_option_mgr
Definition diagnostic.h:888
void set_prefixing_rule(diagnostic_prefixing_rule_t rule)
Definition diagnostic.cc:600
void set_warning_as_error_requested(bool val)
Definition diagnostic.h:615
location_t m_last_location
Definition diagnostic.h:902
void check_max_errors(bool flush)
Definition diagnostic.cc:872
friend diagnostic_start_span_fn & diagnostic_start_span(diagnostic_context *context)
Definition diagnostic.h:1019
unsigned get_lang_mask() const
Definition diagnostic.h:713
void pop_nesting_level()
Definition diagnostic.cc:1755
enum diagnostics_escape_format get_escape_format() const
Definition diagnostic.h:650
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:1298
void set_text_art_charset(enum diagnostic_text_art_charset charset)
Definition diagnostic.cc:1827
auto_vec< diagnostic_output_format * > m_output_sinks
Definition diagnostic.h:960
text_art::theme * m_theme
Definition diagnostic.h:983
bool m_inhibit_notes_p
Definition diagnostic.h:908
bool show_path_depths_p() const
Definition diagnostic.h:647
bool supports_fnotice_on_stderr_p() const
Definition diagnostic.cc:511
void color_init(int value)
Definition diagnostic.cc:311
bool m_warning_as_error_requested
Definition diagnostic.h:801
const diagnostic_client_data_hooks * get_client_data_hooks() const
Definition diagnostic.h:666
void set_show_option_requested(bool val)
Definition diagnostic.h:632
void set_original_argv(unique_argv original_argv)
Definition diagnostic.cc:529
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:1344
int m_n_opts
Definition diagnostic.h:805
bool diagnostic_impl(rich_location *, const diagnostic_metadata *, diagnostic_option_id, const char *, va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(5
Definition diagnostic.cc:1594
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:656
bool option_enabled_p(diagnostic_option_id option_id) const
Definition diagnostic.h:684
void pop_diagnostics(location_t where)
Definition diagnostic.h:595
bool m_pedantic_errors
Definition diagnostic.h:835
text_art::theme * get_diagram_theme() const
Definition diagnostic.h:672
int m_column_origin
Definition diagnostic.h:926
bool m_fatal_errors
Definition diagnostic.h:845
bool m_permissive
Definition diagnostic.h:838
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:883
unsigned m_lang_mask
Definition diagnostic.h:889
void create_edit_context()
Definition diagnostic.cc:617
void override_urlifier(urlifier *)
Definition diagnostic.cc:611
diagnostic_buffer * get_diagnostic_buffer() const
Definition diagnostic.h:747
enum diagnostics_column_unit m_column_unit
Definition diagnostic.h:923
void emit_diagram(const diagnostic_diagram &diagram)
Definition diagnostic.cc:1651
int m_lock
Definition diagnostic.h:905
void set_report_bug(bool val)
Definition diagnostic.h:619
bool m_show_rules
Definition diagnostic.h:815
void set_show_cwe(bool val)
Definition diagnostic.h:624
void clear_diagnostic_buffer(diagnostic_buffer &)
Definition diagnostic.cc:1894
bool bool int get_diagnostic_nesting_level() const
Definition diagnostic.h:726
int m_max_errors
Definition diagnostic.h:855
bool m_abort_on_error
Definition diagnostic.h:829
edit_context * m_edit_context_ptr
Definition diagnostic.h:940
diagnostic_source_printing_options m_source_printing
Definition diagnostic.h:910
int m_opt_permissive
Definition diagnostic.h:842
bool warning_as_error_requested_p() const
Definition diagnostic.h:643
void set_extra_output_kind(enum diagnostics_extra_output_kind kind)
Definition diagnostic.h:620
int m_group_nesting_depth
Definition diagnostic.h:945
void set_show_highlight_colors(bool val)
Definition diagnostic.cc:591
diagnostic_buffer * m_diagnostic_buffer
Definition diagnostic.h:997
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:745
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:1180
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:1015
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: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:55
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: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
diagnostic_context * global_dc
Definition diagnostic-global-context.cc:34
int num_digits(int value)
Definition diagnostic.cc:1542
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:1226
location_t diagnostic_location(const diagnostic_info *diagnostic, int which=0)
Definition diagnostic.h:1200
const int CARET_LINE_MARGIN
Definition diagnostic.h:1226
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:623
diagnostic_t diagnostic_classify_diagnostic(diagnostic_context *context, diagnostic_option_id option_id, diagnostic_t kind, location_t where)
Definition diagnostic.h:1138
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:1129
diagnostic_text_starter_fn & diagnostic_text_starter(diagnostic_context *context)
Definition diagnostic.h:1010
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:1088
void diagnostic_abort_on_error(diagnostic_context *context)
Definition diagnostic.h:1038
diagnostic_text_finalizer_fn & diagnostic_text_finalizer(diagnostic_context *context)
Definition diagnostic.h:1027
void diagnostic_inhibit_notes(diagnostic_context *context)
Definition diagnostic.h:1001
int get_terminal_width(void)
Definition diagnostic.cc:96
const char * diagnostic_get_color_for_kind(diagnostic_t kind)
Definition diagnostic.cc:664
void default_diagnostic_text_finalizer(diagnostic_text_output_format &, const diagnostic_info *, diagnostic_t)
Definition diagnostic-format-text.cc:717
void default_diagnostic_start_span_fn(const diagnostic_location_print_policy &, pretty_printer *, expanded_location)
Definition diagnostic.cc:995
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:1218
diagnostic_start_span_fn & diagnostic_start_span(diagnostic_context *context)
Definition diagnostic.h:1019
const char * get_diagnostic_kind_text(diagnostic_t kind)
Definition diagnostic.cc:769
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:1257
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:1094
bool warning_enabled_at(location_t loc, diagnostic_option_id option_id)
Definition diagnostic.h:1251
unsigned int diagnostic_num_locations(const diagnostic_info *diagnostic)
Definition diagnostic.h:1208
void diagnostic_initialize(diagnostic_context *context, int n_opts)
Definition diagnostic.h:1076
void diagnostic_set_option_id(diagnostic_info *info, diagnostic_option_id option_id)
Definition diagnostic.h:1067
void diagnostic_color_init(diagnostic_context *context, int value=-1)
Definition diagnostic.h:1082
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:1100
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:1153
void diagnostic_push_diagnostics(diagnostic_context *context, location_t where)
Definition diagnostic.h:1147
bool diagnostic_same_line(const diagnostic_context *context, expanded_location s1, expanded_location s2)
Definition diagnostic.h:1233
bool diagnostic_report_diagnostic(diagnostic_context *context, diagnostic_info *diagnostic)
Definition diagnostic.h:1167
void void void default_diagnostic_text_starter(diagnostic_text_output_format &, const diagnostic_info *)
Definition diagnostic-format-text.cc:708
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:458
void clear()
Definition diagnostic.cc:1958
diagnostic_counters()
Definition diagnostic.cc:1926
void move_to(diagnostic_counters &dest)
Definition diagnostic.cc:1950
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:824
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