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

Public Member Functions

 sarif_result (unsigned idx_within_parent)
 
unsigned get_index_within_parent () const
 
void on_nested_diagnostic (const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind, sarif_builder &builder)
 
void on_diagram (const diagnostic_diagram &diagram, sarif_builder &builder)
 
unsigned allocate_location_id ()
 
virtual void add_related_location (std::unique_ptr< sarif_location > location_obj, sarif_builder &builder)
 
void add_relationship_to_worklist (sarif_location &location_obj, enum worklist_item::kind kind, location_t where)
 
void process_worklist (sarif_builder &builder)
 
void process_worklist_item (sarif_builder &builder, const worklist_item &item)
 
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 Attributes

const unsigned m_idx_within_parent
 
json::arraym_related_locations_arr
 
unsigned m_next_location_id
 
std::list< worklist_itemm_worklist
 
std::map< location_t, sarif_location * > m_included_from_locations
 
std::map< location_t, sarif_location * > m_unlabelled_secondary_locations
 
map_t m_map
 
auto_vec< const char * > m_keys
 

Detailed Description

Subclass of sarif_object for SARIF "result" objects
(SARIF v2.1.0 section 3.27).
Each SARIF result object has its own "namespace" of numeric IDs for
managing location objects (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

Constructor & Destructor Documentation

◆ sarif_result()

sarif_result::sarif_result ( unsigned idx_within_parent)
inline

Member Function Documentation

◆ add_related_location()

void sarif_location_manager::add_related_location ( std::unique_ptr< sarif_location > location_obj,
sarif_builder & builder )
virtualinherited
class sarif_location_manager : public sarif_object.   
Base implementation of sarif_location_manager::add_related_location vfunc.

Add LOCATION_OBJ to this object's "relatedLocations" array,
creating it if it doesn't yet exist.   

Reimplemented in sarif_ice_notification.

References json::array::append(), sarif_location_manager::m_related_locations_arr, and json::object::set().

Referenced by sarif_ice_notification::add_related_location(), on_diagram(), on_nested_diagnostic(), and sarif_location_manager::process_worklist_item().

◆ add_relationship_to_worklist()

void sarif_location_manager::add_relationship_to_worklist ( sarif_location & location_obj,
enum worklist_item::kind kind,
location_t where )
inherited

◆ allocate_location_id()

unsigned sarif_location_manager::allocate_location_id ( )
inlineinherited

◆ 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_index_within_parent()

unsigned sarif_result::get_index_within_parent ( ) const
inline

References m_idx_within_parent.

Referenced by make_sarif_url_for_event().

◆ 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

◆ on_diagram()

void sarif_result::on_diagram ( const diagnostic_diagram & diagram,
sarif_builder & builder )
Handle diagrams that occur within a diagnostic group.
The closest thing in SARIF seems to be to add a location to the
"releatedLocations" property  (SARIF v2.1.0 section 3.27.22),
and to put the diagram into the "message" property of that location
(SARIF v2.1.0 section 3.28.5).   

References sarif_location_manager::add_related_location(), sarif_builder::make_message_object_for_diagram(), and make_unique().

◆ on_nested_diagnostic()

void sarif_result::on_nested_diagnostic ( const diagnostic_info & diagnostic,
diagnostic_t orig_diag_kind,
sarif_builder & builder )
class sarif_result : public sarif_location_manager.   
Handle secondary diagnostics that occur within a diagnostic group.
The closest SARIF seems to have to nested diagnostics is the
"relatedLocations" property of result objects (SARIF v2.1.0 section 3.27.22),
so we lazily set this property and populate the array if and when
secondary diagnostics occur (such as notes to a warning).   

References sarif_location_manager::add_related_location(), sarif_builder::get_context(), diagnostic_context::get_diagnostic_nesting_level(), sarif_builder::get_printer(), sarif_builder::make_location_object(), sarif_builder::make_message_object(), pp_clear_output_area(), pp_formatted_text(), result_file, and json::object::set_integer().

◆ print()

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

◆ process_worklist()

void sarif_location_manager::process_worklist ( sarif_builder & builder)
inherited
Process all items in this result's worklist.
Doing so may temporarily add new items to the end
of the worklist.
Handling any item should be "lazy", and thus we should
eventually drain the queue and terminate.   

References sarif_location_manager::m_worklist, and sarif_location_manager::process_worklist_item().

◆ process_worklist_item()

◆ 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(), sarif_location::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_idx_within_parent

const unsigned sarif_result::m_idx_within_parent
private

Referenced by get_index_within_parent().

◆ m_included_from_locations

std::map<location_t, sarif_location *> sarif_location_manager::m_included_from_locations
privateinherited

◆ m_keys

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

◆ m_map

◆ m_next_location_id

unsigned sarif_location_manager::m_next_location_id
privateinherited

◆ m_related_locations_arr

json::array* sarif_location_manager::m_related_locations_arr
privateinherited

◆ m_unlabelled_secondary_locations

std::map<location_t, sarif_location *> sarif_location_manager::m_unlabelled_secondary_locations
privateinherited

◆ m_worklist

std::list<worklist_item> sarif_location_manager::m_worklist
privateinherited

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