Line data Source code
1 : /* Copyright (C) 2024-2026 Free Software Foundation, Inc.
2 : Contributed by David Malcolm <dmalcolm@redhat.com>
3 :
4 : This file is part of GCC.
5 :
6 : GCC is free software; you can redistribute it and/or modify it under
7 : the terms of the GNU General Public License as published by the Free
8 : Software Foundation; either version 3, or (at your option) any later
9 : version.
10 :
11 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 : for more details.
15 :
16 : You should have received a copy of the GNU General Public License
17 : along with GCC; see the file COPYING3. If not see
18 : <http://www.gnu.org/licenses/>. */
19 :
20 : #ifndef GCC_TREE_PRETTY_PRINT_MARKUP_H
21 : #define GCC_TREE_PRETTY_PRINT_MARKUP_H
22 :
23 : #include "pretty-print-markup.h"
24 : #include "diagnostic-highlight-colors.h"
25 :
26 : namespace pp_markup {
27 :
28 : /* Concrete subclass of pp_markup::element.
29 : Print a type in quotes with the given highlighting color. */
30 :
31 3576 : class element_quoted_type : public element
32 : {
33 : public:
34 3641 : element_quoted_type (tree type, const char *highlight_color)
35 3641 : : m_type (type),
36 3620 : m_highlight_color (highlight_color)
37 : {
38 : }
39 :
40 5282 : void add_to_phase_2 (context &ctxt) override
41 : {
42 5282 : ctxt.begin_quote ();
43 5282 : ctxt.begin_highlight_color (m_highlight_color);
44 :
45 5282 : print_type (ctxt);
46 :
47 5282 : ctxt.end_highlight_color ();
48 5282 : ctxt.end_quote ();
49 5282 : }
50 :
51 : void print_type (context &ctxt);
52 :
53 : private:
54 : tree m_type;
55 : const char *m_highlight_color;
56 : };
57 :
58 : /* Concrete subclass of pp_markup::element.
59 : Print a type in quotes highlighted as the "expected" type. */
60 :
61 2947 : class element_expected_type : public element_quoted_type
62 : {
63 : public:
64 2947 : element_expected_type (tree type)
65 2947 : : element_quoted_type (type, highlight_colors::expected)
66 : {
67 : }
68 : };
69 :
70 : /* Concrete subclass of pp_markup::element.
71 : Print a type in quotes highlighted as the "actual" type. */
72 :
73 2947 : class element_actual_type : public element_quoted_type
74 : {
75 : public:
76 2947 : element_actual_type (tree type)
77 2947 : : element_quoted_type (type, highlight_colors::actual)
78 : {
79 : }
80 : };
81 :
82 : } // namespace pp_markup
83 :
84 : #endif /* GCC_TREE_PRETTY_PRINT_MARKUP_H */
|