No functional change intended.
gcc/cp/ChangeLog:
* error.cc (cxx_format_postprocessor::clone): Update to use
unique_ptr.
(cxx_dump_pretty_printer::cxx_dump_pretty_printer): Likewise.
(cxx_initialize_diagnostics): Likewise.
gcc/ChangeLog:
* pretty-print.cc (pretty_printer::pretty_printer): Use "nullptr"
rather than "NULL". Remove explicit delete of
m_format_postprocessor.
* pretty-print.h (format_postprocessor::clone): Use unique_ptr.
(pretty_printer::set_format_postprocessor): New.
(pretty_printer::m_format_postprocessor): Use unique_ptr.
(pp_format_postprocessor): Update for use of unique_ptr, removing
reference from return type.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
: m_type_a (), m_type_b ()
{}
- format_postprocessor *clone() const final override
+ std::unique_ptr<format_postprocessor>
+ clone() const final override
{
- return new cxx_format_postprocessor ();
+ return std::make_unique<cxx_format_postprocessor> ();
}
void handle (pretty_printer *pp) final override;
if (outf)
{
pp_format_decoder (this) = cp_printer;
- /* This gets deleted in ~pretty_printer. */
- pp_format_postprocessor (this) = new cxx_format_postprocessor ();
+ set_format_postprocessor (std::make_unique<cxx_format_postprocessor> ());
set_output_stream (outf);
}
}
cxx_initialize_diagnostics (diagnostic_context *context)
{
cxx_pretty_printer *pp = new cxx_pretty_printer ();
- pp_format_postprocessor (pp) = new cxx_format_postprocessor ();
+ pp->set_format_postprocessor (std::make_unique<cxx_format_postprocessor> ());
context->set_pretty_printer (std::unique_ptr<pretty_printer> (pp));
c_common_diagnostics_set_defaults (context);
m_indent_skip (0),
m_wrapping (),
m_format_decoder (nullptr),
- m_format_postprocessor (NULL),
+ m_format_postprocessor (nullptr),
m_token_printer (nullptr),
m_emitted_prefix (false),
m_need_newline (false),
m_indent_skip (other.m_indent_skip),
m_wrapping (other.m_wrapping),
m_format_decoder (other.m_format_decoder),
- m_format_postprocessor (NULL),
+ m_format_postprocessor (nullptr),
m_token_printer (other.m_token_printer),
m_emitted_prefix (other.m_emitted_prefix),
m_need_newline (other.m_need_newline),
pretty_printer::~pretty_printer ()
{
- if (m_format_postprocessor)
- delete m_format_postprocessor;
m_buffer->~output_buffer ();
XDELETE (m_buffer);
free (m_prefix);
{
public:
virtual ~format_postprocessor () {}
- virtual format_postprocessor *clone() const = 0;
+ virtual std::unique_ptr<format_postprocessor> clone() const = 0;
virtual void handle (pretty_printer *) = 0;
};
inline bool & pp_translate_identifiers (pretty_printer *pp);
inline bool & pp_show_color (pretty_printer *pp);
inline printer_fn &pp_format_decoder (pretty_printer *pp);
-inline format_postprocessor *& pp_format_postprocessor (pretty_printer *pp);
+inline format_postprocessor *pp_format_postprocessor (pretty_printer *pp);
inline bool & pp_show_highlight_colors (pretty_printer *pp);
class urlifier;
friend bool & pp_translate_identifiers (pretty_printer *pp);
friend bool & pp_show_color (pretty_printer *pp);
friend printer_fn &pp_format_decoder (pretty_printer *pp);
- friend format_postprocessor *& pp_format_postprocessor (pretty_printer *pp);
+ friend format_postprocessor * pp_format_postprocessor (pretty_printer *pp);
friend bool & pp_show_highlight_colors (pretty_printer *pp);
friend void pp_output_formatted_text (pretty_printer *,
void set_real_maximum_length ();
int remaining_character_count_for_line ();
+ void set_format_postprocessor (std::unique_ptr<format_postprocessor> p)
+ {
+ m_format_postprocessor = std::move (p);
+ }
+
void dump (FILE *out, int indent) const;
void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
have been processed, to allow for client-specific postprocessing.
This is used by the C++ frontend for handling the %H and %I
format codes (which interract with each other). */
- format_postprocessor *m_format_postprocessor;
+ std::unique_ptr<format_postprocessor> m_format_postprocessor;
/* This is used by pp_output_formatted_text after it has converted all
formatted chunks into a single list of tokens.
return pp->m_format_decoder;
}
-inline format_postprocessor *&
+inline format_postprocessor *
pp_format_postprocessor (pretty_printer *pp)
{
- return pp->m_format_postprocessor;
+ return pp->m_format_postprocessor.get ();
}
inline bool &