GCC Middle and Back End API Reference
pretty-print.c File Reference

Functions

static void pp_set_real_maximum_length ()
static void pp_clear_state ()
void pp_write_text_to_stream ()
void pp_write_text_as_dot_label_to_stream ()
static void pp_wrap_text ()
static void pp_maybe_wrap_text ()
static void pp_append_r ()
void pp_indent ()
void pp_format ()
void pp_output_formatted_text ()
void pp_format_verbatim ()
void pp_flush ()
void pp_set_line_maximum_length ()
void pp_clear_output_area ()
void pp_set_prefix ()
void pp_destroy_prefix ()
void pp_emit_prefix ()
void pp_append_text ()
const char * pp_formatted_text ()
const char * pp_last_position_in_text ()
int pp_remaining_character_count_for_line ()
void pp_printf ()
void pp_verbatim ()
void pp_newline ()
void pp_character ()
void pp_string ()
void pp_maybe_space ()
void pp_newline_and_flush ()
void pp_newline_and_indent ()
void pp_separate_with ()
static int decode_utf8_char ()
const char * identifier_to_locale ()

Variables

void *(* identifier_to_locale_alloc )(size_t) = xmalloc
void(* identifier_to_locale_free )(void *) = free

Function Documentation

static int decode_utf8_char ( )
static
The string starting at P has LEN (at least 1) bytes left; if they
   start with a valid UTF-8 sequence, return the length of that
   sequence and set *VALUE to the value of that sequence, and
   otherwise return 0 and set *VALUE to (unsigned int) -1.   

References abort().

Referenced by identifier_to_locale().

const char* identifier_to_locale ( )
Given IDENT, an identifier in the internal encoding, return a
   version of IDENT suitable for diagnostics in the locale character
   set: either IDENT itself, or a string, allocated using
   identifier_to_locale_alloc, converted to the locale character set
   and using escape sequences if not representable in the locale
   character set or containing control characters or invalid byte
   sequences.  Existing backslashes in IDENT are not doubled, so the
   result may not uniquely specify the contents of an arbitrary byte
   sequence identifier.   

References decode_utf8_char(), errno, identifier_to_locale_alloc, identifier_to_locale_free, locale_encoding, locale_utf8, and strlen().

Referenced by announce_function(), default_tree_printer(), expand_expr_real_1(), lhd_print_error_function(), pp_tree_identifier(), resolve_operand_name_1(), and verify_cgraph_node().

static void pp_append_r ( )
inlinestatic
Append to the output area of PRETTY-PRINTER a string specified by its
   STARTing character and LENGTH.   

References obstack.

Referenced by pp_append_text(), and pp_emit_prefix().

void pp_append_text ( )
Append a string delimited by START and END to the output area of
   PRETTY-PRINTER.  No line wrapping is done.  However, if beginning a
   new line then emit PRETTY-PRINTER's prefix and skip any leading
   whitespace if appropriate.  The caller must ensure that it is
   safe to do so.   

References pp_append_r(), and pp_emit_prefix().

Referenced by pp_format(), pp_maybe_wrap_text(), pp_tree_identifier(), and pp_wrap_text().

void pp_clear_output_area ( )
Clear PRETTY-PRINTER output area text info.   

References obstack.

Referenced by mf_varname_tree(), pp_write_text_as_dot_label_to_stream(), and pp_write_text_to_stream().

static void pp_clear_state ( )
inlinestatic
Clear PRETTY-PRINTER's output state.   

References pretty_printer::emitted_prefix.

Referenced by pp_flush(), and pp_format().

void pp_destroy_prefix ( )
Free PRETTY-PRINTER's prefix, a previously malloc()'d string.   

References free(), and pretty_printer::prefix.

Referenced by diagnostic_append_note(), and diagnostic_report_diagnostic().

void pp_format ( )
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.
   %c: character.
   %s: string.
   %p: pointer.
   %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.
   %': apostrophe (should only be used in untranslated messages;
       translations should use appropriate punctuation directly).
   %.*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 '%').

   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.   
Formatting phases 1 and 2: render TEXT->format_spec plus
   TEXT->args_ptr into a series of chunks in pp_buffer (PP)->args[].
   Phase 3 is in pp_format_text.   

