|
GCC Middle and Back End API Reference
|
#include <json.h>


Public Types | |
| typedef hash_map< char *, value *, simple_hashmap_traits< nofree_string_hash, value * > > | map_t |
Public Member Functions | |
| ~object () | |
| enum kind | get_kind () const final override |
| void | print (pretty_printer *pp, bool formatted) const final override |
| std::unique_ptr< value > | clone () const final override |
| object * | dyn_cast_object () final override |
| bool | is_empty () const |
| void | set (const char *key, value *v) |
| template<typename JsonType> | |
| void | set (const char *key, std::unique_ptr< JsonType > v) |
| value * | get (const char *key) const |
| const map_t & | get_map () const |
| void | set_string (const char *key, const char *utf8_value) |
| void | set_integer (const char *key, long v) |
| void | set_float (const char *key, double v) |
| void | set_bool (const char *key, bool v) |
| void | set_string (const string_property &property, const char *utf8_value) |
| void | set_integer (const integer_property &property, long value) |
| void | set_bool (const bool_property &property, bool value) |
| void | set_array_of_string (const array_of_string_property &property, std::unique_ptr< json::array > value) |
| template<typename EnumType> | |
| bool | maybe_get_enum (const enum_property< EnumType > &property, EnumType &out) const |
| template<typename EnumType> | |
| void | set_enum (const enum_property< EnumType > &property, EnumType value) |
| size_t | get_num_keys () const |
| const char * | get_key (size_t i) const |
| std::unique_ptr< object > | clone_as_object () const |
| void | dump (FILE *, bool formatted) const |
| void DEBUG_FUNCTION | dump () const |
| virtual array * | dyn_cast_array () |
| virtual integer_number * | dyn_cast_integer_number () |
| virtual string * | dyn_cast_string () |
| const pointer::token & | get_pointer_token () const |
Static Public Member Functions | |
| static int | compare (const json::object &obj_a, const json::object &obj_b) |
| static int | compare (const json::value &val_a, const json::value &val_b) |
Data Fields | |
| pointer::token | m_pointer_token |
Private Attributes | |
| map_t | m_map |
| auto_vec< const char * > | m_keys |
Subclass of value for objects: a collection of key/value pairs preserving the ordering in which keys were inserted. Preserving the order eliminates non-determinism in the output, making it easier for the user to compare repeated invocations.
| typedef hash_map<char *, value *, simple_hashmap_traits<nofree_string_hash, value *> > json::object::map_t |
| object::~object | ( | ) |
|
finaloverridevirtual |
Implements json::value.
References clone_as_object().
| std::unique_ptr< object > object::clone_as_object | ( | ) | const |
References json::value::clone(), FOR_EACH_VEC_ELT, hash_map< KeyId, Value, Traits >::get(), i, m_keys, and m_map.
Referenced by clone().
|
static |
Subroutine of json::compare for comparing a pairs of objects.
References json::value::compare(), gcc_assert, get(), m_keys, and m_map.
Referenced by json::value::compare().
|
staticinherited |
A deterministic total ordering for comparing json values, so that we can e.g. put them in std::map. This is intended to follow the condition for equality described in the JSON Schema standard (§4.3, “Instance equality”), as referenced by SARIF v2.1.0 (§3.7.3 "Array properties with unique values"), but has the following limitations: - numbers are supposed to be checked for "the same mathematical value", but in this implementation int vs float numbers won't compare as equal, and float number comparison is bitwise - strings are supposed to be "the same codepoint-for-codepoint", but this implementation doesn't take into account canonicalization issues.
References json::object::compare(), compare(), gcc_unreachable, json::float_number::get(), json::integer_number::get(), get_kind(), json::string::get_string(), json::JSON_ARRAY, json::JSON_FALSE, json::JSON_FLOAT, json::JSON_INTEGER, json::JSON_NULL, json::JSON_OBJECT, json::JSON_STRING, json::JSON_TRUE, and json::array::size().
Referenced by json::object::compare(), compare(), and diagnostics::sarif_array_of_unique< JsonElementType >::comparator_t::operator()().
|
inherited |
A convenience function for debugging. Dump to stderr with formatting, and a trailing newline.
References dump().
|
inherited |
class json::value.
Dump this json::value tree to OUTF. The key/value pairs of json::objects are printed in the order in which the keys were originally inserted.
References output_buffer::m_stream, pp_buffer(), pp_flush(), and print().
Referenced by dump(), generate_results(), and diagnostics::sarif_serialization_format_json::write_to_file().
|
inlinevirtualinherited |
Reimplemented in json::array.
|
inlinevirtualinherited |
Reimplemented in json::integer_number.
|
inlinefinaloverridevirtual |
Reimplemented from json::value.
References dyn_cast_object(), and final().
Referenced by dyn_cast_object().
|
inlinevirtualinherited |
Reimplemented in json::string.
| value * object::get | ( | const char * | key | ) | const |
Get the json::value * for KEY. The object retains ownership of the value.
References gcc_assert, get(), m_map, and NULL.
Referenced by compare(), diagnostics::copy_any_property_bag(), get(), diagnostics::sarif_location::get_id(), diagnostics::sarif_code_flow::get_or_append_thread_flow(), diagnostics::sarif_object::get_or_create_properties(), diagnostics::sarif_location_relationship::get_target_id(), diagnostics::sarif_location_relationship::lazily_add_kind(), diagnostics::sarif_location::lazily_add_relationship_object(), diagnostics::sarif_location::lazily_add_relationships_array(), diagnostics::sarif_builder::make_location_object(), diagnostics::sarif_builder::make_location_object(), diagnostics::sarif_builder::make_location_object(), maybe_get_enum(), and diagnostics::sarif_location_manager::process_worklist_item().
|
inline |
Referenced by diagnostics::copy_any_property_bag().
|
inlinefinaloverridevirtual |
Implements json::value.
References final(), and json::JSON_OBJECT.
|
inline |
References m_keys.
Referenced by diagnostics::copy_any_property_bag().
|
inlineinherited |
References m_pointer_token.
|
inline |
References get(), if(), json::property< Traits >::m_key, and maybe_get_enum().
Referenced by maybe_get_enum().
|
finaloverridevirtual |
Implementation of json::value::print for json::object.
Implements json::value.
References FOR_EACH_VEC_ELT, hash_map< KeyId, Value, Traits >::get(), i, m_keys, m_map, pp_character(), pp_indent(), pp_indentation(), pp_newline(), pp_space, pp_string(), json::value::print(), and print_escaped_json_string().
Referenced by generate_results(), and diagnostics::sarif_socket_sink::send_rpc_notification().
|
inline |
References set().
| void object::set | ( | const char * | key, |
| value * | v ) |
Set the json::value * for KEY, taking ownership of V (and taking a copy of KEY if necessary).
References gcc_assert, m_keys, m_map, and json::value::m_pointer_token.
Referenced by optrecord_json_writer::add_pass_list(), optrecord_json_writer::add_record(), diagnostics::sarif_location_manager::add_related_location(), diagnostics::copy_any_property_bag(), generate_results(), diagnostics::sarif_builder::get_or_create_artifact(), diagnostics::sarif_object::get_or_create_properties(), optrecord_json_writer::inlining_chain_to_json(), json_set_prime_path_coverage(), diagnostics::sarif_location_relationship::lazily_add_kind(), diagnostics::sarif_location::lazily_add_relationships_array(), diagnostics::sarif_builder::make_fix_object(), diagnostics::sarif_builder::make_replacement_object(), diagnostics::sarif_builder::make_result_object(), diagnostics::sarif_builder::make_run_object(), diagnostics::sarif_builder::make_tool_object(), diagnostics::sarif_builder::make_top_level_object(), diagnostics::sarif_builder::maybe_make_cwe_taxonomy_object(), diagnostics::sarif_builder::maybe_make_physical_location_object(), optrecord_json_writer::optinfo_to_json(), optrecord_json_writer::optrecord_json_writer(), output_intermediate_json_line(), output_json_intermediate_file(), optrecord_json_writer::pass_to_json(), diagnostics::sarif_artifact::populate_contents(), diagnostics::sarif_artifact::populate_roles(), diagnostics::sarif_builder::populate_thread_flow_location_object(), diagnostics::sarif_invocation::prepare_to_flush(), diagnostics::sarif_code_flow::sarif_code_flow(), diagnostics::sarif_ice_notification::sarif_ice_notification(), diagnostics::sarif_invocation::sarif_invocation(), diagnostics::sarif_thread_flow::sarif_thread_flow(), set(), diagnostics::sarif_builder::set_any_logical_locs_arr(), set_array_of_string(), set_bool(), set_float(), diagnostics::sarif_property_bag::set_graph(), set_integer(), diagnostics::sarif_property_bag::set_logical_location(), and set_string().
| void object::set_array_of_string | ( | const array_of_string_property & | property, |
| std::unique_ptr< json::array > | value ) |
References json::property< Traits >::m_key, and set().
| void object::set_bool | ( | const bool_property & | property, |
| bool | value ) |
References json::property< Traits >::m_key, and set_bool().
| void object::set_bool | ( | const char * | key, |
| bool | v ) |
Set value of KEY within this object to the JSON literal true or false, based on V.
References set().
Referenced by diagnostics::sarif_builder::make_location_object(), output_intermediate_json_line(), diagnostics::sarif_invocation::prepare_to_flush(), and set_bool().
|
inline |
| void object::set_float | ( | const char * | key, |
| double | v ) |
Set value of KEY within this object to a JSON floating point value based on V.
References set().
| void object::set_integer | ( | const char * | key, |
| long | v ) |
Set value of KEY within this object to a JSON integer value based on V.
References set().
Referenced by optrecord_json_writer::impl_location_to_json(), json_set_prime_path_coverage(), diagnostics::sarif_location::lazily_add_id(), optrecord_json_writer::location_to_json(), diagnostics::sarif_result::on_nested_diagnostic(), output_intermediate_json_line(), optrecord_json_writer::pass_to_json(), diagnostics::sarif_builder::populate_thread_flow_location_object(), optrecord_json_writer::profile_count_to_json(), diagnostics::sarif_location_relationship::sarif_location_relationship(), and set_integer().
| void object::set_integer | ( | const integer_property & | property, |
| long | value ) |
References json::property< Traits >::m_key, and set_integer().
| void object::set_string | ( | const char * | key, |
| const char * | utf8_value ) |
Set value of KEY within this object to a JSON string value based on UTF8_VALUE.
References set().
Referenced by generate_results(), diagnostics::sarif_builder::get_or_create_artifact(), optrecord_json_writer::impl_location_to_json(), optrecord_json_writer::inlining_chain_to_json(), json_set_prime_path_coverage(), optrecord_json_writer::location_to_json(), optrecord_json_writer::optinfo_to_json(), optrecord_json_writer::optrecord_json_writer(), output_intermediate_json_line(), output_json_intermediate_file(), optrecord_json_writer::pass_to_json(), optrecord_json_writer::profile_count_to_json(), diagnostics::sarif_ice_notification::sarif_ice_notification(), diagnostics::sarif_thread_flow::sarif_thread_flow(), set_enum(), set_string(), and diagnostics::set_string_property_escaping_braces().
| void object::set_string | ( | const string_property & | property, |
| const char * | utf8_value ) |
References json::property< Traits >::m_key, and set_string().
|
private |
Referenced by clone_as_object(), compare(), get_key(), get_num_keys(), print(), and set().
|
private |
Referenced by clone_as_object(), compare(), get(), get_map(), is_empty(), print(), set(), and ~object().
|
inherited |
Referenced by json::array::append(), get_pointer_token(), and json::object::set().