GCC Middle and Back End API Reference
sarif_artifact Class Reference
Inheritance diagram for sarif_artifact:
Collaboration diagram for sarif_artifact:

Public Member Functions

 sarif_artifact (const char *filename)
 
void add_role (enum diagnostic_artifact_role role, bool embed_contents)
 
bool embed_contents_p () const
 
void populate_contents (sarif_builder &builder)
 
void populate_roles ()
 
sarif_property_bagget_or_create_properties ()
 
enum kind get_kind () const final override
 
void print (pretty_printer *pp, bool formatted) const final override
 
void set (const char *key, value *v)
 
valueget (const char *key) 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 dump (FILE *, bool formatted) const
 

Private Types

typedef hash_map< char *, value *, simple_hashmap_traits< nofree_string_hash, value * > > map_t
 

Private Attributes

const char * m_filename
 
auto_sbitmap m_roles
 
bool m_embed_contents
 
map_t m_map
 
auto_vec< const char * > m_keys
 

Detailed Description

Subclass of sarif_object for SARIF artifact objects
(SARIF v2.1.0 section 3.24).   

Member Typedef Documentation

◆ map_t

typedef hash_map<char *, value *, simple_hashmap_traits<nofree_string_hash, value *> > json::object::map_t
privateinherited

Constructor & Destructor Documentation

◆ sarif_artifact()

sarif_artifact::sarif_artifact ( const char * filename)
inline

References bitmap_clear(), and m_roles.

Member Function Documentation

◆ add_role()

void sarif_artifact::add_role ( enum diagnostic_artifact_role role,
bool embed_contents )
class sarif_artifact : public sarif_object.   
Add ROLE to this artifact's roles.
If EMBED_CONTENTS is true, then flag that we will attempt to embed the
contents of this artifact when writing it out.   

References analysis_target, bitmap_bit_p, bitmap_set_bit, m_embed_contents, m_roles, and result_file.

Referenced by sarif_builder::get_or_create_artifact().

◆ dump()

void value::dump ( FILE * outf,
bool formatted ) const
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 pp_buffer(), pp_flush(), json::value::print(), and output_buffer::stream.

Referenced by json_output_format::flush_to_file(), sarif_builder::flush_to_file(), and generate_results().

◆ embed_contents_p()

bool sarif_artifact::embed_contents_p ( ) const
inline

◆ get()

value * object::get ( const char * key) const
inherited
Get the json::value * for KEY.

The object retains ownership of the value.   

References gcc_assert, json::object::get(), json::object::m_map, and NULL.

Referenced by json::object::get(), and sarif_object::get_or_create_properties().

◆ get_kind()

enum kind json::object::get_kind ( ) const
inlinefinaloverridevirtualinherited

Implements json::value.

References json::JSON_OBJECT.

◆ get_or_create_properties()

sarif_property_bag & sarif_object::get_or_create_properties ( )
inherited
class sarif_object : public json::object.   

References json::object::get(), json::value::get_kind(), json::JSON_OBJECT, and json::object::set().

◆ populate_contents()

void sarif_artifact::populate_contents ( sarif_builder & builder)
Populate the "contents" property (SARIF v2.1.0 section 3.24.8).
We do this after initialization to
(a) ensure that any charset options have been set
(b) only populate it for artifacts that are referenced by a location.   

References m_filename, sarif_builder::maybe_make_artifact_content_object(), and json::object::set().

Referenced by sarif_builder::make_run_object().

◆ populate_roles()

void sarif_artifact::populate_roles ( )
Populate the "roles" property of this json::object with a new
json::array for the artifact.roles property (SARIF v2.1.0 section 3.24.6)
containing strings such as "analysisTarget", "resultFile"
and/or "tracedFile".   

References json::array::append(), bitmap_bit_p, bitmap_empty_p(), get_artifact_role_string(), i, m_roles, NUM_ROLES, and json::object::set().

Referenced by sarif_builder::make_run_object().

◆ print()

void object::print ( pretty_printer * pp,
bool formatted ) const
finaloverridevirtualinherited

◆ set()

void object::set ( const char * key,
value * v )
inherited
Set the json::value * for KEY, taking ownership of V
(and taking a copy of KEY if necessary).   

References gcc_assert, hash_map< KeyId, Value, Traits >::get(), json::object::m_keys, json::object::m_map, and hash_map< KeyId, Value, Traits >::put().

