json: reduce use of naked new in json-building code
No functional change intended.
gcc/ChangeLog:
* diagnostic-format-json.cc: Use type-specific "set_*" functions
of json::object to avoid naked new of json value subclasses.
* diagnostic-format-sarif.cc: Likewise.
* gcov.cc: Likewise.
* json.cc (object::set_string): New.
(object::set_integer): New.
(object::set_float): New.
(object::set_bool): New.
(selftest::test_writing_objects): Use object::set_string.
* json.h (object::set_string): New decl.
(object::set_integer): New decl.
(object::set_float): New decl.
(object::set_bool): New decl.
* optinfo-emit-json.cc: Use type-specific "set_*" functions of
json::object to avoid naked new of json value subclasses.
* timevar.cc: Likewise.
* tree-diagnostic-path.cc: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>