diff options
Diffstat (limited to 'gcc/analyzer/analyzer.cc')
-rw-r--r-- | gcc/analyzer/analyzer.cc | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/gcc/analyzer/analyzer.cc b/gcc/analyzer/analyzer.cc index 0f998e3..f77dcd76 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. */ |