No functional change intended.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r15-4858-g0cb6078ca83f54.
gcc/analyzer/ChangeLog:
* analyzer.cc: Include "make-unique.h". Convert "to_json"
functions to use std::unique_ptr.
* call-string.cc: Likewise.
* constraint-manager.cc: Likewise.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* program-point.cc: Likewise.
* program-state.cc: Likewise.
* ranges.cc: Likewise.
* region-model.cc: Likewise.
* region.cc: Likewise.
* svalue.cc: Likewise.
* sm.cc: Likewise.
* store.cc: Likewise.
* supergraph.cc: Likewise.
* analyzer.h: Convert "to_json" functions to return
std::unique_ptr.
* call-string.h: Likewise.
* constraint-manager.h: Likewise.
(bounded_range::set_json_attr): Pass "obj" by reference.
* diagnostic-manager.h: Convert "to_json" functions to return
std::unique_ptr.
* exploded-graph.h: Likewise.
* program-point.h: Likewise.
* program-state.h: Likewise.
* ranges.h: Likewise.
* region-model.h: Likewise.
* region.h: Likewise.
* sm.h: Likewise.
* store.h: Likewise.
* supergraph.h: Likewise.
* svalue.h: Likewise.
Signed-off-by: David Malcolm <[email protected]>
---
gcc/analyzer/analyzer.cc | 21 +++++++------
gcc/analyzer/analyzer.h | 8 ++---
gcc/analyzer/call-string.cc | 9 +++---
gcc/analyzer/call-string.h | 2 +-
gcc/analyzer/constraint-manager.cc | 49 +++++++++++++++---------------
gcc/analyzer/constraint-manager.h | 14 ++++-----
gcc/analyzer/diagnostic-manager.cc | 12 ++++----
gcc/analyzer/diagnostic-manager.h | 4 +--
gcc/analyzer/engine.cc | 32 +++++++++----------
gcc/analyzer/exploded-graph.h | 10 +++---
gcc/analyzer/program-point.cc | 5 +--
gcc/analyzer/program-point.h | 2 +-
gcc/analyzer/program-state.cc | 21 +++++++------
gcc/analyzer/program-state.h | 7 +++--
gcc/analyzer/ranges.cc | 7 +++--
gcc/analyzer/ranges.h | 4 +--
gcc/analyzer/region-model.cc | 8 ++---
gcc/analyzer/region-model.h | 4 +--
gcc/analyzer/region.cc | 5 +--
gcc/analyzer/region.h | 2 +-
gcc/analyzer/sm.cc | 13 ++++----
gcc/analyzer/sm.h | 4 +--
gcc/analyzer/store.cc | 26 ++++++++--------
gcc/analyzer/store.h | 10 +++---
gcc/analyzer/supergraph.cc | 21 +++++++------
gcc/analyzer/supergraph.h | 6 ++--
gcc/analyzer/svalue.cc | 4 +--
gcc/analyzer/svalue.h | 2 +-
28 files changed, 161 insertions(+), 151 deletions(-)
diff --git a/gcc/analyzer/analyzer.cc b/gcc/analyzer/analyzer.cc
index 0f998e3f66f7..f77dcd76c5cd 100644
--- a/gcc/analyzer/analyzer.cc
+++ b/gcc/analyzer/analyzer.cc
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-pretty-print.h"
#include "diagnostic-event-id.h"
#include "tree-dfa.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
@@ -223,15 +224,15 @@ get_diagnostic_tree_for_gassign (const gassign
*assign_stmt)
This is intended for debugging the analyzer rather than serialization and
thus is a string (or null, for NULL_TREE). */
-json::value *
+std::unique_ptr<json::value>
tree_to_json (tree node)
{
if (!node)
- return new json::literal (json::JSON_NULL);
+ return ::make_unique<json::literal> (json::JSON_NULL);
pretty_printer pp;
dump_generic_node (&pp, node, 0, TDF_VOPS|TDF_MEMSYMS, false);
- return new json::string (pp_formatted_text (&pp));
+ return ::make_unique<json::string> (pp_formatted_text (&pp));
}
/* Generate a JSON value for EVENT_ID.
@@ -239,41 +240,41 @@ tree_to_json (tree node)
thus is a string matching those seen in event messags (or null,
for unknown). */
-json::value *
+std::unique_ptr<json::value>
diagnostic_event_id_to_json (const diagnostic_event_id_t &event_id)
{
if (event_id.known_p ())
{
pretty_printer pp;
pp_printf (&pp, "%@", &event_id);
- return new json::string (pp_formatted_text (&pp));
+ return ::make_unique<json::string> (pp_formatted_text (&pp));
}
else
- return new json::literal (json::JSON_NULL);
+ return ::make_unique<json::literal> (json::JSON_NULL);
}
/* Generate a JSON value for OFFSET.
This is intended for debugging the analyzer rather than serialization and
thus is a string. */
-json::value *
+std::unique_ptr<json::value>
bit_offset_to_json (const bit_offset_t &offset)
{
pretty_printer pp;
pp_wide_int_large (&pp, offset, SIGNED);
- return new json::string (pp_formatted_text (&pp));
+ return ::make_unique<json::string> (pp_formatted_text (&pp));
}
/* Generate a JSON value for OFFSET.
This is intended for debugging the analyzer rather than serialization and
thus is a string. */
-json::value *
+std::unique_ptr<json::value>
byte_offset_to_json (const byte_offset_t &offset)
{
pretty_printer pp;
pp_wide_int_large (&pp, offset, SIGNED);
- return new json::string (pp_formatted_text (&pp));
+ return ::make_unique<json::string> (pp_formatted_text (&pp));
}
/* Workaround for lack of const-correctness of ssa_default_def. */
diff --git a/gcc/analyzer/analyzer.h b/gcc/analyzer/analyzer.h
index 334b0d32bd05..db152b776ccd 100644
--- a/gcc/analyzer/analyzer.h
+++ b/gcc/analyzer/analyzer.h
@@ -416,16 +416,16 @@ extern void log_stashed_constants (logger *logger);
extern FILE *get_or_create_any_logfile ();
-extern json::value *
+extern std::unique_ptr<json::value>
tree_to_json (tree node);
-extern json::value *
+extern std::unique_ptr<json::value>
diagnostic_event_id_to_json (const diagnostic_event_id_t &);
-extern json::value *
+extern std::unique_ptr<json::value>
bit_offset_to_json (const bit_offset_t &offset);
-extern json::value *
+extern std::unique_ptr<json::value>
byte_offset_to_json (const byte_offset_t &offset);
extern tristate
diff --git a/gcc/analyzer/call-string.cc b/gcc/analyzer/call-string.cc
index c404c09ca0df..024a1fec03ef 100644
--- a/gcc/analyzer/call-string.cc
+++ b/gcc/analyzer/call-string.cc
@@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see
#include "analyzer/analyzer-logging.h"
#include "analyzer/call-string.h"
#include "analyzer/supergraph.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
@@ -103,18 +104,18 @@ call_string::print (pretty_printer *pp) const
"funcname" : str},
...for each element in the callstring]. */
-json::value *
+std::unique_ptr<json::value>
call_string::to_json () const
{
- json::array *arr = new json::array ();
+ auto arr = ::make_unique<json::array> ();
for (const call_string::element_t &e : m_elements)
{
- json::object *e_obj = new json::object ();
+ auto e_obj = ::make_unique<json::object> ();
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);
+ arr->append (std::move (e_obj));
}
return arr;
diff --git a/gcc/analyzer/call-string.h b/gcc/analyzer/call-string.h
index 1c17e2763016..b843067d679a 100644
--- a/gcc/analyzer/call-string.h
+++ b/gcc/analyzer/call-string.h
@@ -72,7 +72,7 @@ public:
void print (pretty_printer *pp) const;
- json::value *to_json () const;
+ std::unique_ptr<json::value> to_json () const;
bool empty_p () const { return m_elements.is_empty (); }
diff --git a/gcc/analyzer/constraint-manager.cc
b/gcc/analyzer/constraint-manager.cc
index 59487034cde7..429a3a0e2a71 100644
--- a/gcc/analyzer/constraint-manager.cc
+++ b/gcc/analyzer/constraint-manager.cc
@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see
#include "analyzer/call-summary.h"
#include "analyzer/analyzer-selftests.h"
#include "tree-pretty-print.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
@@ -446,12 +447,12 @@ bounded_range::dump (bool show_types) const
pp_newline (&pp);
}
-json::object *
+std::unique_ptr<json::object>
bounded_range::to_json () const
{
- json::object *range_obj = new json::object ();
- set_json_attr (range_obj, "lower", m_lower);
- set_json_attr (range_obj, "upper", m_upper);
+ auto range_obj = ::make_unique<json::object> ();
+ set_json_attr (*range_obj, "lower", m_lower);
+ set_json_attr (*range_obj, "upper", m_upper);
return range_obj;
}
@@ -466,12 +467,12 @@ bounded_range::make_dump_widget (const
text_art::dump_widget_info &dwi) const
/* Subroutine of bounded_range::to_json. */
void
-bounded_range::set_json_attr (json::object *obj, const char *name, tree value)
+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_string (name, pp_formatted_text (&pp));
+ obj.set_string (name, pp_formatted_text (&pp));
}
@@ -715,10 +716,10 @@ bounded_ranges::dump (bool show_types) const
pp_newline (&pp);
}
-json::value *
+std::unique_ptr<json::value>
bounded_ranges::to_json () const
{
- json::array *arr_obj = new json::array ();
+ auto arr_obj = ::make_unique<json::array> ();
for (unsigned i = 0; i < m_ranges.length (); ++i)
arr_obj->append (m_ranges[i].to_json ());
@@ -1113,15 +1114,15 @@ equiv_class::print (pretty_printer *pp) const
{"svals" : [str],
"constant" : optional str}. */
-json::object *
+std::unique_ptr<json::object>
equiv_class::to_json () const
{
- json::object *ec_obj = new json::object ();
+ auto ec_obj = ::make_unique<json::object> ();
- json::array *sval_arr = new json::array ();
+ auto sval_arr = ::make_unique<json::array> ();
for (const svalue *sval : m_vars)
sval_arr->append (sval->to_json ());
- ec_obj->set ("svals", sval_arr);
+ ec_obj->set ("svals", std::move (sval_arr));
if (m_constant)
{
@@ -1380,10 +1381,10 @@ constraint::print (pretty_printer *pp, const
constraint_manager &cm) const
"op" : str,
"rhs" : int, the EC index}. */
-json::object *
+std::unique_ptr<json::object>
constraint::to_json () const
{
- json::object *con_obj = new json::object ();
+ auto con_obj = ::make_unique<json::object> ();
con_obj->set_integer ("lhs", m_lhs.as_int ());
con_obj->set_string ("op", constraint_op_code (m_op));
@@ -1468,10 +1469,10 @@ bounded_ranges_constraint::print (pretty_printer *pp,
m_ranges->dump_to_pp (pp, true);
}
-json::object *
+std::unique_ptr<json::object>
bounded_ranges_constraint::to_json () const
{
- json::object *con_obj = new json::object ();
+ auto con_obj = ::make_unique<json::object> ();
con_obj->set_integer ("ec", m_ec_id.as_int ());
con_obj->set ("ranges", m_ranges->to_json ());
@@ -1781,33 +1782,33 @@ debug (const constraint_manager &cm)
{"ecs" : array of objects, one per equiv_class
"constraints" : array of objects, one per constraint}. */
-json::object *
+std::unique_ptr<json::object>
constraint_manager::to_json () const
{
- json::object *cm_obj = new json::object ();
+ auto cm_obj = ::make_unique<json::object> ();
/* Equivalence classes. */
{
- json::array *ec_arr = new json::array ();
+ auto ec_arr = ::make_unique<json::array> ();
for (const equiv_class *ec : m_equiv_classes)
ec_arr->append (ec->to_json ());
- cm_obj->set ("ecs", ec_arr);
+ cm_obj->set ("ecs", std::move (ec_arr));
}
/* Constraints. */
{
- json::array *con_arr = new json::array ();
+ auto con_arr = ::make_unique<json::array> ();
for (const constraint &c : m_constraints)
con_arr->append (c.to_json ());
- cm_obj->set ("constraints", con_arr);
+ cm_obj->set ("constraints", std::move (con_arr));
}
/* m_bounded_ranges_constraints. */
{
- json::array *con_arr = new json::array ();
+ auto con_arr = ::make_unique<json::array> ();
for (const auto &c : m_bounded_ranges_constraints)
con_arr->append (c.to_json ());
- cm_obj->set ("bounded_ranges_constraints", con_arr);
+ cm_obj->set ("bounded_ranges_constraints", std::move (con_arr));
}
return cm_obj;
diff --git a/gcc/analyzer/constraint-manager.h
b/gcc/analyzer/constraint-manager.h
index 81e9c7ec035c..399758b392f0 100644
--- a/gcc/analyzer/constraint-manager.h
+++ b/gcc/analyzer/constraint-manager.h
@@ -85,7 +85,7 @@ struct bounded_range
void dump_to_pp (pretty_printer *pp, bool show_types) const;
void dump (bool show_types) const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
std::unique_ptr<text_art::widget>
make_dump_widget (const text_art::dump_widget_info &dwi) const;
@@ -112,7 +112,7 @@ struct bounded_range
tree m_upper;
private:
- static void set_json_attr (json::object *obj, const char *name, tree value);
+ static void set_json_attr (json::object &obj, const char *name, tree value);
};
/* A collection of bounded_range instances, suitable
@@ -135,7 +135,7 @@ public:
void dump_to_pp (pretty_printer *pp, bool show_types) const;
void dump (bool show_types) const;
- json::value *to_json () const;
+ std::unique_ptr<json::value> to_json () const;
void add_to_dump_widget (text_art::tree_widget &parent,
const text_art::dump_widget_info &dwi) const;
@@ -271,7 +271,7 @@ public:
void print (pretty_printer *pp) const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
std::unique_ptr<text_art::tree_widget>
make_dump_widget (const text_art::dump_widget_info &dwi,
@@ -351,7 +351,7 @@ class constraint
void print (pretty_printer *pp, const constraint_manager &cm) const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
std::unique_ptr<text_art::widget>
make_dump_widget (const text_art::dump_widget_info &dwi,
@@ -398,7 +398,7 @@ public:
void print (pretty_printer *pp, const constraint_manager &cm) const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
bool operator== (const bounded_ranges_constraint &other) const;
bool operator!= (const bounded_ranges_constraint &other) const
@@ -442,7 +442,7 @@ public:
void dump (FILE *fp) const;
void dump () const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
std::unique_ptr<text_art::tree_widget>
make_dump_widget (const text_art::dump_widget_info &dwi) const;
diff --git a/gcc/analyzer/diagnostic-manager.cc
b/gcc/analyzer/diagnostic-manager.cc
index 0e5e96c3f936..999fb9cee0b4 100644
--- a/gcc/analyzer/diagnostic-manager.cc
+++ b/gcc/analyzer/diagnostic-manager.cc
@@ -740,10 +740,10 @@ saved_diagnostic::add_event
(std::unique_ptr<checker_event> event)
"pending_diagnostic": str,
"idx": int}. */
-json::object *
+std::unique_ptr<json::object>
saved_diagnostic::to_json () const
{
- json::object *sd_obj = new json::object ();
+ auto sd_obj = ::make_unique<json::object> ();
if (m_sm)
sd_obj->set_string ("sm", m_sm->get_name ());
@@ -1216,18 +1216,18 @@ diagnostic_manager::add_event
(std::unique_ptr<checker_event> event)
/* Return a new json::object of the form
{"diagnostics" : [obj for saved_diagnostic]}. */
-json::object *
+std::unique_ptr<json::object>
diagnostic_manager::to_json () const
{
- json::object *dm_obj = new json::object ();
+ auto dm_obj = ::make_unique<json::object> ();
{
- json::array *sd_arr = new json::array ();
+ auto sd_arr = ::make_unique<json::array> ();
int i;
saved_diagnostic *sd;
FOR_EACH_VEC_ELT (m_saved_diagnostics, i, sd)
sd_arr->append (sd->to_json ());
- dm_obj->set ("diagnostics", sd_arr);
+ dm_obj->set ("diagnostics", std::move (sd_arr));
}
return dm_obj;
diff --git a/gcc/analyzer/diagnostic-manager.h
b/gcc/analyzer/diagnostic-manager.h
index 8d55344693e0..6fbbe3e47ef6 100644
--- a/gcc/analyzer/diagnostic-manager.h
+++ b/gcc/analyzer/diagnostic-manager.h
@@ -42,7 +42,7 @@ public:
void add_note (std::unique_ptr<pending_note> pn);
void add_event (std::unique_ptr<checker_event> event);
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
void dump_dot_id (pretty_printer *pp) const;
void dump_as_dot_node (pretty_printer *pp) const;
@@ -157,7 +157,7 @@ public:
engine *get_engine () const { return m_eng; }
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
bool add_diagnostic (const state_machine *sm,
const pending_location &ploc,
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index ca81285175b6..d5328d7e162e 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -1438,10 +1438,10 @@ exploded_node::dump (const extrinsic_state &ext_state)
const
"idx" : int,
"processed_stmts" : int}. */
-json::object *
+std::unique_ptr<json::object>
exploded_node::to_json (const extrinsic_state &ext_state) const
{
- json::object *enode_obj = new json::object ();
+ auto enode_obj = ::make_unique<json::object> ();
enode_obj->set ("point", get_point ().to_json ());
enode_obj->set ("state", get_state ().to_json (ext_state));
@@ -2292,10 +2292,10 @@ exploded_edge::dump_dot_label (pretty_printer *pp) const
"sedge": (optional) object for the superedge, if any,
"custom": (optional) str, a description, if this is a custom edge}. */
-json::object *
+std::unique_ptr<json::object>
exploded_edge::to_json () const
{
- json::object *eedge_obj = new json::object ();
+ auto eedge_obj = ::make_unique<json::object> ();
eedge_obj->set_integer ("src_idx", m_src->m_index);
eedge_obj->set_integer ("dst_idx", m_dest->m_index);
if (m_sedge)
@@ -2418,10 +2418,10 @@ strongly_connected_components::dump () const
/* Return a new json::array of per-snode SCC ids. */
-json::array *
+std::unique_ptr<json::array>
strongly_connected_components::to_json () const
{
- json::array *scc_arr = new json::array ();
+ auto scc_arr = ::make_unique<json::array> ();
for (int i = 0; i < m_sg.num_nodes (); i++)
scc_arr->append (new json::integer_number (get_scc_id (i)));
return scc_arr;
@@ -2639,10 +2639,10 @@ worklist::key_t::cmp (const worklist::key_t &ka, const
worklist::key_t &kb)
/* Return a new json::object of the form
{"scc" : [per-snode-IDs]}, */
-json::object *
+std::unique_ptr<json::object>
worklist::to_json () const
{
- json::object *worklist_obj = new json::object ();
+ auto worklist_obj = ::make_unique<json::object> ();
worklist_obj->set ("scc", m_scc.to_json ());
@@ -4658,29 +4658,29 @@ exploded_graph::dump_states_for_supernode (FILE *out,
"ext_state": object for extrinsic_state,
"diagnostic_manager": object for diagnostic_manager}. */
-json::object *
+std::unique_ptr<json::object>
exploded_graph::to_json () const
{
- json::object *egraph_obj = new json::object ();
+ auto egraph_obj = ::make_unique<json::object> ();
/* Nodes. */
{
- json::array *nodes_arr = new json::array ();
+ auto nodes_arr = ::make_unique<json::array> ();
unsigned i;
exploded_node *n;
FOR_EACH_VEC_ELT (m_nodes, i, n)
nodes_arr->append (n->to_json (m_ext_state));
- egraph_obj->set ("nodes", nodes_arr);
+ egraph_obj->set ("nodes", std::move (nodes_arr));
}
/* Edges. */
{
- json::array *edges_arr = new json::array ();
+ auto edges_arr = ::make_unique<json::array> ();
unsigned i;
exploded_edge *n;
FOR_EACH_VEC_ELT (m_edges, i, n)
edges_arr->append (n->to_json ());
- egraph_obj->set ("edges", edges_arr);
+ egraph_obj->set ("edges", std::move (edges_arr));
}
/* m_sg is JSONified at the top-level. */
@@ -6095,7 +6095,7 @@ dump_analyzer_json (const supergraph &sg,
return;
}
- json::object *toplev_obj = new json::object ();
+ auto toplev_obj = ::make_unique<json::object> ();
toplev_obj->set ("sgraph", sg.to_json ());
toplev_obj->set ("egraph", eg.to_json ());
@@ -6103,8 +6103,6 @@ dump_analyzer_json (const supergraph &sg,
toplev_obj->print (&pp, flag_diagnostics_json_formatting);
pp_formatted_text (&pp);
- delete toplev_obj;
-
if (gzputs (output, pp_formatted_text (&pp)) == EOF
|| gzclose (output))
error_at (UNKNOWN_LOCATION, "error writing %qs", filename);
diff --git a/gcc/analyzer/exploded-graph.h b/gcc/analyzer/exploded-graph.h
index aa18bf468d9e..0e05a5db3f71 100644
--- a/gcc/analyzer/exploded-graph.h
+++ b/gcc/analyzer/exploded-graph.h
@@ -239,7 +239,7 @@ class exploded_node : public dnode<eg_traits>
void dump_processed_stmts (pretty_printer *pp) const;
void dump_saved_diagnostics (pretty_printer *pp) const;
- json::object *to_json (const extrinsic_state &ext_state) const;
+ std::unique_ptr<json::object> to_json (const extrinsic_state &ext_state)
const;
/* The result of on_stmt. */
struct on_stmt_flags
@@ -387,7 +387,7 @@ class exploded_edge : public dedge<eg_traits>
const final override;
void dump_dot_label (pretty_printer *pp) const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
//private:
const superedge *const m_sedge;
@@ -688,7 +688,7 @@ public:
void dump () const;
- json::array *to_json () const;
+ std::unique_ptr<json::array> to_json () const;
private:
struct per_node_data
@@ -732,7 +732,7 @@ public:
return m_scc.get_scc_id (snode.m_index);
}
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
private:
class key_t
@@ -867,7 +867,7 @@ public:
void dump_states_for_supernode (FILE *, const supernode *snode) const;
void dump_exploded_nodes () const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
exploded_node *get_node_by_index (int idx) const;
diff --git a/gcc/analyzer/program-point.cc b/gcc/analyzer/program-point.cc
index 313df9af1d31..bfb1dd48f801 100644
--- a/gcc/analyzer/program-point.cc
+++ b/gcc/analyzer/program-point.cc
@@ -54,6 +54,7 @@ along with GCC; see the file COPYING3. If not see
#include "analyzer/exploded-graph.h"
#include "analyzer/analysis-plan.h"
#include "analyzer/inlining-iterator.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
@@ -313,10 +314,10 @@ program_point::dump () const
"stmt_idx": int (only for kind=='PK_BEFORE_STMT',
"call_string": object for the call_string}. */
-json::object *
+std::unique_ptr<json::object>
program_point::to_json () const
{
- json::object *point_obj = new json::object ();
+ auto point_obj = ::make_unique<json::object> ();
point_obj->set_string ("kind", point_kind_to_string (get_kind ()));
diff --git a/gcc/analyzer/program-point.h b/gcc/analyzer/program-point.h
index 61b895f4499b..a2e04204f17d 100644
--- a/gcc/analyzer/program-point.h
+++ b/gcc/analyzer/program-point.h
@@ -184,7 +184,7 @@ public:
void print (pretty_printer *pp, const format &f) const;
void dump () const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
hashval_t hash () const;
bool operator== (const program_point &other) const
diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc
index bc7e30eacd50..5cad3e68bf01 100644
--- a/gcc/analyzer/program-state.cc
+++ b/gcc/analyzer/program-state.cc
@@ -56,6 +56,7 @@ along with GCC; see the file COPYING3. If not see
#include "analyzer/analyzer-selftests.h"
#include "text-art/tree-widget.h"
#include "text-art/dump.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
@@ -98,18 +99,18 @@ extrinsic_state::dump () const
/* Return a new json::object of the form
{"checkers" : array of objects, one for each state_machine}. */
-json::object *
+std::unique_ptr<json::object>
extrinsic_state::to_json () const
{
- json::object *ext_state_obj = new json::object ();
+ auto ext_state_obj = ::make_unique<json::object> ();
{
- json::array *checkers_arr = new json::array ();
+ auto checkers_arr = ::make_unique<json::array> ();
unsigned i;
state_machine *sm;
FOR_EACH_VEC_ELT (m_checkers, i, sm)
checkers_arr->append (sm->to_json ());
- ext_state_obj->set ("checkers", checkers_arr);
+ ext_state_obj->set ("checkers", std::move (checkers_arr));
}
return ext_state_obj;
@@ -276,10 +277,10 @@ sm_state_map::dump (bool simple) const
{"global" : (optional) value for global state,
SVAL_DESC : value for state}. */
-json::object *
+std::unique_ptr<json::object>
sm_state_map::to_json () const
{
- json::object *map_obj = new json::object ();
+ auto map_obj = ::make_unique<json::object> ();
if (m_global_state != m_sm.get_start_state ())
map_obj->set ("global", m_global_state->to_json ());
@@ -1185,10 +1186,10 @@ program_state::dump () const
"checkers" : { STATE_NAME : object per sm_state_map },
"valid" : true/false}. */
-json::object *
+std::unique_ptr<json::object>
program_state::to_json (const extrinsic_state &ext_state) const
{
- json::object *state_obj = new json::object ();
+ auto state_obj = ::make_unique<json::object> ();
state_obj->set ("store", m_region_model->get_store ()->to_json ());
state_obj->set ("constraints",
@@ -1199,7 +1200,7 @@ program_state::to_json (const extrinsic_state &ext_state)
const
/* Provide m_checker_states as an object, using names as keys. */
{
- json::object *checkers_obj = new json::object ();
+ auto checkers_obj = ::make_unique<json::object> ();
int i;
sm_state_map *smap;
@@ -1207,7 +1208,7 @@ program_state::to_json (const extrinsic_state &ext_state)
const
if (!smap->is_empty_p ())
checkers_obj->set (ext_state.get_name (i), smap->to_json ());
- state_obj->set ("checkers", checkers_obj);
+ state_obj->set ("checkers", std::move (checkers_obj));
}
state_obj->set_bool ("valid", m_valid);
diff --git a/gcc/analyzer/program-state.h b/gcc/analyzer/program-state.h
index 322ca8d0f11a..a9b4be2102c5 100644
--- a/gcc/analyzer/program-state.h
+++ b/gcc/analyzer/program-state.h
@@ -55,7 +55,7 @@ public:
void dump_to_file (FILE *outf) const;
void dump () const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
engine *get_engine () const { return m_engine; }
region_model_manager *get_model_manager () const;
@@ -117,7 +117,7 @@ public:
pretty_printer *pp) const;
void dump (bool simple) const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
std::unique_ptr<text_art::tree_widget>
make_dump_widget (const text_art::dump_widget_info &dwi,
@@ -231,7 +231,8 @@ public:
void dump (const extrinsic_state &ext_state, bool simple) const;
void dump () const;
- json::object *to_json (const extrinsic_state &ext_state) const;
+ std::unique_ptr<json::object>
+ to_json (const extrinsic_state &ext_state) const;
std::unique_ptr<text_art::tree_widget>
make_dump_widget (const text_art::dump_widget_info &dwi) const;
diff --git a/gcc/analyzer/ranges.cc b/gcc/analyzer/ranges.cc
index 3323a96fed10..420aac4a910d 100644
--- a/gcc/analyzer/ranges.cc
+++ b/gcc/analyzer/ranges.cc
@@ -54,6 +54,7 @@ along with GCC; see the file COPYING3. If not see
#include "analyzer/constraint-manager.h"
#include "analyzer/analyzer-selftests.h"
#include "analyzer/ranges.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
@@ -100,7 +101,7 @@ symbolic_byte_offset::dump (bool simple) const
pp_newline (&pp);
}
-json::value *
+std::unique_ptr<json::value>
symbolic_byte_offset::to_json () const
{
return m_num_bytes_sval->to_json ();
@@ -155,10 +156,10 @@ symbolic_byte_range::dump (bool simple,
region_model_manager &mgr) const
pp_newline (&pp);
}
-json::value *
+std::unique_ptr<json::value>
symbolic_byte_range::to_json () const
{
- json::object *obj = new json::object ();
+ auto obj = ::make_unique<json::object> ();
obj->set ("start", m_start.to_json ());
obj->set ("size", m_size.to_json ());
return obj;
diff --git a/gcc/analyzer/ranges.h b/gcc/analyzer/ranges.h
index aca4554bde69..b784cf470075 100644
--- a/gcc/analyzer/ranges.h
+++ b/gcc/analyzer/ranges.h
@@ -39,7 +39,7 @@ public:
void dump_to_pp (pretty_printer *pp, bool) const;
void dump (bool) const;
- json::value *to_json () const;
+ std::unique_ptr<json::value> to_json () const;
bool operator== (const symbolic_byte_offset &other) const
{
@@ -72,7 +72,7 @@ public:
region_model_manager &mgr) const;
void dump (bool, region_model_manager &mgr) const;
- json::value *to_json () const;
+ std::unique_ptr<json::value> to_json () const;
bool empty_p () const;
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index d7fd03831eb5..aa4e9982c891 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -232,10 +232,10 @@ region_to_value_map::dump (bool simple) const
This is intended for debugging the analyzer rather than
serialization. */
-json::object *
+std::unique_ptr<json::object>
region_to_value_map::to_json () const
{
- json::object *map_obj = new json::object ();
+ auto map_obj = ::make_unique<json::object> ();
auto_vec<const region *> regs;
for (iterator iter = begin (); iter != end (); ++iter)
@@ -512,10 +512,10 @@ region_model::debug () const
This is intended for debugging the analyzer rather than
serialization. */
-json::object *
+std::unique_ptr<json::object>
region_model::to_json () const
{
- json::object *model_obj = new json::object ();
+ auto model_obj = ::make_unique<json::object> ();
model_obj->set ("store", m_store.to_json ());
model_obj->set ("constraints", m_constraints->to_json ());
if (m_current_frame)
diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h
index 7ae4a798eff1..97468b9e7f2b 100644
--- a/gcc/analyzer/region-model.h
+++ b/gcc/analyzer/region-model.h
@@ -177,7 +177,7 @@ public:
void dump_to_pp (pretty_printer *pp, bool simple, bool multiline) const;
void dump (bool simple) const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
std::unique_ptr<text_art::tree_widget>
make_dump_widget (const text_art::dump_widget_info &dwi) const;
@@ -286,7 +286,7 @@ class region_model
void debug () const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
std::unique_ptr<text_art::tree_widget>
make_dump_widget (const text_art::dump_widget_info &dwi) const;
diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc
index 59b09e5c81ce..ac1ea646eb83 100644
--- a/gcc/analyzer/region.cc
+++ b/gcc/analyzer/region.cc
@@ -59,6 +59,7 @@ along with GCC; see the file COPYING3. If not see
#include "analyzer/sm.h"
#include "analyzer/program-state.h"
#include "text-art/dump.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
@@ -1035,11 +1036,11 @@ region::dump () const
/* Return a new json::string describing the region. */
-json::value *
+std::unique_ptr<json::value>
region::to_json () const
{
label_text desc = get_desc (true);
- json::value *reg_js = new json::string (desc.get ());
+ auto reg_js = ::make_unique<json::string> (desc.get ());
return reg_js;
}
diff --git a/gcc/analyzer/region.h b/gcc/analyzer/region.h
index ffc05e034f1f..00a8c7680d50 100644
--- a/gcc/analyzer/region.h
+++ b/gcc/analyzer/region.h
@@ -176,7 +176,7 @@ public:
void dump (bool simple) const;
void dump () const;
- json::value *to_json () const;
+ std::unique_ptr<json::value> to_json () const;
bool maybe_print_for_user (pretty_printer *pp,
diff --git a/gcc/analyzer/sm.cc b/gcc/analyzer/sm.cc
index f8b21b85db03..4c4b2eaf73ef 100644
--- a/gcc/analyzer/sm.cc
+++ b/gcc/analyzer/sm.cc
@@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see
#include "analyzer/svalue.h"
#include "analyzer/program-state.h"
#include "analyzer/pending-diagnostic.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
@@ -77,13 +78,13 @@ state_machine::state::dump_to_pp (pretty_printer *pp) const
/* Return a new json::string describing the state. */
-json::value *
+std::unique_ptr<json::value>
state_machine::state::to_json () const
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
dump_to_pp (&pp);
- return new json::string (pp_formatted_text (&pp));
+ return ::make_unique<json::string> (pp_formatted_text (&pp));
}
/* class state_machine. */
@@ -151,19 +152,19 @@ state_machine::dump_to_pp (pretty_printer *pp) const
{"name" : str,
"states" : [str]}. */
-json::object *
+std::unique_ptr<json::object>
state_machine::to_json () const
{
- json::object *sm_obj = new json::object ();
+ auto sm_obj = ::make_unique<json::object> ();
sm_obj->set_string ("name", m_name);
{
- json::array *states_arr = new json::array ();
+ auto states_arr = ::make_unique<json::array> ();
unsigned i;
state *s;
FOR_EACH_VEC_ELT (m_states, i, s)
states_arr->append (s->to_json ());
- sm_obj->set ("states", states_arr);
+ sm_obj->set ("states", std::move (states_arr));
}
return sm_obj;
diff --git a/gcc/analyzer/sm.h b/gcc/analyzer/sm.h
index aa0c4f67f51e..cdd6b4f381c4 100644
--- a/gcc/analyzer/sm.h
+++ b/gcc/analyzer/sm.h
@@ -49,7 +49,7 @@ public:
const char *get_name () const { return m_name; }
virtual void dump_to_pp (pretty_printer *pp) const;
- virtual json::value *to_json () const;
+ virtual std::unique_ptr<json::value> to_json () const;
unsigned get_id () const { return m_id; }
@@ -180,7 +180,7 @@ public:
void dump_to_pp (pretty_printer *pp) const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
state_t get_start_state () const { return m_start; }
diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc
index 6dc4bb5cad48..e95c86ff516a 100644
--- a/gcc/analyzer/store.cc
+++ b/gcc/analyzer/store.cc
@@ -56,6 +56,7 @@ along with GCC; see the file COPYING3. If not see
#include "analyzer/analyzer-selftests.h"
#include "stor-layout.h"
#include "text-art/tree-widget.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
@@ -231,10 +232,10 @@ bit_range::dump () const
This is intended for debugging the analyzer rather
than serialization. */
-json::object *
+std::unique_ptr<json::object>
bit_range::to_json () const
{
- json::object *obj = new json::object ();
+ auto obj = ::make_unique<json::object> ();
obj->set ("start_bit_offset",
bit_offset_to_json (m_start_bit_offset));
obj->set ("size_in_bits",
@@ -505,10 +506,10 @@ byte_range::dump () const
This is intended for debugging the analyzer rather
than serialization. */
-json::object *
+std::unique_ptr<json::object>
byte_range::to_json () const
{
- json::object *obj = new json::object ();
+ auto obj = ::make_unique<json::object> ();
obj->set ("start_byte_offset",
byte_offset_to_json (m_start_byte_offset));
obj->set ("size_in_bytes",
@@ -770,10 +771,10 @@ binding_map::dump (bool simple) const
{KEY_DESC : SVALUE_DESC,
...for the various key/value pairs in this binding_map}. */
-json::object *
+std::unique_ptr<json::object>
binding_map::to_json () const
{
- json::object *map_obj = new json::object ();
+ auto map_obj = ::make_unique<json::object> ();
auto_vec <const binding_key *> binding_keys;
for (map_t::iterator iter = m_map.begin ();
@@ -1419,10 +1420,10 @@ binding_cluster::validate () const
"touched": true/false,
"map" : object for the binding_map. */
-json::object *
+std::unique_ptr<json::object>
binding_cluster::to_json () const
{
- json::object *cluster_obj = new json::object ();
+ auto cluster_obj = ::make_unique<json::object> ();
cluster_obj->set_bool ("escaped", m_escaped);
cluster_obj->set_bool ("touched", m_touched);
@@ -2636,10 +2637,10 @@ store::validate () const
...for each parent region,
"called_unknown_fn": true/false}. */
-json::object *
+std::unique_ptr<json::object>
store::to_json () const
{
- json::object *store_obj = new json::object ();
+ auto store_obj = ::make_unique<json::object> ();
/* Sort into some deterministic order. */
auto_vec<const region *> base_regions;
@@ -2662,7 +2663,7 @@ store::to_json () const
{
gcc_assert (parent_reg);
- json::object *clusters_in_parent_reg_obj = new json::object ();
+ auto clusters_in_parent_reg_obj = ::make_unique<json::object> ();
const region *base_reg;
unsigned j;
@@ -2678,7 +2679,8 @@ store::to_json () const
cluster->to_json ());
}
label_text parent_reg_desc = parent_reg->get_desc ();
- store_obj->set (parent_reg_desc.get (), clusters_in_parent_reg_obj);
+ store_obj->set (parent_reg_desc.get (),
+ std::move (clusters_in_parent_reg_obj));
}
store_obj->set_bool ("called_unknown_fn", m_called_unknown_fn);
diff --git a/gcc/analyzer/store.h b/gcc/analyzer/store.h
index af9ea4172a2f..34f975a8dcc4 100644
--- a/gcc/analyzer/store.h
+++ b/gcc/analyzer/store.h
@@ -239,7 +239,7 @@ struct bit_range
void dump_to_pp (pretty_printer *pp) const;
void dump () const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
bool empty_p () const
{
@@ -315,7 +315,7 @@ struct byte_range
void dump_to_pp (pretty_printer *pp) const;
void dump () const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
bool empty_p () const
{
@@ -546,7 +546,7 @@ public:
void dump_to_pp (pretty_printer *pp, bool simple, bool multiline) const;
void dump (bool simple) const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
void add_to_tree_widget (text_art::tree_widget &parent_widget,
const text_art::dump_widget_info &dwi) const;
@@ -615,7 +615,7 @@ public:
void validate () const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
std::unique_ptr<text_art::tree_widget>
make_dump_widget (const text_art::dump_widget_info &dwi,
@@ -758,7 +758,7 @@ public:
void validate () const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
std::unique_ptr<text_art::tree_widget>
make_dump_widget (const text_art::dump_widget_info &dwi,
diff --git a/gcc/analyzer/supergraph.cc b/gcc/analyzer/supergraph.cc
index e53c10940d35..9d78b1b44c8d 100644
--- a/gcc/analyzer/supergraph.cc
+++ b/gcc/analyzer/supergraph.cc
@@ -54,6 +54,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-cfg.h"
#include "analyzer/supergraph.h"
#include "analyzer/analyzer-logging.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
@@ -462,29 +463,29 @@ supergraph::dump_dot (const char *path, const dump_args_t
&dump_args) const
{"nodes" : [objs for snodes],
"edges" : [objs for sedges]}. */
-json::object *
+std::unique_ptr<json::object>
supergraph::to_json () const
{
- json::object *sgraph_obj = new json::object ();
+ auto sgraph_obj = ::make_unique<json::object> ();
/* Nodes. */
{
- json::array *nodes_arr = new json::array ();
+ auto nodes_arr = ::make_unique<json::array> ();
unsigned i;
supernode *n;
FOR_EACH_VEC_ELT (m_nodes, i, n)
nodes_arr->append (n->to_json ());
- sgraph_obj->set ("nodes", nodes_arr);
+ sgraph_obj->set ("nodes", std::move (nodes_arr));
}
/* Edges. */
{
- json::array *edges_arr = new json::array ();
+ auto edges_arr = ::make_unique<json::array> ();
unsigned i;
superedge *n;
FOR_EACH_VEC_ELT (m_edges, i, n)
edges_arr->append (n->to_json ());
- sgraph_obj->set ("edges", edges_arr);
+ sgraph_obj->set ("edges", std::move (edges_arr));
}
return sgraph_obj;
@@ -717,10 +718,10 @@ supernode::dump_dot_id (pretty_printer *pp) const
"phis": [str],
"stmts" : [str]}. */
-json::object *
+std::unique_ptr<json::object>
supernode::to_json () const
{
- json::object *snode_obj = new json::object ();
+ auto snode_obj = ::make_unique<json::object> ();
snode_obj->set_integer ("idx", m_index);
snode_obj->set_integer ("bb_idx", m_bb->index);
@@ -980,10 +981,10 @@ superedge::dump_dot (graphviz_out *gv, const dump_args_t
&) const
"dst_idx": int, the index of the destination supernode,
"desc" : str. */
-json::object *
+std::unique_ptr<json::object>
superedge::to_json () const
{
- json::object *sedge_obj = new json::object ();
+ auto sedge_obj = ::make_unique<json::object> ();
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);
diff --git a/gcc/analyzer/supergraph.h b/gcc/analyzer/supergraph.h
index 86f918bc8b5d..a1bbb9d53904 100644
--- a/gcc/analyzer/supergraph.h
+++ b/gcc/analyzer/supergraph.h
@@ -168,7 +168,7 @@ public:
void dump_dot_to_file (FILE *fp, const dump_args_t &) const;
void dump_dot (const char *path, const dump_args_t &) const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
int num_nodes () const { return m_nodes.length (); }
int num_edges () const { return m_edges.length (); }
@@ -255,7 +255,7 @@ class supernode : public dnode<supergraph_traits>
void dump_dot (graphviz_out *gv, const dump_args_t &args) const override;
void dump_dot_id (pretty_printer *pp) const;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
location_t get_start_location () const;
location_t get_end_location () const;
@@ -323,7 +323,7 @@ class superedge : public dedge<supergraph_traits>
virtual void dump_label_to_pp (pretty_printer *pp,
bool user_facing) const = 0;
- json::object *to_json () const;
+ std::unique_ptr<json::object> to_json () const;
enum edge_kind get_kind () const { return m_kind; }
diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc
index 663119613fb5..3be861e3f04f 100644
--- a/gcc/analyzer/svalue.cc
+++ b/gcc/analyzer/svalue.cc
@@ -104,11 +104,11 @@ svalue::get_desc (bool simple) const
/* Return a new json::string describing the svalue. */
-json::value *
+std::unique_ptr<json::value>
svalue::to_json () const
{
label_text desc = get_desc (true);
- json::value *sval_js = new json::string (desc.get ());
+ auto sval_js = ::make_unique<json::string> (desc.get ());
return sval_js;
}
diff --git a/gcc/analyzer/svalue.h b/gcc/analyzer/svalue.h
index bc2374fe8892..94e1ee4d8c70 100644
--- a/gcc/analyzer/svalue.h
+++ b/gcc/analyzer/svalue.h
@@ -105,7 +105,7 @@ public:
void dump (bool simple) const;
label_text get_desc (bool simple=true) const;
- json::value *to_json () const;
+ std::unique_ptr<json::value> to_json () const;
std::unique_ptr<text_art::tree_widget>
make_dump_widget (const dump_widget_info &dwi,
--
2.26.3