Add inherent visit_with method to dataflow::Results

This is more ergonomic than importing `dataflow::visit_results`
This commit is contained in:
Dylan MacKenzie 2020-02-18 09:51:21 -08:00
parent 5fa2c9e799
commit 6d7ce880aa

View File

@ -75,6 +75,24 @@ pub fn into_results_cursor(self, body: &'mir mir::Body<'tcx>) -> ResultsCursor<'
pub fn entry_set_for_block(&self, block: BasicBlock) -> &BitSet<A::Idx> {
&self.entry_sets[block]
}
pub fn visit_with(
&self,
body: &'mir mir::Body<'tcx>,
blocks: impl IntoIterator<Item = BasicBlock>,
vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = BitSet<A::Idx>>,
) {
visit_results(body, blocks, self, vis)
}
pub fn visit_in_rpo_with(
&self,
body: &'mir mir::Body<'tcx>,
vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = BitSet<A::Idx>>,
) {
let blocks = mir::traversal::reverse_postorder(body);
visit_results(body, blocks.map(|(bb, _)| bb), self, vis)
}
}
/// Define the domain of a dataflow problem.