@@ -111,12 +111,9 @@ call_string::to_json () const
for (const call_string::element_t &e : m_elements)
{
json::object *e_obj = new json::object ();
- e_obj->set ("src_snode_idx",
- new json::integer_number (e.m_callee->m_index));
- e_obj->set ("dst_snode_idx",
- new json::integer_number (e.m_caller->m_index));
- e_obj->set ("funcname",
- new json::string (function_name (e.m_caller->m_fun)));
+ e_obj->set_integer ("src_snode_idx", e.m_callee->m_index);
+ e_obj->set_integer ("dst_snode_idx", e.m_caller->m_index);
+ e_obj->set_string ("funcname", function_name (e.m_caller->m_fun));
arr->append (e_obj);
}
@@ -479,7 +479,7 @@ bounded_range::set_json_attr (json::object *obj, const char *name, tree value)
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
pp_printf (&pp, "%E", value);
- obj->set (name, new json::string (pp_formatted_text (&pp)));
+ obj->set_string (name, pp_formatted_text (&pp));
}
@@ -1140,7 +1140,7 @@ equiv_class::to_json () const
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
pp_printf (&pp, "%qE", m_constant);
- ec_obj->set ("constant", new json::string (pp_formatted_text (&pp)));
+ ec_obj->set_string ("constant", pp_formatted_text (&pp));
}
return ec_obj;
@@ -1397,9 +1397,9 @@ constraint::to_json () const
{
json::object *con_obj = new json::object ();
- con_obj->set ("lhs", new json::integer_number (m_lhs.as_int ()));
- con_obj->set ("op", new json::string (constraint_op_code (m_op)));
- con_obj->set ("rhs", new json::integer_number (m_rhs.as_int ()));
+ con_obj->set_integer ("lhs", m_lhs.as_int ());
+ con_obj->set_string ("op", constraint_op_code (m_op));
+ con_obj->set_integer ("rhs", m_rhs.as_int ());
return con_obj;
}
@@ -1485,7 +1485,7 @@ bounded_ranges_constraint::to_json () const
{
json::object *con_obj = new json::object ();
- con_obj->set ("ec", new json::integer_number (m_ec_id.as_int ()));
+ con_obj->set_integer ("ec", m_ec_id.as_int ());
con_obj->set ("ranges", m_ranges->to_json ());
return con_obj;
@@ -746,17 +746,17 @@ saved_diagnostic::to_json () const
json::object *sd_obj = new json::object ();
if (m_sm)
- sd_obj->set ("sm", new json::string (m_sm->get_name ()));
- sd_obj->set ("enode", new json::integer_number (m_enode->m_index));
- sd_obj->set ("snode", new json::integer_number (m_snode->m_index));
+ sd_obj->set_string ("sm", m_sm->get_name ());
+ sd_obj->set_integer ("enode", m_enode->m_index);
+ sd_obj->set_integer ("snode", m_snode->m_index);
if (m_sval)
sd_obj->set ("sval", m_sval->to_json ());
if (m_state)
sd_obj->set ("state", m_state->to_json ());
if (m_best_epath)
- sd_obj->set ("path_length", new json::integer_number (get_epath_length ()));
- sd_obj->set ("pending_diagnostic", new json::string (m_d->get_kind ()));
- sd_obj->set ("idx", new json::integer_number (m_idx));
+ sd_obj->set_integer ("path_length", get_epath_length ());
+ sd_obj->set_string ("pending_diagnostic", m_d->get_kind ());
+ sd_obj->set_integer ("idx", m_idx);
/* We're not yet JSONifying the following fields:
const gimple *m_stmt;
@@ -1038,7 +1038,7 @@ saved_diagnostic::maybe_add_sarif_properties (sarif_object &result_obj) const
if (m_state)
props.set (PROPERTY_PREFIX "state", m_state->to_json ());
if (m_best_epath)
- props.set (PROPERTY_PREFIX "idx", new json::integer_number (m_idx));
+ props.set_integer (PROPERTY_PREFIX "idx", m_idx);
#undef PROPERTY_PREFIX
/* Potentially add pending_diagnostic-specific properties. */
@@ -1449,10 +1449,9 @@ exploded_node::to_json (const extrinsic_state &ext_state) const
enode_obj->set ("point", get_point ().to_json ());
enode_obj->set ("state", get_state ().to_json (ext_state));
- enode_obj->set ("status", new json::string (status_to_str (m_status)));
- enode_obj->set ("idx", new json::integer_number (m_index));
- enode_obj->set ("processed_stmts",
- new json::integer_number (m_num_processed_stmts));
+ enode_obj->set_string ("status", status_to_str (m_status));
+ enode_obj->set_integer ("idx", m_index);
+ enode_obj->set_integer ("processed_stmts", m_num_processed_stmts);
return enode_obj;
}
@@ -2298,8 +2297,8 @@ json::object *
exploded_edge::to_json () const
{
json::object *eedge_obj = new json::object ();
- eedge_obj->set ("src_idx", new json::integer_number (m_src->m_index));
- eedge_obj->set ("dst_idx", new json::integer_number (m_dest->m_index));
+ eedge_obj->set_integer ("src_idx", m_src->m_index);
+ eedge_obj->set_integer ("dst_idx", m_dest->m_index);
if (m_sedge)
eedge_obj->set ("sedge", m_sedge->to_json ());
if (m_custom_info)
@@ -2307,7 +2306,7 @@ exploded_edge::to_json () const
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
m_custom_info->print (&pp);
- eedge_obj->set ("custom", new json::string (pp_formatted_text (&pp)));
+ eedge_obj->set_string ("custom", pp_formatted_text (&pp));
}
return eedge_obj;
}
@@ -319,23 +319,20 @@ program_point::to_json () const
{
json::object *point_obj = new json::object ();
- point_obj->set ("kind",
- new json::string (point_kind_to_string (get_kind ())));
+ point_obj->set_string ("kind", point_kind_to_string (get_kind ()));
if (get_supernode ())
- point_obj->set ("snode_idx",
- new json::integer_number (get_supernode ()->m_index));
+ point_obj->set_integer ("snode_idx", get_supernode ()->m_index);
switch (get_kind ())
{
default: break;
case PK_BEFORE_SUPERNODE:
if (const superedge *sedge = get_from_edge ())
- point_obj->set ("from_edge_snode_idx",
- new json::integer_number (sedge->m_src->m_index));
+ point_obj->set_integer ("from_edge_snode_idx", sedge->m_src->m_index);
break;
case PK_BEFORE_STMT:
- point_obj->set ("stmt_idx", new json::integer_number (get_stmt_idx ()));
+ point_obj->set_integer ("stmt_idx", get_stmt_idx ());
break;
}
@@ -1223,7 +1223,7 @@ program_state::to_json (const extrinsic_state &ext_state) const
state_obj->set ("checkers", checkers_obj);
}
- state_obj->set ("valid", new json::literal (m_valid));
+ state_obj->set_bool ("valid", m_valid);
return state_obj;
}
@@ -156,7 +156,7 @@ state_machine::to_json () const
{
json::object *sm_obj = new json::object ();
- sm_obj->set ("name", new json::string (m_name));
+ sm_obj->set_string ("name", m_name);
{
json::array *states_arr = new json::array ();
unsigned i;
@@ -1444,8 +1444,8 @@ binding_cluster::to_json () const
{
json::object *cluster_obj = new json::object ();
- cluster_obj->set ("escaped", new json::literal (m_escaped));
- cluster_obj->set ("touched", new json::literal (m_touched));
+ cluster_obj->set_bool ("escaped", m_escaped);
+ cluster_obj->set_bool ("touched", m_touched);
cluster_obj->set ("map", m_map.to_json ());
return cluster_obj;
@@ -2705,7 +2705,7 @@ store::to_json () const
store_obj->set (parent_reg_desc.get (), clusters_in_parent_reg_obj);
}
- store_obj->set ("called_unknown_fn", new json::literal (m_called_unknown_fn));
+ store_obj->set_bool ("called_unknown_fn", m_called_unknown_fn);
return store_obj;
}
@@ -723,18 +723,17 @@ supernode::to_json () const
{
json::object *snode_obj = new json::object ();
- snode_obj->set ("idx", new json::integer_number (m_index));
- snode_obj->set ("bb_idx", new json::integer_number (m_bb->index));
+ snode_obj->set_integer ("idx", m_index);
+ snode_obj->set_integer ("bb_idx", m_bb->index);
if (function *fun = get_function ())
- snode_obj->set ("fun", new json::string (function_name (fun)));
+ snode_obj->set_string ("fun", function_name (fun));
if (m_returning_call)
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
pp_gimple_stmt_1 (&pp, m_returning_call, 0, (dump_flags_t)0);
- snode_obj->set ("returning_call",
- new json::string (pp_formatted_text (&pp)));
+ snode_obj->set_string ("returning_call", pp_formatted_text (&pp));
}
/* Phi nodes. */
@@ -990,15 +989,15 @@ json::object *
superedge::to_json () const
{
json::object *sedge_obj = new json::object ();
- sedge_obj->set ("kind", new json::string (edge_kind_to_string (m_kind)));
- sedge_obj->set ("src_idx", new json::integer_number (m_src->m_index));
- sedge_obj->set ("dst_idx", new json::integer_number (m_dest->m_index));
+ sedge_obj->set_string ("kind", edge_kind_to_string (m_kind));
+ sedge_obj->set_integer ("src_idx", m_src->m_index);
+ sedge_obj->set_integer ("dst_idx", m_dest->m_index);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
dump_label_to_pp (&pp, false);
- sedge_obj->set ("desc", new json::string (pp_formatted_text (&pp)));
+ sedge_obj->set_string ("desc", pp_formatted_text (&pp));
}
return sedge_obj;
No functional change intended. gcc/analyzer/ChangeLog: * call-string.cc (call_string::to_json): Avoid naked "new". * constraint-manager.cc (bounded_range::set_json_attr): Likewise. (equiv_class::to_json): Likewise. (constraint::to_json): Likewise. (bounded_ranges_constraint::to_json): Likewise. * diagnostic-manager.cc (saved_diagnostic::to_json): Likewise. (saved_diagnostic::maybe_add_sarif_properties): Likewise. * engine.cc (exploded_node::to_json): Likewise. (exploded_edge::to_json): Likewise. * program-point.cc (program_point::to_json): Likewise. * program-state.cc (program_state::to_json): Likewise. * sm.cc (state_machine::to_json): Likewise. * store.cc (binding_cluster::to_json): Likewise. (store::to_json): Likewise. * supergraph.cc (supernode::to_json): Likewise. (superedge::to_json): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com> --- gcc/analyzer/call-string.cc | 9 +++------ gcc/analyzer/constraint-manager.cc | 12 ++++++------ gcc/analyzer/diagnostic-manager.cc | 14 +++++++------- gcc/analyzer/engine.cc | 13 ++++++------- gcc/analyzer/program-point.cc | 11 ++++------- gcc/analyzer/program-state.cc | 2 +- gcc/analyzer/sm.cc | 2 +- gcc/analyzer/store.cc | 6 +++--- gcc/analyzer/supergraph.cc | 17 ++++++++--------- 9 files changed, 39 insertions(+), 47 deletions(-)