Type Alias flowistry::infoflow::FlowResults

source ·
pub type FlowResults<'a, 'tcx> = AnalysisResults<'tcx, FlowAnalysis<'a, 'tcx>>;
Expand description

The output of the information flow analysis.

Using the metavariables in the paper: for each LocationOrArg $\ell$ in a Body $f$, this type contains a FlowDomain $\Theta_\ell$ that maps from a Place $p$ to a LocationOrArgSet $\kappa$. The domain of $\Theta_\ell$ is all places that have been defined up to $\ell$. For each place, $\Theta_\ell(p)$ contains the set of locations (or arguments) that could influence the value of that place, i.e. the place’s dependencies.

For example, to get the dependencies of the first argument at the first instruction, that would be:

fn example<'tcx>(tcx: TyCtxt<'tcx>, results: &FlowResults<'_, 'tcx>) {
  let ℓ: Location         = Location::START;
  let Θ: &FlowDomain      = results.state_at(ℓ);
  let p: Place            = Place::make(Local::from_usize(1), &[], tcx);
  let κ: LocationOrArgSet = results.analysis.deps_for(Θ, p);
  for ℓ2 in κ.iter() {
    println!("at location {ℓ:?}, place {p:?} depends on location {ℓ2:?}");
  }
}

To access a FlowDomain for a given location, use the method AnalysisResults::state_at. See FlowDomain for more on how to access the location set for a given place.

Note: this analysis uses rustc’s dataflow analysis framework, i.e. rustc_mir_dataflow. You will see several types and traits from that crate here, such as Analysis and AnalysisDomain. However, for performance purposes, several constructs were reimplemented within Flowistry, such as AnalysisResults which replaces rustc_mir_dataflow::Results.