pretty-print: move class chunk_info into its own header

No functional change intended.

gcc/cp/ChangeLog:
	* error.cc: Include "pretty-print-format-impl.h".

gcc/ChangeLog:
	* dumpfile.cc: Include "pretty-print-format-impl.h".
	* pretty-print-format-impl.h: New file, based on material from
	pretty-print.h.
	* pretty-print.cc: Include "pretty-print-format-impl.h".
	* pretty-print.h (chunk_info): Replace full declaration with
	a forward decl, moving full decl to pretty-print-format-impl.h.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
David Malcolm 2024-08-29 18:48:20 -04:00
parent 464a3d2fe5
commit 68a0ca6697
5 changed files with 74 additions and 44 deletions

View file

@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see
#include "c-family/c-type-mismatch.h"
#include "cp-name-hint.h"
#include "attribs.h"
#include "pretty-print-format-impl.h"
#define pp_separate_with_comma(PP) pp_cxx_separate_with (PP, ',')
#define pp_separate_with_semicolon(PP) pp_cxx_separate_with (PP, ';')

View file

@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see
#include "stringpool.h" /* for get_identifier. */
#include "spellcheck.h"
#include "make-unique.h"
#include "pretty-print-format-impl.h"
/* If non-NULL, return one past-the-end of the matching SUBPART of
the WHOLE string. */

View file

@ -0,0 +1,70 @@
/* Implementation detail of pp_format.
Copyright (C) 2002-2024 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_PRETTY_PRINT_FORMAT_IMPL_H
#define GCC_PRETTY_PRINT_FORMAT_IMPL_H
#include "pretty-print.h"
/* 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. */
class chunk_info
{
friend class pretty_printer;
friend class pp_markup::context;
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. */
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
to be output verbatim, odd-numbered chunks are format specifiers.
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 *m_args[PP_NL_ARGMAX * 2];
/* If non-null, information on quoted text runs within the chunks
for use by a urlifier. */
quoting_info *m_quotes;
};
#endif /* GCC_PRETTY_PRINT_FORMAT_IMPL_H */

View file

@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "intl.h"
#include "pretty-print.h"
#include "pretty-print-format-impl.h"
#include "pretty-print-markup.h"
#include "pretty-print-urlifier.h"
#include "diagnostic-color.h"

View file

@ -69,6 +69,7 @@ enum diagnostic_prefixing_rule_t
DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE = 0x2
};
class chunk_info;
class quoting_info;
class output_buffer;
class urlifier;
@ -77,50 +78,6 @@ namespace pp_markup {
class context;
} // namespace pp_markup
/* 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. */
class chunk_info
{
friend class pretty_printer;
friend class pp_markup::context;
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. */
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
to be output verbatim, odd-numbered chunks are format specifiers.
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 *m_args[PP_NL_ARGMAX * 2];
/* If non-null, information on quoted text runs within the chunks
for use by a urlifier. */
quoting_info *m_quotes;
};
/* The output buffer datatype. This is best seen as an abstract datatype
whose fields should not be accessed directly by clients. */
class output_buffer