GCC Middle and Back End API Reference
dump_pretty_printer Class Reference

#include <dump-context.h>

Inheritance diagram for dump_pretty_printer:
Collaboration diagram for dump_pretty_printer:

Data Structures

class  stashed_item
 

Public Member Functions

 dump_pretty_printer (dump_context *context, dump_flags_t dump_kind)
 
void emit_items (optinfo *dest)
 
virtual pretty_printerclone () const
 

Data Fields

output_bufferbuffer
 
charprefix
 
pp_padding padding
 
int maximum_length
 
int indent_skip
 
pp_wrapping_mode_t wrapping
 
printer_fn format_decoder
 
format_postprocessorm_format_postprocessor
 
bool emitted_prefix
 
bool need_newline
 
bool translate_identifiers
 
bool show_color
 
diagnostic_url_format url_format
 
bool m_skipping_null_url
 

Private Member Functions

bool decode_format (text_info *text, const char *spec, const char **buffer_ptr)
 
void stash_item (const char **buffer_ptr, optinfo_item *item)
 
void emit_any_pending_textual_chunks (optinfo *dest)
 
void emit_item (optinfo_item *item, optinfo *dest)
 

Static Private Member Functions

static bool format_decoder_cb (pretty_printer *pp, text_info *text, const char *spec, int, bool, bool, bool, bool @endverbatim *, const char **buffer_ptr)
 

Private Attributes

dump_contextm_context
 
dump_flags_t m_dump_kind
 
auto_vec< stashed_itemm_stashed_items
 

Detailed Description

A subclass of pretty_printer for implementing dump_context::dump_printf_va.
In particular, the formatted chunks are captured as optinfo_item instances,
thus retaining metadata about the entities being dumped (e.g. source
locations), rather than just as plain text.   

Constructor & Destructor Documentation

◆ dump_pretty_printer()

dump_pretty_printer::dump_pretty_printer ( dump_context * context,
dump_flags_t dump_kind )
dump_pretty_printer's ctor.   

References format_decoder_cb(), and pp_format_decoder.

Member Function Documentation

◆ clone()

pretty_printer * pretty_printer::clone ( ) const
virtualinherited
Base class implementation of pretty_printer::clone vfunc.   

References pretty_printer::pretty_printer().

Referenced by attr_access::array_as_string().

◆ decode_format()

bool dump_pretty_printer::decode_format ( text_info * text,
const char * spec,
const char ** buffer_ptr )
private
Format decoder for dump_pretty_printer, and thus for dump_printf and
dump_printf_loc.

Supported format codes (in addition to the standard pretty_printer ones)
are:

%C: cgraph_node *:
    Equivalent to: dump_symtab_node (MSG_*, node)
%E: gimple *:
    Equivalent to: dump_gimple_expr (MSG_*, TDF_SLIM, stmt, 0)
%G: gimple *:
    Equivalent to: dump_gimple_stmt (MSG_*, TDF_SLIM, stmt, 0)
%T: tree:
    Equivalent to: dump_generic_expr (MSG_*, arg, TDF_SLIM).

TODO: add a format code that can handle (symtab_node*) *and* both
subclasses (presumably means teaching -Wformat about non-virtual
subclasses).

These format codes build optinfo_item instances, thus capturing metadata
about the arguments being dumped, as well as the textual output.   

References ggc_alloc(), make_item_for_dump_generic_expr(), make_item_for_dump_gimple_expr(), make_item_for_dump_gimple_stmt(), make_item_for_dump_symtab_node(), stash_item(), and TDF_SLIM.

◆ emit_any_pending_textual_chunks()

void dump_pretty_printer::emit_any_pending_textual_chunks ( optinfo * dest)
private
Subroutine of dump_pretty_printer::emit_items
for consolidating multiple adjacent pure-text chunks into single
optinfo_items (in phase 3).   

