/* Phi nodes. */
{
- json::array *phi_arr = new json::array ();
+ auto phi_arr = ::make_unique<json::array> ();
for (gphi_iterator gpi = const_cast<supernode *> (this)->start_phis ();
!gsi_end_p (gpi); gsi_next (&gpi))
{
pp_gimple_stmt_1 (&pp, stmt, 0, (dump_flags_t)0);
phi_arr->append_string (pp_formatted_text (&pp));
}
- snode_obj->set ("phis", phi_arr);
+ snode_obj->set ("phis", std::move (phi_arr));
}
/* Statements. */
{
- json::array *stmt_arr = new json::array ();
+ auto stmt_arr = ::make_unique<json::array> ();
int i;
gimple *stmt;
FOR_EACH_VEC_ELT (m_stmts, i, stmt)
pp_gimple_stmt_1 (&pp, stmt, 0, (dump_flags_t)0);
stmt_arr->append_string (pp_formatted_text (&pp));
}
- snode_obj->set ("stmts", stmt_arr);
+ snode_obj->set ("stmts", std::move (stmt_arr));
}
return snode_obj;
#include "timevar.h"
#include "options.h"
#include "json.h"
+#include "make-unique.h"
/* Non-NULL if timevars should be used. In GCC, this happens with
the -ftime-report flag. */
void pop ();
void print (FILE *fp, const timevar_time_def *total);
- json::value *make_json () const;
+ std::unique_ptr<json::value> make_json () const;
private:
/* Which timer instance does this relate to? */
/* Create a json value representing this object, suitable for use
in SARIF output. */
-json::value *
+std::unique_ptr<json::value>
timer::named_items::make_json () const
{
- json::array *arr = new json::array ();
+ auto arr = ::make_unique<json::array> ();
for (const char *item_name : m_names)
{
hash_map_t &mut_map = const_cast <hash_map_t &> (m_hash_map);
/* Create a json value representing this object, suitable for use
in SARIF output. */
-json::object *
+std::unique_ptr<json::object>
make_json_for_timevar_time_def (const timevar_time_def &ttd)
{
- json::object *obj = new json::object ();
+ auto obj = ::make_unique<json::object> ();
obj->set_float ("wall", nanosec_to_floating_sec (ttd.wall));
obj->set_integer ("ggc_mem", ttd.ggc_mem);
return obj;
/* Create a json value representing this object, suitable for use
in SARIF output. */
-json::value *
+std::unique_ptr<json::value>
timer::timevar_def::make_json () const
{
- json::object *timevar_obj = new json::object ();
+ auto timevar_obj = ::make_unique<json::object> ();
timevar_obj->set_string ("name", name);
timevar_obj->set ("elapsed", make_json_for_timevar_time_def (elapsed));
}
if (any_children_with_time)
{
- json::array *children_arr = new json::array ();
- timevar_obj->set ("children", children_arr);
+ auto children_arr = ::make_unique<json::array> ();
for (auto i : *children)
{
/* Don't emit timing variables if we're going to get a row of
zeroes. */
if (all_zero (i.second))
continue;
- json::object *child_obj = new json::object;
- children_arr->append (child_obj);
+ auto child_obj = ::make_unique<json::object> ();
child_obj->set_string ("name", i.first->name);
child_obj->set ("elapsed",
make_json_for_timevar_time_def (i.second));
+ children_arr->append (std::move (child_obj));
}
+ timevar_obj->set ("children", std::move (children_arr));
}
}
/* Create a json value representing this object, suitable for use
in SARIF output. */
-json::value *
+std::unique_ptr<json::value>
timer::make_json () const
{
#if defined (HAVE_WALL_TIME)
- json::object *report_obj = new json::object ();
+ auto report_obj = ::make_unique<json::object> ();
json::array *json_arr = new json::array ();
report_obj->set ("timevars", json_arr);
get_time (&total_now);
timevar_diff (&total_elapsed, m_timevars[TV_TOTAL].start_time, total_now);
- json::object *total_obj = new json::object();
- json_arr->append (total_obj);
+ auto total_obj = ::make_unique<json::object> ();
total_obj->set_string ("name", "TOTAL");
total_obj->set ("elapsed", make_json_for_timevar_time_def (total_elapsed));
+ json_arr->append (std::move (total_obj));
}
if (m_jit_client_items)