GCC Middle and Back End API Reference
pretty-print-token-buffer.h
Go to the documentation of this file.
1
/* Capturing the results of pretty_print for later playback.
2
Copyright (C) 2023-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 under
8
the terms of the GNU General Public License as published by the Free
9
Software Foundation; either version 3, or (at your option) any later
10
version.
11
12
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13
WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
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_PRETTY_PRINT_TOKEN_BUFFER_H
22
#define GCC_PRETTY_PRINT_TOKEN_BUFFER_H
23
24
#include "
pretty-print-format-impl.h
"
25
#include "
auto-obstack.h
"
26
#include "
pretty-print-markup.h
"
27
28
/* A class for capturing the results of pretty-printing as tokens,
29
potentially for playback into a different pretty-printer. */
30
31
class
pretty_print_token_buffer
32
{
33
public
:
34
pretty_print_token_buffer
();
35
pretty_print_token_buffer
(
const
char
*gmsgid,
36
va_list *args);
37
38
pretty_print_token_buffer
(
const
pretty_print_token_buffer
&) =
delete
;
39
pretty_print_token_buffer
(
pretty_print_token_buffer
&&);
40
41
~pretty_print_token_buffer
() =
default
;
42
43
std::string
to_string
()
const
;
44
45
void
dump
(FILE *out)
const
{
m_tokens
.dump (out); }
46
void
DEBUG_FUNCTION
dump
()
const
{
dump
(stderr); }
47
48
std::unique_ptr<auto_obstack>
m_obstack
;
49
pp_token_list
m_tokens
;
50
};
51
52
/* A pp_element subclass for use with "%e" that replays the buffered tokens
53
from TOKEN_BUF in another formatting call. */
54
55
class
pp_token_buffer_element
:
public
pp_element
56
{
57
public
:
58
pp_token_buffer_element
(
const
pretty_print_token_buffer
&token_buf)
59
:
m_token_buf
(token_buf)
60
{
61
}
62
63
void
64
add_to_phase_2
(
pp_markup::context
&ctxt)
final
override
;
65
66
private
:
67
const
pretty_print_token_buffer
&
m_token_buf
;
68
};
69
70
#endif
/* GCC_PRETTY_PRINT_TOKEN_BUFFER_H */
auto-obstack.h
pp_markup::context
Definition
pretty-print-markup.h:30
pp_token_buffer_element::m_token_buf
const pretty_print_token_buffer & m_token_buf
Definition
pretty-print-token-buffer.h:67
pp_token_buffer_element::add_to_phase_2
void add_to_phase_2(pp_markup::context &ctxt) final override
Definition
pretty-print-token-buffer.cc:210
pp_token_buffer_element::pp_token_buffer_element
pp_token_buffer_element(const pretty_print_token_buffer &token_buf)
Definition
pretty-print-token-buffer.h:58
pp_token_list
Definition
pretty-print-format-impl.h:300
pretty_print_token_buffer
Definition
pretty-print-token-buffer.h:32
pretty_print_token_buffer::dump
void DEBUG_FUNCTION dump() const
Definition
pretty-print-token-buffer.h:46
pretty_print_token_buffer::to_string
std::string to_string() const
Definition
pretty-print-token-buffer.cc:153
pretty_print_token_buffer::pretty_print_token_buffer
pretty_print_token_buffer(const pretty_print_token_buffer &)=delete
pretty_print_token_buffer::m_tokens
pp_token_list m_tokens
Definition
pretty-print-token-buffer.h:49
pretty_print_token_buffer::pretty_print_token_buffer
pretty_print_token_buffer()
Definition
pretty-print-token-buffer.cc:121
pretty_print_token_buffer::m_obstack
std::unique_ptr< auto_obstack > m_obstack
Definition
pretty-print-token-buffer.h:48
pretty_print_token_buffer::dump
void dump(FILE *out) const
Definition
pretty-print-token-buffer.h:45
pretty_print_token_buffer::~pretty_print_token_buffer
~pretty_print_token_buffer()=default
pp_element
pp_markup::element pp_element
Definition
coretypes.h:177
pretty-print-format-impl.h
pretty-print-markup.h
DEBUG_FUNCTION
#define DEBUG_FUNCTION
Definition
system.h:1191
gcc
pretty-print-token-buffer.h
Generated by
1.16.1