References pretty_printer::buffer, emit_item(), output_buffer::formatted_obstack, gcc_assert, ggc_alloc(), NULL, output_buffer::obstack, OPTINFO_ITEM_KIND_TEXT, output_buffer_last_position_in_text(), pp_formatted_text(), and UNKNOWN_LOCATION.

Referenced by emit_items().

◆ emit_item()

void dump_pretty_printer::emit_item ( optinfo_item * item,
optinfo * dest )
private
Emit ITEM and take ownership of it.  If DEST is non-NULL, add ITEM
to DEST; otherwise delete ITEM.   

References optinfo::add_item(), dump_context::emit_item(), m_context, and m_dump_kind.

Referenced by emit_any_pending_textual_chunks(), and emit_items().

◆ emit_items()

void dump_pretty_printer::emit_items ( optinfo * dest)
Phase 3 of formatting; compare with pp_output_formatted_text.

Emit optinfo_item instances for the various formatted chunks from phases
1 and 2 (i.e. pp_format).

Some chunks may already have had their items built (during decode_format).
These chunks have been stashed into m_stashed_items; we emit them here.

For all other purely textual chunks, they are printed into
buffer->formatted_obstack, and then emitted as a textual optinfo_item.
This consolidates multiple adjacent text chunks into a single text
optinfo_item.   

References pretty_printer::buffer, output_buffer::chunk_obstack, output_buffer::cur_chunk_array, emit_any_pending_textual_chunks(), emit_item(), output_buffer::formatted_obstack, gcc_assert, ggc_alloc(), output_buffer::line_length, m_stashed_items, output_buffer::obstack, pp_buffer, and pp_string().

Referenced by dump_context::dump_printf_va(), and opt_problem::opt_problem().

◆ format_decoder_cb()

bool dump_pretty_printer::format_decoder_cb ( pretty_printer * pp,
text_info * text,
const char * spec,
int ,
bool ,
bool ,
bool ,
bool @endverbatim * ,
const char ** buffer_ptr )
staticprivate
pp_format_decoder callback for dump_pretty_printer, and thus for
dump_printf and dump_printf_loc.

A wrapper around decode_format, for type-safety.   

References ggc_alloc().

Referenced by dump_pretty_printer().

◆ stash_item()

void dump_pretty_printer::stash_item ( const char ** buffer_ptr,
optinfo_item * item )
private
Record that ITEM (generated in phase 2 of formatting) is to be used for
the chunk at BUFFER_PTR in phase 3 (by emit_items).   

References gcc_assert, and m_stashed_items.

Referenced by decode_format().

Field Documentation

◆ buffer

◆ emitted_prefix

bool pretty_printer::emitted_prefix
inherited

◆ format_decoder

printer_fn pretty_printer::format_decoder
inherited

◆ indent_skip

int pretty_printer::indent_skip
inherited

◆ m_context

dump_context* dump_pretty_printer::m_context
private

Referenced by emit_item().

◆ m_dump_kind

dump_flags_t dump_pretty_printer::m_dump_kind
private

Referenced by emit_item().

◆ m_format_postprocessor

format_postprocessor* pretty_printer::m_format_postprocessor
inherited

◆ m_skipping_null_url

bool pretty_printer::m_skipping_null_url
inherited

Referenced by pp_begin_url(), and pp_end_url().

◆ m_stashed_items

auto_vec<stashed_item> dump_pretty_printer::m_stashed_items
private

Referenced by emit_items(), and stash_item().

◆ maximum_length

◆ need_newline

bool pretty_printer::need_newline
inherited

◆ padding

pp_padding pretty_printer::padding
inherited

Referenced by pp_maybe_space().

◆ prefix

◆ show_color

bool pretty_printer::show_color
inherited

◆ translate_identifiers

bool pretty_printer::translate_identifiers
inherited

◆ url_format

◆ wrapping

pp_wrapping_mode_t pretty_printer::wrapping
inherited

The documentation for this class was generated from the following files: