1 /* Classes for analyzer diagnostics.
2 Copyright (C) 2019-2020 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"
28 #include "analyzer/analyzer.h"
29 #include "diagnostic-event-id.h"
30 #include "analyzer/analyzer-logging.h"
31 #include "analyzer/sm.h"
32 #include "diagnostic-event-id.h"
33 #include "analyzer/sm.h"
34 #include "analyzer/pending-diagnostic.h"
40 /* Generate a label_text by printing FMT.
42 Use a clone of the global_dc for formatting callbacks.
44 Use this evdesc::event_desc's m_colorize flag to control colorization
45 (so that e.g. we can disable it for JSON output). */
48 evdesc::event_desc::formatted_print (const char *fmt, ...) const
50 pretty_printer *pp = global_dc->printer->clone ();
52 pp_show_color (pp) = m_colorize;
55 rich_location rich_loc (line_table, UNKNOWN_LOCATION);
58 ti.format_spec = _(fmt);
62 ti.m_richloc = &rich_loc;
64 pp_output_formatted_text (pp);
67 label_text result = label_text::take (xstrdup (pp_formatted_text (pp)));
72 /* Return true if T1 and T2 are "the same" for the purposes of
73 diagnostic deduplication. */
76 pending_diagnostic::same_tree_p (tree t1, tree t2)
78 return simple_cst_equal (t1, t2) == 1;
83 #endif /* #if ENABLE_ANALYZER */