diff options
author | David Malcolm <dmalcolm@redhat.com> | 2019-12-11 19:06:39 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2019-12-11 19:06:39 +0000 |
commit | 368877a11b789a74b1ae5b878e3bd30039118c30 (patch) | |
tree | 616fe464613c54fdd3f9145a99dc1e15724d8745 /gcc/c-family | |
parent | 34a53788fec49e0a85bd32b51b057cfaae0200c8 (diff) |
Introduce pretty_printer::clone vfunc
This patch provides a way to clone a pretty_printer.
This is needed so that we can capture text in a label_text and make
layout decisions based on it, using the policy of global_dc's printer,
whilst within a call to diagnostic_show_locus. We can't print with
the pretty_printer itself within a call to diagnostic_show_locus since
it has partly-buffered content.
gcc/c-family/ChangeLog:
* c-pretty-print.c (c_pretty_printer::clone): New vfunc
implementation.
* c-pretty-print.h (c_pretty_printer::clone): New vfunc decl.
gcc/cp/ChangeLog:
* cxx-pretty-print.c (cxx_pretty_printer::clone): New vfunc
implementation.
* cxx-pretty-print.h (cxx_pretty_printer::clone): New vfunc decl.
* error.c (cxx_format_postprocessor::clone): New vfunc.
gcc/ChangeLog:
* pretty-print.c (pretty_printer::pretty_printer): New copy-ctor.
(pretty_printer::clone): New vfunc implementation.
* pretty-print.h (format_postprocessor::clone): New pure vfunc
decl.
(pretty_printer::pretty_printer): New copy-ctor decl.
(pretty_printer::clone): New vfunc decl.
From-SVN: r279244
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-pretty-print.c | 7 | ||||
-rw-r--r-- | gcc/c-family/c-pretty-print.h | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 9d488555c42..b264c38177f 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2019-12-11 David Malcolm <dmalcolm@redhat.com> + + * c-pretty-print.c (c_pretty_printer::clone): New vfunc + implementation. + * c-pretty-print.h (c_pretty_printer::clone): New vfunc decl. + 2019-12-09 David Malcolm <dmalcolm@redhat.com> * c-format.c (range_label_for_format_type_mismatch::get_text): diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index bc7354559ba..e5e898a6253 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -2372,6 +2372,13 @@ c_pretty_printer::c_pretty_printer () parameter_list = pp_c_parameter_type_list; } +/* c_pretty_printer's implementation of pretty_printer::clone vfunc. */ + +pretty_printer * +c_pretty_printer::clone () const +{ + return new c_pretty_printer (*this); +} /* Print the tree T in full, on file FILE. */ diff --git a/gcc/c-family/c-pretty-print.h b/gcc/c-family/c-pretty-print.h index 8d69620b724..df21e212734 100644 --- a/gcc/c-family/c-pretty-print.h +++ b/gcc/c-family/c-pretty-print.h @@ -51,6 +51,7 @@ class c_pretty_printer : public pretty_printer { public: c_pretty_printer (); + pretty_printer *clone () const OVERRIDE; // Format string, possibly translated. void translate_string (const char *); |