const logical_locations::manager *
get_logical_location_manager () const
{
- return m_logical_loc_mgr;
+ if (auto client_data_hooks = m_context.get_client_data_hooks ())
+ return client_data_hooks->get_logical_location_manager ();
+ return nullptr;
}
void
const line_maps *m_line_maps;
sarif_token_printer m_token_printer;
- const logical_locations::manager *m_logical_loc_mgr;
-
/* The JSON object for the invocation object. */
std::unique_ptr<sarif_invocation> m_invocation_obj;
m_printer (&printer),
m_line_maps (line_maps),
m_token_printer (*this),
- m_logical_loc_mgr (nullptr),
m_invocation_obj
(std::make_unique<sarif_invocation> (*this,
dc.get_original_argv ())),
{
gcc_assert (m_line_maps);
gcc_assert (m_serialization_format);
-
- if (auto client_data_hooks = dc.get_client_data_hooks ())
- m_logical_loc_mgr = client_data_hooks->get_logical_location_manager ();
}
sarif_builder::~sarif_builder ()
{
if (!logical_loc)
return;
- gcc_assert (m_logical_loc_mgr);
+ auto logical_loc_mgr = get_logical_location_manager ();
+ gcc_assert (logical_loc_mgr);
auto location_locs_arr = std::make_unique<json::array> ();
auto logical_loc_obj = make_minimal_sarif_logical_location (logical_loc);
sarif_builder::
ensure_sarif_logical_location_for (logical_locations::key k)
{
- gcc_assert (m_logical_loc_mgr);
+ auto logical_loc_mgr = get_logical_location_manager ();
+ gcc_assert (logical_loc_mgr);
auto sarif_logical_loc = std::make_unique<sarif_logical_location> ();
- if (const char *short_name = m_logical_loc_mgr->get_short_name (k))
+ if (const char *short_name = logical_loc_mgr->get_short_name (k))
sarif_logical_loc->set_string ("name", short_name);
/* "fullyQualifiedName" property (SARIF v2.1.0 section 3.33.5). */
- if (const char *name_with_scope = m_logical_loc_mgr->get_name_with_scope (k))
+ if (const char *name_with_scope = logical_loc_mgr->get_name_with_scope (k))
sarif_logical_loc->set_string ("fullyQualifiedName", name_with_scope);
/* "decoratedName" property (SARIF v2.1.0 section 3.33.6). */
- if (const char *internal_name = m_logical_loc_mgr->get_internal_name (k))
+ if (const char *internal_name = logical_loc_mgr->get_internal_name (k))
sarif_logical_loc->set_string ("decoratedName", internal_name);
/* "kind" property (SARIF v2.1.0 section 3.33.7). */
- enum logical_locations::kind kind = m_logical_loc_mgr->get_kind (k);
+ enum logical_locations::kind kind = logical_loc_mgr->get_kind (k);
if (const char *sarif_kind_str = maybe_get_sarif_kind (kind))
sarif_logical_loc->set_string ("kind", sarif_kind_str);
/* "parentIndex" property (SARIF v2.1.0 section 3.33.8). */
- if (auto parent_key = m_logical_loc_mgr->get_parent (k))
+ if (auto parent_key = logical_loc_mgr->get_parent (k))
{
/* Recurse upwards. */
int parent_index = ensure_sarif_logical_location_for (parent_key);
sarif_builder::
make_minimal_sarif_logical_location (logical_locations::key logical_loc)
{
- gcc_assert (m_logical_loc_mgr);
+ auto logical_loc_mgr = get_logical_location_manager ();
+ gcc_assert (logical_loc_mgr);
/* Ensure that m_cached_logical_locs has a "logicalLocation" object
(SARIF v2.1.0 section 3.33) for LOGICAL_LOC, and return its index within
/* "fullyQualifiedName" property (SARIF v2.1.0 section 3.33.5). */
if (const char *name_with_scope
- = m_logical_loc_mgr->get_name_with_scope (logical_loc))
+ = logical_loc_mgr->get_name_with_scope (logical_loc))
sarif_logical_loc->set_string ("fullyQualifiedName", name_with_scope);
return sarif_logical_loc;