21#ifndef GCC_PRETTY_PRINT_H
22#define GCC_PRETTY_PRINT_H
25#include "rich-location.h"
29#define PP_NL_ARGMAX 30
39 void **
data =
nullptr,
40 rich_location *rich_loc =
nullptr)
50 enum range_display_kind range_display_kind);
51 location_t
get_location (
unsigned int index_of_location)
const;
96 void dump (FILE *out,
int indent)
const;
136 return (
const char *) obstack_base (buff->
m_obstack);
145 obstack_grow (buff->
m_obstack, start, length);
146 for (
int i = 0;
i < length;
i++)
147 if (start[
i] ==
'\n')
158 const char *p =
NULL;
161 if (obstack_base (
text) != obstack_next_free (
text))
162 p = ((
const char *) obstack_next_free (
text)) - 1;
199 virtual std::unique_ptr<format_postprocessor>
clone()
const = 0;
218#define pp_is_wrapping_line(PP) (pp_line_cutoff (PP) > 0)
272 virtual std::unique_ptr<pretty_printer>
clone ()
const;
324 void dump (FILE *out,
int indent)
const;
490#define pp_space(PP) pp_character (PP, ' ')
491#define pp_left_paren(PP) pp_character (PP, '(')
492#define pp_right_paren(PP) pp_character (PP, ')')
493#define pp_left_bracket(PP) pp_character (PP, '[')
494#define pp_right_bracket(PP) pp_character (PP, ']')
495#define pp_left_brace(PP) pp_character (PP, '{')
496#define pp_right_brace(PP) pp_character (PP, '}')
497#define pp_semicolon(PP) pp_character (PP, ';')
498#define pp_comma(PP) pp_character (PP, ',')
499#define pp_dot(PP) pp_character (PP, '.')
500#define pp_colon(PP) pp_character (PP, ':')
501#define pp_colon_colon(PP) pp_string (PP, "::")
502#define pp_arrow(PP) pp_string (PP, "->")
503#define pp_equal(PP) pp_character (PP, '=')
504#define pp_question(PP) pp_character (PP, '?')
505#define pp_bar(PP) pp_character (PP, '|')
506#define pp_bar_bar(PP) pp_string (PP, "||")
507#define pp_carret(PP) pp_character (PP, '^')
508#define pp_ampersand(PP) pp_character (PP, '&')
509#define pp_ampersand_ampersand(PP) pp_string (PP, "&&")
510#define pp_less(PP) pp_character (PP, '<')
511#define pp_less_equal(PP) pp_string (PP, "<=")
512#define pp_greater(PP) pp_character (PP, '>')
513#define pp_greater_equal(PP) pp_string (PP, ">=")
514#define pp_plus(PP) pp_character (PP, '+')
515#define pp_minus(PP) pp_character (PP, '-')
516#define pp_star(PP) pp_character (PP, '*')
517#define pp_slash(PP) pp_character (PP, '/')
518#define pp_modulo(PP) pp_character (PP, '%')
519#define pp_exclamation(PP) pp_character (PP, '!')
520#define pp_complement(PP) pp_character (PP, '~')
521#define pp_quote(PP) pp_character (PP, '\'')
522#define pp_backquote(PP) pp_character (PP, '`')
523#define pp_doublequote(PP) pp_character (PP, '"')
524#define pp_underscore(PP) pp_character (PP, '_')
525#define pp_maybe_newline_and_indent(PP, N) \
526 if (pp_needs_newline (PP)) pp_newline_and_indent (PP, N)
525#define pp_maybe_newline_and_indent(PP, N) \ …
527#define pp_scalar(PP, FORMAT, SCALAR) \
530 sprintf (pp_buffer (PP)->m_digit_buffer, FORMAT, SCALAR); \
531 pp_string (PP, pp_buffer (PP)->m_digit_buffer); \
527#define pp_scalar(PP, FORMAT, SCALAR) \ …
534#define pp_decimal_int(PP, I) pp_scalar (PP, "%d", I)
535#define pp_unsigned_wide_integer(PP, I) \
536 pp_scalar (PP, HOST_WIDE_INT_PRINT_UNSIGNED, (unsigned HOST_WIDE_INT) I)
535#define pp_unsigned_wide_integer(PP, I) \ …
537#define pp_vrange(PP, R) \
540 vrange_printer vrange_pp (PP); \
541 (R)->accept (vrange_pp); \
537#define pp_vrange(PP, R) \ …
544#define pp_double(PP, F) pp_scalar (PP, "%f", F)
545#define pp_pointer(PP, P) pp_scalar (PP, "%p", P)
547#define pp_identifier(PP, ID) pp_string (PP, (pp_translate_identifiers (PP) \
548 ? identifier_to_locale (ID) \
547#define pp_identifier(PP, ID) pp_string (PP, (pp_translate_identifiers (PP) \ …
552extern void pp_set_line_maximum_length (pretty_printer *, int);
553inline void pp_set_prefix (pretty_printer *pp, char *prefix)
555 pp->set_prefix (prefix);
553inline void pp_set_prefix (pretty_printer *pp, char *prefix) {
…}
557extern void pp_clear_output_area (pretty_printer *);
558extern const char *pp_formatted_text (pretty_printer *);
559extern const char *pp_last_position_in_text (const pretty_printer *);
560inline void pp_emit_prefix (pretty_printer *pp)
560inline void pp_emit_prefix (pretty_printer *pp) {
…}
564extern void pp_append_text (pretty_printer *, const char *, const char *);
565extern void pp_newline_and_flush (pretty_printer *);
566extern void pp_newline_and_indent (pretty_printer *, int);
567extern void pp_separate_with (pretty_printer *, char);
569/* If we haven't already defined a front-end-specific diagnostics
570 style, use the generic one. */
572#define GCC_PPDIAG_STYLE GCC_DIAG_STYLE
574#define GCC_PPDIAG_STYLE __gcc_diag__
577/* This header may be included before diagnostics-core.h, hence the duplicate
578 definitions to allow for GCC-specific formats. */
579#if GCC_VERSION >= 3005
580#define ATTRIBUTE_GCC_PPDIAG(m, n) __attribute__ ((__format__ (GCC_PPDIAG_STYLE, m ,n))) ATTRIBUTE_NONNULL(m)
582#define ATTRIBUTE_GCC_PPDIAG(m, n) ATTRIBUTE_NONNULL(m)
584extern void pp_printf (pretty_printer *, const char *, ...)
585 ATTRIBUTE_GCC_PPDIAG(2,3);
587extern void pp_printf_n (pretty_printer *, unsigned HOST_WIDE_INT n,
588 const char *, const char *, ...)
589 ATTRIBUTE_GCC_PPDIAG(3,5)
590 ATTRIBUTE_GCC_PPDIAG(4,5);
592extern void pp_verbatim (pretty_printer *, const char *, ...)
593 ATTRIBUTE_GCC_PPDIAG(2,3);
594extern void pp_flush (pretty_printer *);
595extern void pp_really_flush (pretty_printer *);
596inline void pp_format (pretty_printer *pp, text_info *text)
596inline void pp_format (pretty_printer *pp, text_info *text) {
…}
601extern void pp_output_formatted_text (pretty_printer *,
602 const urlifier * = nullptr);
603extern void pp_format_verbatim (pretty_printer *, text_info *);
605extern void pp_indent (pretty_printer *);
606extern void pp_newline (pretty_printer *);
607extern void pp_character (pretty_printer *, int);
608extern void pp_string (pretty_printer *, const char *);
609extern void pp_string_n (pretty_printer *, const char *, size_t);
610extern void pp_unicode_character (pretty_printer *, unsigned);
612extern void pp_write_text_to_stream (pretty_printer *);
613extern void pp_write_text_as_dot_label_to_stream (pretty_printer *, bool);
614extern void pp_write_text_as_html_like_dot_to_stream (pretty_printer *pp);
616inline void pp_maybe_space (pretty_printer *pp)
616inline void pp_maybe_space (pretty_printer *pp) {
…}
621extern void pp_begin_quote (pretty_printer *, bool);
622extern void pp_end_quote (pretty_printer *, bool);
625pp_begin_url (pretty_printer *pp, const char *url)
625pp_begin_url (pretty_printer *pp, const char *url) {
…}
631pp_end_url (pretty_printer *pp)
631pp_end_url (pretty_printer *pp) {
…}
636/* Switch into verbatim mode and return the old mode. */
637inline pp_wrapping_mode_t
638pp_set_verbatim_wrapping (pretty_printer *pp)
640 return pp->set_verbatim_wrapping ();
638pp_set_verbatim_wrapping (pretty_printer *pp) {
…}
643extern const char *identifier_to_locale (const char *);
644extern void *(*identifier_to_locale_alloc) (size_t);
645extern void (*identifier_to_locale_free) (void *);
647/* Print I to PP in decimal. */
650pp_wide_integer (pretty_printer *pp, HOST_WIDE_INT i)
652 pp_scalar (pp, HOST_WIDE_INT_PRINT_DEC, i);
650pp_wide_integer (pretty_printer *pp, HOST_WIDE_INT i) {
…}
656pp_wide_int (pretty_printer *pp, const wide_int_ref &w, signop sgn)
659 print_dec_buf_size (w, sgn, &len);
660 if (UNLIKELY (len > sizeof (pp_buffer (pp)->m_digit_buffer)))
661 pp_wide_int_large (pp, w, sgn);
664 print_dec (w, pp_buffer (pp)->m_digit_buffer, sgn);
665 pp_string (pp, pp_buffer (pp)->m_digit_buffer);
656pp_wide_int (pretty_printer *pp, const wide_int_ref &w, signop sgn) {
…}
669template<unsigned int N, typename T>
670void pp_wide_integer (pretty_printer *pp, const poly_int<N, T> &);
672#endif /* GCC_PRETTY_PRINT_H */
Definition genoutput.cc:150
Definition pretty-print.h:196
virtual ~format_postprocessor()
Definition pretty-print.h:198
virtual void handle(pretty_printer *)=0
virtual std::unique_ptr< format_postprocessor > clone() const =0
Definition pretty-print.h:84
int m_line_length
Definition pretty-print.h:118
output_buffer()
Definition pretty-print.cc:745
char m_digit_buffer[128]
Definition pretty-print.h:122
pp_formatted_chunks * push_formatted_chunks()
Definition pretty-print.cc:772
void DEBUG_FUNCTION dump() const
Definition pretty-print.h:97
bool m_flush_p
Definition pretty-print.h:127
output_buffer(const output_buffer &)=delete
void pop_formatted_chunks()
Definition pretty-print.cc:787
FILE * m_stream
Definition pretty-print.h:115
~output_buffer()
Definition pretty-print.cc:761
output_buffer & operator=(const output_buffer &)=delete
output_buffer(output_buffer &&)=delete
struct obstack * m_obstack
Definition pretty-print.h:108
struct obstack m_formatted_obstack
Definition pretty-print.h:100
struct obstack m_chunk_obstack
Definition pretty-print.h:104
pp_formatted_chunks * m_cur_formatted_chunks
Definition pretty-print.h:112
Definition pretty-print-markup.h:30
Definition pretty-print-format-impl.h:300
Definition pretty-print.h:241
friend format_postprocessor * pp_format_postprocessor(pretty_printer *pp)
Definition pretty-print.h:452
friend pp_wrapping_mode_t & pp_wrapping_mode(pretty_printer *pp)
Definition pretty-print.h:485
void set_real_maximum_length()
Definition pretty-print.cc:931
friend char * pp_take_prefix(pretty_printer *)
Definition pretty-print.cc:2404
diagnostic_url_format get_url_format() const
Definition pretty-print.h:293
void set_format_postprocessor(std::unique_ptr< format_postprocessor > p)
Definition pretty-print.h:319
void format(text_info &text)
Definition pretty-print.cc:1680
friend bool & pp_needs_newline(pretty_printer *pp)
Definition pretty-print.h:418
void maybe_space()
Definition pretty-print.cc:2746
void clear_state()
Definition pretty-print.cc:954
bool m_show_color
Definition pretty-print.h:383
pp_wrapping_mode_t m_wrapping
Definition pretty-print.h:346
void set_padding(pp_padding padding)
Definition pretty-print.h:312
virtual ~pretty_printer()
Definition pretty-print.cc:2509
int remaining_character_count_for_line()
Definition pretty-print.cc:2562
void set_token_printer(token_printer *tp)
Definition pretty-print.h:279
void set_url_format(diagnostic_url_format url_format)
Definition pretty-print.h:294
pp_padding get_padding() const
Definition pretty-print.h:313
friend output_buffer *& pp_buffer(pretty_printer *pp)
Definition pretty-print.h:398
void set_output_stream(FILE *outfile)
Definition pretty-print.h:274
int m_indent_skip
Definition pretty-print.h:343
bool m_skipping_null_url
Definition pretty-print.h:394
bool m_need_newline
Definition pretty-print.h:376
pp_padding m_padding
Definition pretty-print.h:336
friend const char * pp_get_prefix(const pretty_printer *pp)
Definition pretty-print.h:410
virtual std::unique_ptr< pretty_printer > clone() const
Definition pretty-print.cc:2519
bool supports_urls_p() const
Definition pretty-print.h:292
std::unique_ptr< format_postprocessor > m_format_postprocessor
Definition pretty-print.h:364
friend void pp_destroy_prefix(pretty_printer *)
Definition pretty-print.cc:2413
token_printer * m_token_printer
Definition pretty-print.h:370
output_buffer * m_buffer
Definition pretty-print.h:329
friend bool & pp_translate_identifiers(pretty_printer *pp)
Definition pretty-print.h:433
pp_wrapping_mode_t set_verbatim_wrapping()
Definition pretty-print.h:304
friend diagnostic_prefixing_rule_t & pp_prefixing_rule(pretty_printer *pp)
Definition pretty-print.h:473
char * m_prefix
Definition pretty-print.h:333
friend int & pp_indentation(pretty_printer *pp)
Definition pretty-print.h:425
friend void pp_output_formatted_text(pretty_printer *, const urlifier *)
Definition pretty-print.cc:2221
bool m_emitted_prefix
Definition pretty-print.h:373
void begin_url(const char *url)
Definition pretty-print.cc:3052
friend int & pp_line_cutoff(pretty_printer *pp)
Definition pretty-print.h:466
pretty_printer(int=0)
Definition pretty-print.cc:2456
diagnostic_url_format m_url_format
Definition pretty-print.h:390
bool m_translate_identifiers
Definition pretty-print.h:380
friend bool & pp_show_color(pretty_printer *pp)
Definition pretty-print.h:440
int m_maximum_length
Definition pretty-print.h:340
void DEBUG_FUNCTION dump() const
Definition pretty-print.h:325
void emit_prefix()
Definition pretty-print.cc:2424
printer_fn m_format_decoder
Definition pretty-print.h:358
void end_url()
Definition pretty-print.cc:3102
friend bool & pp_show_highlight_colors(pretty_printer *pp)
Definition pretty-print.h:458
bool m_show_highlight_colors
Definition pretty-print.h:387
void set_prefix(char *prefix)
Definition pretty-print.cc:2390
friend printer_fn & pp_format_decoder(pretty_printer *pp)
Definition pretty-print.h:446
Definition pretty-print.h:208
virtual void print_tokens(pretty_printer *pp, const pp_token_list &tokens)=0
virtual ~token_printer()
Definition pretty-print.h:210
Definition pretty-print-urlifier.h:27
diagnostic_url_format
Definition diagnostic-url.h:37
@ URL_FORMAT_NONE
Definition diagnostic-url.h:39
static struct obstack obstack
Definition gcc.cc:364
@ text
Definition logical-location.h:49
Definition coretypes.h:172
i
Definition poly-int.h:776
format_postprocessor * pp_format_postprocessor(pretty_printer *pp)
Definition pretty-print.h:452
pp_wrapping_mode_t & pp_wrapping_mode(pretty_printer *pp)
Definition pretty-print.h:485
bool(* printer_fn)(pretty_printer *, text_info *, const char *, int, bool, bool, bool, bool *, pp_token_list &)
Definition pretty-print.h:190
char * pp_take_prefix(pretty_printer *)
Definition pretty-print.cc:2404
bool & pp_needs_newline(pretty_printer *pp)
Definition pretty-print.h:418
void output_buffer_append_r(output_buffer *buff, const char *start, int length)
Definition pretty-print.h:142
pp_padding
Definition pretty-print.h:171
@ pp_none
Definition pretty-print.h:172
@ pp_after
Definition pretty-print.h:172
@ pp_before
Definition pretty-print.h:172
const char * output_buffer_formatted_text(output_buffer *buff)
Definition pretty-print.h:133
output_buffer *& pp_buffer(pretty_printer *pp)
Definition pretty-print.h:398
const char * pp_get_prefix(const pretty_printer *pp)
Definition pretty-print.h:410
void pp_destroy_prefix(pretty_printer *)
Definition pretty-print.cc:2413
bool & pp_translate_identifiers(pretty_printer *pp)
Definition pretty-print.h:433
diagnostic_prefixing_rule_t & pp_prefixing_rule(pretty_printer *pp)
Definition pretty-print.h:473
int & pp_indentation(pretty_printer *pp)
Definition pretty-print.h:425
int & pp_line_cutoff(pretty_printer *pp)
Definition pretty-print.h:466
diagnostic_prefixing_rule_t
Definition pretty-print.h:66
@ DIAGNOSTICS_SHOW_PREFIX_NEVER
Definition pretty-print.h:68
@ DIAGNOSTICS_SHOW_PREFIX_ONCE
Definition pretty-print.h:67
@ DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE
Definition pretty-print.h:69
const char * output_buffer_last_position_in_text(const output_buffer *buff)
Definition pretty-print.h:156
bool & pp_show_color(pretty_printer *pp)
Definition pretty-print.h:440
unsigned int pp_flags
Definition pretty-print.h:168
bool & pp_show_highlight_colors(pretty_printer *pp)
Definition pretty-print.h:458
printer_fn & pp_format_decoder(pretty_printer *pp)
Definition pretty-print.h:446
Definition pretty-print.h:178
diagnostic_prefixing_rule_t rule
Definition pretty-print.h:180
int line_cutoff
Definition pretty-print.h:184
Definition pretty-print.h:34
int m_err_no
Definition pretty-print.h:55
va_list * m_args_ptr
Definition pretty-print.h:54
void ** m_data
Definition pretty-print.h:56
void set_location(unsigned int idx, location_t loc, enum range_display_kind range_display_kind)
Definition pretty-print.cc:725
text_info(const char *format_spec, va_list *args_ptr, int err_no, void **data=nullptr, rich_location *rich_loc=nullptr)
Definition pretty-print.h:36
location_t get_location(unsigned int index_of_location) const
Definition pretty-print.cc:733
const char * m_format_spec
Definition pretty-print.h:53
rich_location * m_richloc
Definition pretty-print.h:57
#define NULL
Definition system.h:50
#define bool
Definition system.h:886
#define DEBUG_FUNCTION
Definition system.h:1236
#define gcc_checking_assert(EXPR)
Definition system.h:821