GCC Middle and Back End API Reference
|
#include <pretty-print.h>
Public Member Functions | |
pretty_printer (int=0) | |
pretty_printer (const pretty_printer &other) | |
virtual | ~pretty_printer () |
virtual pretty_printer * | clone () const |
void | set_output_stream (FILE *outfile) |
void | set_prefix (char *prefix) |
void | emit_prefix () |
void | format (text_info *text, const urlifier *urlifier) |
void | maybe_space () |
bool | supports_urls_p () const |
diagnostic_url_format | get_url_format () const |
void | set_url_format (diagnostic_url_format url_format) |
void | begin_url (const char *url) |
void | end_url () |
pp_wrapping_mode_t | set_verbatim_wrapping () |
void | set_padding (pp_padding padding) |
pp_padding | get_padding () const |
void | clear_state () |
void | set_real_maximum_length () |
int | remaining_character_count_for_line () |
Friends | |
output_buffer *& | pp_buffer (pretty_printer *pp) |
output_buffer * | pp_buffer (const pretty_printer *pp) |
const char * | pp_get_prefix (const pretty_printer *pp) |
char * | pp_take_prefix (pretty_printer *pp) |
void | pp_destroy_prefix (pretty_printer *pp) |
int & | pp_line_cutoff (pretty_printer *pp) |
diagnostic_prefixing_rule_t & | pp_prefixing_rule (pretty_printer *pp) |
const diagnostic_prefixing_rule_t & | pp_prefixing_rule (const pretty_printer *pp) |
pp_wrapping_mode_t & | pp_wrapping_mode (pretty_printer *pp) |
bool & | pp_needs_newline (pretty_printer *pp) |
int & | pp_indentation (pretty_printer *pp) |
bool & | pp_translate_identifiers (pretty_printer *pp) |
bool & | pp_show_color (pretty_printer *pp) |
printer_fn & | pp_format_decoder (pretty_printer *pp) |
format_postprocessor *& | pp_format_postprocessor (pretty_printer *pp) |
bool & | pp_show_highlight_colors (pretty_printer *pp) |
The data structure that contains the bare minimum required to do proper pretty-printing. Clients may derive from this structure and add additional fields they need.
|
explicit |
Construct a PRETTY-PRINTER of MAXIMUM_LENGTH characters per line.
References DIAGNOSTICS_SHOW_PREFIX_ONCE, NULL, pp_line_cutoff, pp_prefixing_rule, and pp_set_prefix().
Referenced by clone().
|
explicit |
Copy constructor for pretty_printer.
References format_postprocessor::clone(), m_format_postprocessor, m_maximum_length, NULL, pp_line_cutoff, pp_prefixing_rule, and pp_set_prefix().
|
virtual |
References free(), m_buffer, m_format_postprocessor, m_prefix, and output_buffer::~output_buffer().
Referenced by diagnostic_context::finish().
void pretty_printer::begin_url | ( | const char * | url | ) |
Support for encoding URLs. See egmontkob/Hyperlinks_in_Terminal_Emulators.md ( https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda ). > A hyperlink is opened upon encountering an OSC 8 escape sequence with > the target URI. The syntax is > > OSC 8 ; params ; URI ST > > A hyperlink is closed with the same escape sequence, omitting the > parameters and the URI but keeping the separators: > > OSC 8 ; ; ST > > OSC (operating system command) is typically ESC ]. Use BEL instead of ST, as that is currently rendered better in some terminal emulators that don't support OSC 8, like konsole.
If URL-printing is enabled, write an "open URL" escape sequence to PP for the given URL.
References gcc_unreachable, m_skipping_null_url, m_url_format, pp_string(), URL_FORMAT_BEL, URL_FORMAT_NONE, and URL_FORMAT_ST.
Referenced by format().
|
inline |
Clear this pretty_printer's output state.
References m_emitted_prefix, and pp_indentation.
Referenced by format(), pp_flush(), and pp_really_flush().
|
virtual |
Base class implementation of pretty_printer::clone vfunc.
References pretty_printer().
Referenced by attr_access::array_as_string().
void pretty_printer::emit_prefix | ( | ) |
Write out this pretty_printer's prefix.
References DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE, DIAGNOSTICS_SHOW_PREFIX_NEVER, DIAGNOSTICS_SHOW_PREFIX_ONCE, m_emitted_prefix, m_prefix, pp_append_r(), pp_indent(), pp_indentation, and pp_prefixing_rule.
Referenced by pp_append_text().
void pretty_printer::end_url | ( | ) |
If URL-printing is enabled, write a "close URL" escape sequence to PP.
References get_end_url_string(), m_skipping_null_url, m_url_format, pp_string(), and URL_FORMAT_NONE.
The following format specifiers are recognized as being client independent: %d, %i: (signed) integer in base ten. %u: unsigned integer in base ten. %o: unsigned integer in base eight. %x: unsigned integer in base sixteen. %ld, %li, %lo, %lu, %lx: long versions of the above. %lld, %lli, %llo, %llu, %llx: long long versions. %wd, %wi, %wo, %wu, %wx: HOST_WIDE_INT versions. %zd, %zi, %zo, %zu, %zx: size_t versions. %td, %ti, %to, %tu, %tx: ptrdiff_t versions. %f: double %c: character. %s: string. %p: pointer (printed in a host-dependent manner). %r: if pp_show_color(pp), switch to color identified by const char *. %R: if pp_show_color(pp), reset color. %m: strerror(text->err_no) - does not consume a value from args_ptr. %%: '%'. %<: opening quote. %>: closing quote. %{: URL start. Consumes a const char * argument for the URL. %}: URL end. Does not consume any arguments. %': apostrophe (should only be used in untranslated messages; translations should use appropriate punctuation directly). %@: diagnostic_event_id_ptr, for which event_id->known_p () must be true. %.*s: a substring the length of which is specified by an argument integer. %Ns: likewise, but length specified as constant in the format string. Flag 'q': quote formatted text (must come immediately after '%'). %Z: Requires two arguments - array of int, and len. Prints elements of the array. %e: Consumes a pp_element * argument. Arguments can be used sequentially, or through %N$ resp. *N$ notation Nth argument after the format string. If %N$ / *N$ notation is used, it must be used for all arguments, except %m, %%, %<, %>, %} and %', which may not have a number, as they do not consume an argument. When %M$.*N$s is used, M must be N + 1. (This may also be written %M$.*s, provided N is not otherwise used.) The format string must have conversion specifiers with argument numbers 1 up to highest argument; each argument may only be used once. A format string can have at most 30 arguments.
Implementation of pp_format. Formatting phases 1 and 2: render TEXT->format_spec plus text->m_args_ptr into a series of chunks in pp_buffer (PP)->args[]. Phase 3 is in pp_output_formatted_text. If URLIFIER is non-NULL, then use it to add URLs for quoted strings, so that e.g. "before %<quoted%> after" with a URLIFIER that has a URL for "quoted" might be emitted as: "before `BEGIN_URL(http://example.com)quotedEND_URL' after" This is handled here for message fragments that are: - quoted entirely in phase 1 (e.g. "%<this is quoted%>"), or - quoted entirely in phase 2 (e.g. "%qs"), Quoted fragments that use a mixture of both phases (e.g. "%<this is a mixture: %s %>") are stashed into the output_buffer's m_quotes for use in phase 3.
References pp_markup::element::add_to_phase_2(), begin_url(), output_buffer::chunk_obstack, clear_state(), close_quote, colorize_start(), colorize_stop(), output_buffer::cur_chunk_array, end(), output_buffer::formatted_obstack, gcc_assert, gcc_unreachable, get_end_url_string(), format_postprocessor::handle(), HOST_WIDE_INT_PRINT, HOST_WIDE_INT_PRINT_HEX, HOST_WIDE_INT_PRINT_UNSIGNED, i, diagnostic_event_id_t::known_p(), output_buffer::line_length, chunk_info::m_args, text_info::m_args_ptr, m_buffer, text_info::m_err_no, m_format_decoder, m_format_postprocessor, text_info::m_format_spec, chunk_info::m_prev, chunk_info::m_quotes, m_show_color, output_buffer::obstack, chunk_info::on_begin_quote(), chunk_info::on_end_quote(), diagnostic_event_id_t::one_based(), open_quote, pp_append_text(), pp_begin_quote(), pp_character(), pp_comma, pp_decimal_int, pp_double, pp_end_quote(), pp_format_decoder, pp_integer_with_precision, PP_NL_ARGMAX, pp_pointer, pp_quoted_string(), pp_scalar, pp_set_verbatim_wrapping(), pp_space, pp_string(), pp_wide_integer(), and pp_wrapping_mode.
|
inline |
References m_padding.
|
inline |
References m_url_format.
Referenced by get_end_url_string(), and urlify_quoted_string().
void pretty_printer::maybe_space | ( | ) |
int pretty_printer::remaining_character_count_for_line | ( | ) |
Return the amount of characters PRETTY-PRINTER can accept to make a full line. Meaningful only in line-wrapping mode.
References output_buffer::line_length, m_maximum_length, and pp_buffer.
Referenced by pp_character(), and pp_wrap_text().
|
inline |
References m_buffer, and output_buffer::stream.
Referenced by dot_rdg_1(), ana::one_way_id_map< T >::dump(), irange_bitmask::dump(), vrange::dump(), digraph< GraphTraits >::dump_dot_to_file(), dump_insn_slim(), dump_rtl_slim(), dump_ssaname_info_to_file(), dump_value_slim(), gimple_dump_bb(), maybe_init_pretty_print(), print_gimple_expr(), print_gimple_seq(), print_gimple_stmt(), print_graph_cfg(), print_node(), and start_graph_dump().
|
inline |
References m_padding.
void pretty_printer::set_prefix | ( | char * | prefix | ) |
Set PREFIX for PRETTY-PRINTER, taking ownership of PREFIX, which will eventually be free-ed.
References free(), m_emitted_prefix, m_prefix, pp_indentation, and set_real_maximum_length().
Referenced by lhd_print_error_function().
void pretty_printer::set_real_maximum_length | ( | ) |
Subroutine of pp_set_maximum_length. Set up PRETTY-PRINTER's internal maximum characters per line.
References DIAGNOSTICS_SHOW_PREFIX_NEVER, DIAGNOSTICS_SHOW_PREFIX_ONCE, m_maximum_length, m_prefix, pp_is_wrapping_line, pp_line_cutoff, and pp_prefixing_rule.
Referenced by pp_set_line_maximum_length(), and set_prefix().
|
inline |
References m_url_format.
Referenced by print_lto_docs_link(), and diagnostic_context::urls_init().
|
inline |
References DIAGNOSTICS_SHOW_PREFIX_NEVER, pp_line_cutoff, pp_prefixing_rule, and pp_wrapping_mode.
|
inline |
|
friend |
|
friend |
|
friend |
Free PRETTY-PRINTER's prefix, a previously malloc()'d string.
|
friend |
Referenced by dump_pretty_printer::dump_pretty_printer(), and format().
|
friend |
|
friend |
|
friend |
The amount of whitespace to be emitted when starting a new line.
Referenced by clear_state(), emit_prefix(), and set_prefix().
|
friend |
Maximum characters per line in automatic line wrapping mode. Zero means don't wrap lines.
Referenced by pretty_printer(), pretty_printer(), set_real_maximum_length(), and set_verbatim_wrapping().
|
friend |
TRUE if a newline character needs to be added before further formatting.
|
friend |
|
friend |
Prefixing rule used in formatting a diagnostic message.
Referenced by emit_prefix(), pretty_printer(), pretty_printer(), set_real_maximum_length(), and set_verbatim_wrapping().
|
friend |
True if colors should be shown.
|
friend |
|
friend |
Take ownership of PP's prefix, setting it to NULL. This allows clients to save, override, and then restore an existing prefix, without it being free-ed.
|
friend |
True if identifiers are translated to the locale character set on output.
|
friend |
Get or set the wrapping mode as a single entity.
Referenced by format(), and set_verbatim_wrapping().
|
private |
Referenced by format(), set_output_stream(), and ~pretty_printer().
|
private |
Referenced by clear_state(), emit_prefix(), and set_prefix().
|
private |
Referenced by format().
|
private |
Referenced by format(), pretty_printer(), and ~pretty_printer().
|
private |
|
private |
Referenced by pretty_printer(), remaining_character_count_for_line(), and set_real_maximum_length().
|
private |
|
private |
Referenced by get_padding(), maybe_space(), and set_padding().
|
private |
Referenced by emit_prefix(), set_prefix(), set_real_maximum_length(), and ~pretty_printer().
|
private |
|
private |
Referenced by begin_url(), and end_url().
|
private |
|
private |
Referenced by begin_url(), end_url(), get_url_format(), set_url_format(), and supports_urls_p().
|
private |