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

Public Member Functions

long lazily_add_id (sarif_location_manager &loc_mgr)
 
long get_id () const
 
void lazily_add_relationship (sarif_location &target, enum location_relationship_kind kind, sarif_location_manager &loc_mgr)
 
sarif_property_bagget_or_create_properties ()
 
enum kind get_kind () const final override
 
void print (pretty_printer *pp, bool formatted) const 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)
 
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
 
void DEBUG_FUNCTION dump () const
 

Private Types

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

Private Member Functions

sarif_location_relationshiplazily_add_relationship_object (sarif_location &target, sarif_location_manager &loc_mgr)
 
json::arraylazily_add_relationships_array ()
 

Private Attributes

std::map< sarif_location *, sarif_location_relationship * > m_relationships_map
 
map_t m_map
 
auto_vec< const char * > m_keys
 

Detailed Description

Subclass of sarif_object for SARIF "location" objects
(SARIF v2.1.0 section 3.28).
A location object can have an "id" which must be unique within
the enclosing result, if any (see SARIF v2.1.0 section 3.28.2).   

Member Typedef Documentation

◆ map_t

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

Member Function Documentation

◆ dump() [1/2]

void value::dump ( ) const
inherited
A convenience function for debugging.
Dump to stderr with formatting, and a trailing newline.  

References json::value::dump().

Referenced by json::value::dump().

◆ dump() [2/2]

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 output_buffer::m_stream, pp_buffer(), pp_flush(), and json::value::print().

Referenced by generate_results().

◆ get()

◆ get_id()

long sarif_location::get_id ( ) const
Get the id of this location, or -1 if it doesn't have one.   

References gcc_assert, json::object::get(), and json::JSON_INTEGER.

Referenced by lazily_add_id(), and lazily_add_relationship_object().

◆ 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

◆ is_empty()

bool json::object::is_empty ( ) const
inlineinherited

◆ lazily_add_id()

long sarif_location::lazily_add_id ( sarif_location_manager & loc_mgr)
class sarif_location : public sarif_object.   
Ensure this location has an "id" and return it.
Use LOC_MGR if an id needs to be allocated.

See the "id" property (3.28.2).

We use this to only assign ids to locations that are
referenced by another sarif object; others have no "id".    

References sarif_location_manager::allocate_location_id(), gcc_assert, get_id(), and json::object::set_integer().

Referenced by sarif_location_relationship::sarif_location_relationship().

◆ lazily_add_relationship()

void sarif_location::lazily_add_relationship ( sarif_location & target,
enum location_relationship_kind kind,
sarif_location_manager & loc_mgr )
Lazily populate this location's "relationships" property (3.28.7)
with the relationship of KIND to TARGET, creating objects
as necessary.
Use LOC_MGR for any locations that need "id" values.   

References sarif_location_relationship::lazily_add_kind(), and lazily_add_relationship_object().

Referenced by sarif_location_manager::process_worklist_item().

◆ lazily_add_relationship_object()

sarif_location_relationship & sarif_location::lazily_add_relationship_object ( sarif_location & target,
sarif_location_manager & loc_mgr )
private
Lazily populate this location's "relationships" property (3.28.7)
with a location_relationship to TARGET, creating objects
as necessary.
Use LOC_MGR for any locations that need "id" values.   

References json::array::append(), gcc_assert, json::object::get(), get_id(), sarif_location_relationship::get_target_id(), lazily_add_relationships_array(), m_relationships_map, and make_unique().

Referenced by lazily_add_relationship().

◆ lazily_add_relationships_array()

json::array & sarif_location::lazily_add_relationships_array ( )
private
Ensure this location has a "relationships" array (3.28.7).   

References gcc_assert, json::object::get(), json::JSON_ARRAY, and json::object::set().

Referenced by lazily_add_relationship_object().

◆ print()

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

◆ set() [1/2]

template<typename JsonType >
void json::object::set ( const char * key,
std::unique_ptr< JsonType > v )
inlineinherited

References json::object::set().

◆ set() [2/2]

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_location_manager::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(), sarif_location_relationship::lazily_add_kind(), lazily_add_relationships_array(), sarif_builder::make_fix_object(), sarif_builder::make_replacement_object(), sarif_builder::make_result_object(), sarif_builder::make_run_object(), sarif_builder::make_tool_object(), sarif_builder::make_top_level_object(), infinite_loop_diagnostic::maybe_add_sarif_properties(), sarif_builder::maybe_make_cwe_taxonomy_object(), sarif_builder::maybe_make_physical_location_object(), json_output_format::on_report_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(), sarif_artifact::populate_contents(), sarif_artifact::populate_roles(), sarif_builder::populate_thread_flow_location_object(), sarif_invocation::prepare_to_flush(), sarif_code_flow::sarif_code_flow(), sarif_ice_notification::sarif_ice_notification(), sarif_invocation::sarif_invocation(), sarif_thread_flow::sarif_thread_flow(), json::object::set(), sarif_builder::set_any_logical_locs_arr(), json::object::set_bool(), json::object::set_float(), json::object::set_integer(), and json::object::set_string().

◆ 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 sarif_builder::make_location_object(), json_output_format::on_report_diagnostic(), 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().

◆ set_integer()

◆ set_string()

Field Documentation

◆ m_keys

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

◆ m_map

◆ m_relationships_map

std::map<sarif_location *, sarif_location_relationship *> sarif_location::m_relationships_map
private

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