diff options
author | Pranil Dey <mkdeyp@gmail.com> | 2024-09-30 19:03:42 +0530 |
---|---|---|
committer | Pranil Dey <mkdeyp@gmail.com> | 2024-09-30 19:03:42 +0530 |
commit | b602de4ed9f872aa2a07e8cf74d5b3c8446de221 (patch) | |
tree | 0d1fa6e4793d0a240fee8b958764cb93fc837aab /gcc/dump-context.h | |
parent | c16d4a0ae162abc00d97bb73e598ca00d16cf555 (diff) | |
parent | 87905f63a6521eef1f38082e2368e18c637ef092 (diff) | |
download | gcc-b602de4ed9f872aa2a07e8cf74d5b3c8446de221.zip gcc-b602de4ed9f872aa2a07e8cf74d5b3c8446de221.tar.gz gcc-b602de4ed9f872aa2a07e8cf74d5b3c8446de221.tar.bz2 |
Merge branch 'master' of git+ssh://gcc.gnu.org/git/gcc into devel/nothrow-detection
Diffstat (limited to 'gcc/dump-context.h')
-rw-r--r-- | gcc/dump-context.h | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/gcc/dump-context.h b/gcc/dump-context.h index b2aed28..e90c4ee 100644 --- a/gcc/dump-context.h +++ b/gcc/dump-context.h @@ -120,7 +120,7 @@ class dump_context void end_any_optinfo (); void emit_optinfo (const optinfo *info); - void emit_item (optinfo_item *item, dump_flags_t dump_kind); + void emit_item (const optinfo_item &item, dump_flags_t dump_kind); bool apply_dump_filter_p (dump_flags_t dump_kind, dump_flags_t filter) const; @@ -154,47 +154,52 @@ class dump_context }; /* 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. */ + In particular, the formatted chunks are captured as optinfo_item instances + as pp_token_custom_data, thus retaining metadata about the entities being + dumped (e.g. source locations), rather than just as plain text. + These custom items are retained through to the end of stage 3 of formatted + printing; the printer uses a custom token_printer subclass to emit them to + the active optinfo (if any). */ class dump_pretty_printer : public pretty_printer { public: dump_pretty_printer (dump_context *context, dump_flags_t dump_kind); - void emit_items (optinfo *dest); + void set_optinfo (optinfo *info) { m_token_printer.m_optinfo = info; } private: - /* Information on an optinfo_item that was generated during phase 2 of - formatting. */ - class stashed_item + struct custom_token_printer : public token_printer { - public: - stashed_item (const char **buffer_ptr_, optinfo_item *item_) - : buffer_ptr (buffer_ptr_), item (item_) {} - const char **buffer_ptr; - optinfo_item *item; + custom_token_printer (dump_pretty_printer &dump_pp) + : m_dump_pp (dump_pp), + m_optinfo (nullptr) + {} + void print_tokens (pretty_printer *pp, + const pp_token_list &tokens) final override; + void emit_any_pending_textual_chunks (); + + dump_pretty_printer &m_dump_pp; + optinfo *m_optinfo; }; static bool format_decoder_cb (pretty_printer *pp, text_info *text, const char *spec, int /*precision*/, bool /*wide*/, bool /*set_locus*/, bool /*verbose*/, bool */*quoted*/, - const char **buffer_ptr); + pp_token_list &formatted_tok_list); bool decode_format (text_info *text, const char *spec, - const char **buffer_ptr); + pp_token_list &formatted_tok_list); - void stash_item (const char **buffer_ptr, optinfo_item *item); + void stash_item (pp_token_list &formatted_tok_list, + std::unique_ptr<optinfo_item> item); - void emit_any_pending_textual_chunks (optinfo *dest); - - void emit_item (optinfo_item *item, optinfo *dest); + void emit_item (std::unique_ptr<optinfo_item> item, optinfo *dest); dump_context *m_context; dump_flags_t m_dump_kind; - auto_vec<stashed_item> m_stashed_items; + custom_token_printer m_token_printer; }; /* An RAII-style class for use in debug dumpers for temporarily using a |