comparison gcc/pretty-print.h @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* Various declarations for language-independent pretty-print subroutines. 1 /* Various declarations for language-independent pretty-print subroutines.
2 Copyright (C) 2002-2017 Free Software Foundation, Inc. 2 Copyright (C) 2002-2018 Free Software Foundation, Inc.
3 Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net> 3 Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify it under 7 GCC is free software; you can redistribute it and/or modify it under
34 va_list *args_ptr; 34 va_list *args_ptr;
35 int err_no; /* for %m */ 35 int err_no; /* for %m */
36 void **x_data; 36 void **x_data;
37 rich_location *m_richloc; 37 rich_location *m_richloc;
38 38
39 void set_location (unsigned int idx, location_t loc, bool caret_p); 39 void set_location (unsigned int idx, location_t loc,
40 enum range_display_kind range_display_kind);
40 location_t get_location (unsigned int index_of_location) const; 41 location_t get_location (unsigned int index_of_location) const;
41 }; 42 };
42 43
43 /* How often diagnostics are prefixed by their locations: 44 /* How often diagnostics are prefixed by their locations:
44 o DIAGNOSTICS_SHOW_PREFIX_NEVER: never - not yet supported; 45 o DIAGNOSTICS_SHOW_PREFIX_NEVER: never - not yet supported;
177 178
178 /* The type of a hook that formats client-specific data onto a pretty_printer. 179 /* The type of a hook that formats client-specific data onto a pretty_printer.
179 A client-supplied formatter returns true if everything goes well, 180 A client-supplied formatter returns true if everything goes well,
180 otherwise it returns false. */ 181 otherwise it returns false. */
181 typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *, 182 typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *,
182 int, bool, bool, bool, bool, const char **); 183 int, bool, bool, bool, bool *, const char **);
183 184
184 /* Client supplied function used to decode formats. */ 185 /* Client supplied function used to decode formats. */
185 #define pp_format_decoder(PP) (PP)->format_decoder 186 #define pp_format_decoder(PP) (PP)->format_decoder
186 187
187 /* Base class for an optional client-supplied object for doing additional 188 /* Base class for an optional client-supplied object for doing additional
213 /* The data structure that contains the bare minimum required to do 214 /* The data structure that contains the bare minimum required to do
214 proper pretty-printing. Clients may derived from this structure 215 proper pretty-printing. Clients may derived from this structure
215 and add additional fields they need. */ 216 and add additional fields they need. */
216 struct pretty_printer 217 struct pretty_printer
217 { 218 {
218 // Default construct a pretty printer with specified prefix 219 /* Default construct a pretty printer with specified
219 // and a maximum line length cut off limit. 220 maximum line length cut off limit. */
220 explicit pretty_printer (const char* = NULL, int = 0); 221 explicit pretty_printer (int = 0);
221 222
222 virtual ~pretty_printer (); 223 virtual ~pretty_printer ();
223 224
224 /* Where we print external representation of ENTITY. */ 225 /* Where we print external representation of ENTITY. */
225 output_buffer *buffer; 226 output_buffer *buffer;
226 227
227 /* The prefix for each new line. */ 228 /* The prefix for each new line. If non-NULL, this is "owned" by the
228 const char *prefix; 229 pretty_printer, and will eventually be free-ed. */
230 char *prefix;
229 231
230 /* Where to put whitespace around the entity being formatted. */ 232 /* Where to put whitespace around the entity being formatted. */
231 pp_padding padding; 233 pp_padding padding;
232 234
233 /* The real upper bound of number of characters per line, taking into 235 /* The real upper bound of number of characters per line, taking into
326 { \ 328 { \
327 print_dec (W, pp_buffer (PP)->digit_buffer, SGN); \ 329 print_dec (W, pp_buffer (PP)->digit_buffer, SGN); \
328 pp_string (PP, pp_buffer (PP)->digit_buffer); \ 330 pp_string (PP, pp_buffer (PP)->digit_buffer); \
329 } \ 331 } \
330 while (0) 332 while (0)
331 #define pp_wide_integer(PP, I) \
332 pp_scalar (PP, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) I)
333 #define pp_pointer(PP, P) pp_scalar (PP, "%p", P) 333 #define pp_pointer(PP, P) pp_scalar (PP, "%p", P)
334 334
335 #define pp_identifier(PP, ID) pp_string (PP, (pp_translate_identifiers (PP) \ 335 #define pp_identifier(PP, ID) pp_string (PP, (pp_translate_identifiers (PP) \
336 ? identifier_to_locale (ID) \ 336 ? identifier_to_locale (ID) \
337 : (ID))) 337 : (ID)))
338 338
339 339
340 #define pp_buffer(PP) (PP)->buffer 340 #define pp_buffer(PP) (PP)->buffer
341 341
342 extern void pp_set_line_maximum_length (pretty_printer *, int); 342 extern void pp_set_line_maximum_length (pretty_printer *, int);
343 extern void pp_set_prefix (pretty_printer *, const char *); 343 extern void pp_set_prefix (pretty_printer *, char *);
344 extern char *pp_take_prefix (pretty_printer *);
344 extern void pp_destroy_prefix (pretty_printer *); 345 extern void pp_destroy_prefix (pretty_printer *);
345 extern int pp_remaining_character_count_for_line (pretty_printer *); 346 extern int pp_remaining_character_count_for_line (pretty_printer *);
346 extern void pp_clear_output_area (pretty_printer *); 347 extern void pp_clear_output_area (pretty_printer *);
347 extern const char *pp_formatted_text (pretty_printer *); 348 extern const char *pp_formatted_text (pretty_printer *);
348 extern const char *pp_last_position_in_text (const pretty_printer *); 349 extern const char *pp_last_position_in_text (const pretty_printer *);
384 extern void pp_string (pretty_printer *, const char *); 385 extern void pp_string (pretty_printer *, const char *);
385 extern void pp_write_text_to_stream (pretty_printer *); 386 extern void pp_write_text_to_stream (pretty_printer *);
386 extern void pp_write_text_as_dot_label_to_stream (pretty_printer *, bool); 387 extern void pp_write_text_as_dot_label_to_stream (pretty_printer *, bool);
387 extern void pp_maybe_space (pretty_printer *); 388 extern void pp_maybe_space (pretty_printer *);
388 389
390 extern void pp_begin_quote (pretty_printer *, bool);
391 extern void pp_end_quote (pretty_printer *, bool);
392
389 /* Switch into verbatim mode and return the old mode. */ 393 /* Switch into verbatim mode and return the old mode. */
390 static inline pp_wrapping_mode_t 394 static inline pp_wrapping_mode_t
391 pp_set_verbatim_wrapping_ (pretty_printer *pp) 395 pp_set_verbatim_wrapping_ (pretty_printer *pp)
392 { 396 {
393 pp_wrapping_mode_t oldmode = pp_wrapping_mode (pp); 397 pp_wrapping_mode_t oldmode = pp_wrapping_mode (pp);
399 403
400 extern const char *identifier_to_locale (const char *); 404 extern const char *identifier_to_locale (const char *);
401 extern void *(*identifier_to_locale_alloc) (size_t); 405 extern void *(*identifier_to_locale_alloc) (size_t);
402 extern void (*identifier_to_locale_free) (void *); 406 extern void (*identifier_to_locale_free) (void *);
403 407
408 /* Print I to PP in decimal. */
409
410 inline void
411 pp_wide_integer (pretty_printer *pp, HOST_WIDE_INT i)
412 {
413 pp_scalar (pp, HOST_WIDE_INT_PRINT_DEC, i);
414 }
415
416 template<unsigned int N, typename T>
417 void pp_wide_integer (pretty_printer *pp, const poly_int_pod<N, T> &);
418
404 #endif /* GCC_PRETTY_PRINT_H */ 419 #endif /* GCC_PRETTY_PRINT_H */