aboutsummaryrefslogtreecommitdiff
path: root/gcc/pretty-print.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2024-06-12 09:15:09 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2024-06-12 09:15:09 -0400
commit1cae1a5ce088c1fa351b5752d43de52f1f116a75 (patch)
tree17acbd2d1cab142f7b402b2d46e46a109808a69f /gcc/pretty-print.h
parentc5e3be456888aa48f591512ec28183703e70978c (diff)
downloadgcc-1cae1a5ce088c1fa351b5752d43de52f1f116a75.zip
gcc-1cae1a5ce088c1fa351b5752d43de52f1f116a75.tar.gz
gcc-1cae1a5ce088c1fa351b5752d43de52f1f116a75.tar.bz2
pretty_printer: convert chunk_info into a class
No functional change intended. gcc/cp/ChangeLog: * error.cc (append_formatted_chunk): Move part of body into chunk_info::append_formatted_chunk. gcc/ChangeLog: * dumpfile.cc (dump_pretty_printer::emit_items): Update for changes to chunk_info. * pretty-print.cc (chunk_info::append_formatted_chunk): New, based on code in cp/error.cc's append_formatted_chunk. (chunk_info::pop_from_output_buffer): New, based on code in pp_output_formatted_text and dump_pretty_printer::emit_items. (on_begin_quote): Convert to... (chunk_info::on_begin_quote): ...this. (on_end_quote): Convert to... (chunk_info::on_end_quote): ...this. (pretty_printer::format): Update for chunk_info becoming a class and its fields gaining "m_" prefixes. Update for on_begin_quote and on_end_quote moving to chunk_info. (quoting_info::handle_phase_3): Update for changes to chunk_info. (pp_output_formatted_text): Likewise. Move cleanup code to chunk_info::pop_from_output_buffer. * pretty-print.h (class output_buffer): New forward decl. (class urlifier): New forward decl. (struct chunk_info): Convert to... (class chunk_info): ...this. Add friend class pretty_printer. (chunk_info::get_args): New accessor. (chunk_info::get_quoting_info): New accessor. (chunk_info::append_formatted_chunk): New decl. (chunk_info::pop_from_output_buffer): New decl. (chunk_info::on_begin_quote): New decl. (chunk_info::on_end_quote): New decl. (chunk_info::prev): Rename to... (chunk_info::m_prev): ...this. (chunk_info::args): Rename to... (chunk_info::m_args): ...this. (output_buffer::cur_chunk_array): Drop "struct" from decl. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/pretty-print.h')
-rw-r--r--gcc/pretty-print.h30
1 files changed, 26 insertions, 4 deletions
diff --git a/gcc/pretty-print.h b/gcc/pretty-print.h
index 99e55dc..b41d3ce 100644
--- a/gcc/pretty-print.h
+++ b/gcc/pretty-print.h
@@ -70,16 +70,38 @@ enum diagnostic_prefixing_rule_t
};
class quoting_info;
+class output_buffer;
+class urlifier;
/* The chunk_info data structure forms a stack of the results from the
first phase of formatting (pp_format) which have not yet been
output (pp_output_formatted_text). A stack is necessary because
the diagnostic starter may decide to generate its own output by way
of the formatter. */
-struct chunk_info
+class chunk_info
{
+ friend class pretty_printer;
+
+public:
+ const char * const *get_args () const { return m_args; }
+ quoting_info *get_quoting_info () const { return m_quotes; }
+
+ void append_formatted_chunk (const char *content);
+
+ void pop_from_output_buffer (output_buffer &buf);
+
+private:
+ void on_begin_quote (const output_buffer &buf,
+ unsigned chunk_idx,
+ const urlifier *urlifier);
+
+ void on_end_quote (pretty_printer *pp,
+ output_buffer &buf,
+ unsigned chunk_idx,
+ const urlifier *urlifier);
+
/* Pointer to previous chunk on the stack. */
- struct chunk_info *prev;
+ chunk_info *m_prev;
/* Array of chunks to output. Each chunk is a NUL-terminated string.
In the first phase of formatting, even-numbered chunks are
@@ -87,7 +109,7 @@ struct chunk_info
The second phase replaces all odd-numbered chunks with formatted
text, and the third phase simply emits all the chunks in sequence
with appropriate line-wrapping. */
- const char *args[PP_NL_ARGMAX * 2];
+ const char *m_args[PP_NL_ARGMAX * 2];
/* If non-null, information on quoted text runs within the chunks
for use by a urlifier. */
@@ -114,7 +136,7 @@ public:
struct obstack *obstack;
/* Stack of chunk arrays. These come from the chunk_obstack. */
- struct chunk_info *cur_chunk_array;
+ chunk_info *cur_chunk_array;
/* Where to output formatted text. */
FILE *stream;