comparison gcc/analyzer/pending-diagnostic.cc @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Classes for analyzer diagnostics.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5 This file is part of GCC.
6
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)
10 any later version.
11
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.
16
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/>. */
20
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tree.h"
25 #include "intl.h"
26 #include "diagnostic.h"
27 #include "function.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"
35
36 #if ENABLE_ANALYZER
37
38 namespace ana {
39
40 /* Generate a label_text by printing FMT.
41
42 Use a clone of the global_dc for formatting callbacks.
43
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). */
46
47 label_text
48 evdesc::event_desc::formatted_print (const char *fmt, ...) const
49 {
50 pretty_printer *pp = global_dc->printer->clone ();
51
52 pp_show_color (pp) = m_colorize;
53
54 text_info ti;
55 rich_location rich_loc (line_table, UNKNOWN_LOCATION);
56 va_list ap;
57 va_start (ap, fmt);
58 ti.format_spec = _(fmt);
59 ti.args_ptr = &ap;
60 ti.err_no = 0;
61 ti.x_data = NULL;
62 ti.m_richloc = &rich_loc;
63 pp_format (pp, &ti);
64 pp_output_formatted_text (pp);
65 va_end (ap);
66
67 label_text result = label_text::take (xstrdup (pp_formatted_text (pp)));
68 delete pp;
69 return result;
70 }
71
72 /* Return true if T1 and T2 are "the same" for the purposes of
73 diagnostic deduplication. */
74
75 bool
76 pending_diagnostic::same_tree_p (tree t1, tree t2)
77 {
78 return simple_cst_equal (t1, t2) == 1;
79 }
80
81 } // namespace ana
82
83 #endif /* #if ENABLE_ANALYZER */