References chunk_info::args, text_info::args_ptr, buffer, output_buffer::chunk_obstack, close_quote, colorize_start(), colorize_stop(), output_buffer::cur_chunk_array, text_info::err_no, text_info::format_spec, output_buffer::formatted_obstack, HOST_WIDE_INT, HOST_WIDE_INT_PRINT, HOST_WIDE_INT_PRINT_HEX, HOST_WIDE_INT_PRINT_UNSIGNED, output_buffer::line_length, memset(), output_buffer::obstack, open_quote, pp_append_text(), pp_character(), pp_clear_state(), pp_string(), chunk_info::prev, and strlen().

Referenced by diagnostic_append_note(), diagnostic_report_diagnostic(), pp_format_verbatim(), and pp_printf().

void pp_format_verbatim ( )
Helper subroutine of output_verbatim and verbatim. Do the appropriate
   settings needed by BUFFER for a verbatim formatting.   

References pp_format(), and pp_output_formatted_text().

Referenced by pp_verbatim(), and verbatim().

const char* pp_formatted_text ( )
Finishes constructing a NULL-terminated character string representing
   the PRETTY-PRINTED text.   

References obstack.

Referenced by asan_pp_string(), mf_varname_tree(), pp_write_text_as_dot_label_to_stream(), pp_write_text_to_stream(), and str_pattern_slim().

void pp_indent ( )
Insert enough spaces into the output area of PRETTY-PRINTER to bring
   the column position to the current indentation level, assuming that a
   newline has just been written to the buffer.   

Referenced by pp_emit_prefix(), and pp_newline_and_indent().

const char* pp_last_position_in_text ( )
Return a pointer to the last character emitted in PRETTY-PRINTER's
    output area.  A NULL pointer means no character available.   

References obstack.

void pp_maybe_space ( )
Maybe print out a whitespace if needed.   

References pretty_printer::padding, and pp_none.

static void pp_maybe_wrap_text ( )
inlinestatic
Same as pp_wrap_text but wrap text only when in line-wrapping mode.   

References pp_append_text(), and pp_wrap_text().

Referenced by pp_string().

void pp_newline_and_indent ( )

References pp_indent(), and pp_newline().

int pp_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 pretty_printer::maximum_length.

Referenced by pp_character(), and pp_wrap_text().

void pp_separate_with ( )

References pp_character().

void pp_set_line_maximum_length ( )
Sets the number of maximum characters per line PRETTY-PRINTER can
   output in line-wrapping mode.  A LENGTH value 0 suppresses
   line-wrapping.   

References pp_set_real_maximum_length().

Referenced by common_handle_option().

static void pp_set_real_maximum_length ( )
static
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, pretty_printer::maximum_length, pretty_printer::prefix, and strlen().

Referenced by pp_set_line_maximum_length(), and pp_set_prefix().

void pp_verbatim ( )
static void pp_wrap_text ( )
static
Wrap a text delimited by START and END into PRETTY-PRINTER.   

References pp_append_text(), pp_newline(), and pp_remaining_character_count_for_line().

Referenced by pp_maybe_wrap_text().

void pp_write_text_as_dot_label_to_stream ( )
As pp_write_text_to_stream, but for GraphViz label output.

   Flush the formatted text of pretty-printer PP onto the attached stream.
   Replace characters in PPF that have special meaning in a GraphViz .dot
   file.
   
   This routine is not very fast, but it doesn't have to be as this is only
   be used by routines dumping intermediate representations in graph form.   

References pp_clear_output_area(), and pp_formatted_text().

Referenced by gimple_dump_bb_for_graph(), rtl_dump_bb_for_graph(), and start_graph_dump().

void pp_write_text_to_stream ( )
Flush the formatted text of PRETTY-PRINTER onto the attached stream.   

References pp_clear_output_area(), and pp_formatted_text().

Referenced by draw_cfg_node(), dump_bb_for_graph(), gimple_dump_bb_for_graph(), pp_flush(), print_generic_decl(), rtl_dump_bb_for_graph(), and start_graph_dump().


Variable Documentation

void*(* identifier_to_locale_alloc)(size_t) = xmalloc
Allocator for identifier_to_locale and corresponding function to
   free memory.   

Referenced by general_init(), and identifier_to_locale().

void(* identifier_to_locale_free)(void *) = free