in sapp/trimmed_trace_graph.py [0:0]
def _recompute_instance_properties(self, graph: TraceGraph) -> None:
"""Some properties of issue instances will be affected after trimming
such as min trace length to leaves. This should be called after the
trimming to re-compute these values.
"""
callables_histo = Counter(
inst.callable_id.local_id for inst in self._issue_instances.values()
)
# frame_id -> interval -> leaf_id -> min_trace
# where min_trace is negative k, if we didn't reach the leaf in k hops
visited: Visited = {}
# We may find issues that have no valid traces, then it should be removed.
to_remove = []
for inst in self._issue_instances.values():
# log.info(
# "recomputing props for %d",
# inst.id.local_id,
# )
inst.min_trace_length_to_sources = self._get_min_depth_to_sources(
visited,
inst.id.local_id,
inst.min_trace_length_to_sources,
)
inst.min_trace_length_to_sinks = self._get_min_depth_to_sinks(
visited,
inst.id.local_id,
inst.min_trace_length_to_sinks,
)
if (
inst.min_trace_length_to_sources == infinite_trace_length
and inst.min_trace_length_to_sinks is not None
) or (
inst.min_trace_length_to_sinks == infinite_trace_length
and inst.min_trace_length_to_sources is not None
):
# Unreachable instance
to_remove.append(inst)
continue
inst.callable_count = callables_histo[inst.callable_id.local_id]
for inst in to_remove:
self._remove_instance(inst)