Referenced by optrecord_json_writer::add_pass_list(), optrecord_json_writer::add_record(), sarif_result::add_related_location(), compiler_data_hooks::add_sarif_invocation_properties(), generate_results(), sarif_builder::get_or_create_artifact(), sarif_object::get_or_create_properties(), optrecord_json_writer::inlining_chain_to_json(), json_from_fixit_hint(), json_from_location_range(), sarif_builder::make_artifact_change_object(), sarif_builder::make_code_flow_object(), sarif_builder::make_driver_tool_component_object(), sarif_builder::make_fix_object(), timer::make_json(), timer::timevar_def::make_json(), make_json_for_path(), sarif_builder::make_location_object(), sarif_builder::make_location_object(), sarif_builder::make_replacement_object(), sarif_builder::make_reporting_descriptor_reference_object_for_cwe_id(), sarif_builder::make_result_object(), sarif_builder::make_run_object(), sarif_builder::make_thread_flow_location_object(), sarif_builder::make_tool_object(), sarif_builder::make_top_level_object(), infinite_loop_diagnostic::maybe_add_sarif_properties(), sarif_builder::maybe_make_artifact_content_object(), sarif_builder::maybe_make_cwe_taxonomy_object(), sarif_builder::maybe_make_physical_location_object(), sarif_builder::maybe_make_region_object_for_context(), sarif_result::on_diagram(), json_output_format::on_end_diagnostic(), sarif_result::on_nested_diagnostic(), 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(), populate_contents(), populate_roles(), sarif_invocation::prepare_to_flush(), sarif_ice_notification::sarif_ice_notification(), sarif_thread_flow::sarif_thread_flow(), sarif_builder::set_any_logical_locs_arr(), json::object::set_bool(), json::object::set_float(), json::object::set_integer(), json::object::set_string(), and infinite_loop::to_json().

◆ set_bool()

void object::set_bool ( const char * key,
bool v )
inherited
Set value of KEY within this object to the JSON
literal true or false, based on V.   

References json::object::set().

Referenced by timer::make_json(), output_intermediate_json_line(), and sarif_invocation::prepare_to_flush().

◆ set_float()

void object::set_float ( const char * key,
double v )
inherited
Set value of KEY within this object to a JSON
floating point value based on V.   

References json::object::set().

Referenced by make_json_for_timevar_time_def().

◆ set_integer()

◆ set_string()

void object::set_string ( const char * key,
const char * utf8_value )
inherited
Set value of KEY within this object to a JSON
string value based on UTF8_VALUE.   

References json::object::set().

Referenced by generate_results(), sarif_builder::get_or_create_artifact(), optrecord_json_writer::impl_location_to_json(), optrecord_json_writer::inlining_chain_to_json(), json_from_expanded_location(), json_from_fixit_hint(), json_from_location_range(), optrecord_json_writer::location_to_json(), sarif_builder::make_artifact_content_object(), sarif_builder::make_artifact_location_object(), sarif_builder::make_artifact_location_object_for_pwd(), sarif_builder::make_driver_tool_component_object(), timer::make_json(), timer::timevar_def::make_json(), make_json_for_path(), sarif_builder::make_message_object(), sarif_builder::make_message_object_for_diagram(), sarif_builder::make_multiformat_message_string(), sarif_builder::make_reporting_descriptor_object_for_cwe_id(), sarif_builder::make_reporting_descriptor_object_for_warning(), sarif_builder::make_reporting_descriptor_reference_object_for_cwe_id(), sarif_builder::make_result_object(), make_sarif_logical_location_object(), sarif_builder::make_tool_component_reference_object_for_cwe(), sarif_builder::make_tool_object(), sarif_builder::make_top_level_object(), sarif_builder::maybe_make_artifact_content_object(), sarif_builder::maybe_make_cwe_taxonomy_object(), json_output_format::on_end_diagnostic(), 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(), sarif_ice_notification::sarif_ice_notification(), and sarif_thread_flow::sarif_thread_flow().

Field Documentation

◆ m_embed_contents

bool sarif_artifact::m_embed_contents
private

Referenced by add_role(), and embed_contents_p().

◆ m_filename

const char* sarif_artifact::m_filename
private

Referenced by populate_contents().

◆ m_keys

auto_vec<const char *> json::object::m_keys
privateinherited

◆ m_map

map_t json::object::m_map
privateinherited

◆ m_roles

auto_sbitmap sarif_artifact::m_roles
private

The documentation for this class was generated from the following file: