1 /* Classes for analyzer diagnostics.
2 Copyright (C) 2019-2021 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
26 #include "diagnostic.h"
29 #include "analyzer/analyzer.h"
30 #include "diagnostic-event-id.h"
31 #include "analyzer/analyzer-logging.h"
32 #include "analyzer/sm.h"
33 #include "diagnostic-event-id.h"
34 #include "analyzer/sm.h"
35 #include "analyzer/pending-diagnostic.h"
41 /* Generate a label_text by printing FMT.
43 Use a clone of the global_dc for formatting callbacks.
45 Use this evdesc::event_desc's m_colorize flag to control colorization
46 (so that e.g. we can disable it for JSON output). */
49 evdesc::event_desc::formatted_print (const char *fmt
, ...) const
51 pretty_printer
*pp
= global_dc
->printer
->clone ();
53 pp_show_color (pp
) = m_colorize
;
56 rich_location
rich_loc (line_table
, UNKNOWN_LOCATION
);
59 ti
.format_spec
= _(fmt
);
63 ti
.m_richloc
= &rich_loc
;
65 pp_output_formatted_text (pp
);
68 label_text result
= label_text::take (xstrdup (pp_formatted_text (pp
)));
73 /* Return true if T1 and T2 are "the same" for the purposes of
74 diagnostic deduplication. */
77 pending_diagnostic::same_tree_p (tree t1
, tree t2
)
79 return simple_cst_equal (t1
, t2
) == 1;
84 #endif /* #if ENABLE_ANALYZER */