Line data Source code
1 : /* Classes for adding special effects when quoting source code.
2 : Copyright (C) 2024-2026 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 : #ifndef GCC_DIAGNOSTICS_SOURCE_PRINTING_EFFECTS_H
22 : #define GCC_DIAGNOSTICS_SOURCE_PRINTING_EFFECTS_H
23 :
24 : namespace diagnostics {
25 :
26 : /* Abstract base class for describing special effects when printing
27 : a label when quoting source code. */
28 :
29 2651 : class label_effects
30 : {
31 : public:
32 2651 : virtual ~label_effects () {}
33 :
34 : /* Adding links between labels, e.g. for visualizing control flow
35 : in execution paths. */
36 : virtual bool has_in_edge (unsigned range_idx) const = 0;
37 : virtual bool has_out_edge (unsigned range_idx) const = 0;
38 : };
39 :
40 : /* A class to hold state when quoting a run of lines of source code. */
41 :
42 : class source_effect_info
43 : {
44 : public:
45 2651 : source_effect_info ()
46 2651 : : m_leading_in_edge_column (-1),
47 2651 : m_trailing_out_edge_column (-1)
48 : {
49 : }
50 :
51 : /* The column for an incoming link to the first label,
52 : or -1 if no such link. */
53 : int m_leading_in_edge_column;
54 :
55 : /* The column for an outgoing link from the final label,
56 : or -1 if no such link. */
57 : int m_trailing_out_edge_column;
58 : };
59 :
60 : } // namespace diagnostics
61 :
62 : #endif /* GCC_DIAGNOSTICS_SOURCE_PRINTING_EFFECTS_H */
|