Pass Analysis to visit_* instead of Results.
Every `Results` contains an `Analysis`, but these methods only need the `Analysis`. No point passing them more data than they need.
This commit is contained in:
@@ -222,17 +222,18 @@ impl Direction for Backward {
|
||||
|
||||
let loc = Location { block, statement_index: block_data.statements.len() };
|
||||
let term = block_data.terminator();
|
||||
results.analysis.apply_early_terminator_effect(state, term, loc);
|
||||
vis.visit_after_early_terminator_effect(results, state, term, loc);
|
||||
results.analysis.apply_primary_terminator_effect(state, term, loc);
|
||||
vis.visit_after_primary_terminator_effect(results, state, term, loc);
|
||||
let analysis = &mut results.analysis;
|
||||
analysis.apply_early_terminator_effect(state, term, loc);
|
||||
vis.visit_after_early_terminator_effect(analysis, state, term, loc);
|
||||
analysis.apply_primary_terminator_effect(state, term, loc);
|
||||
vis.visit_after_primary_terminator_effect(analysis, state, term, loc);
|
||||
|
||||
for (statement_index, stmt) in block_data.statements.iter().enumerate().rev() {
|
||||
let loc = Location { block, statement_index };
|
||||
results.analysis.apply_early_statement_effect(state, stmt, loc);
|
||||
vis.visit_after_early_statement_effect(results, state, stmt, loc);
|
||||
results.analysis.apply_primary_statement_effect(state, stmt, loc);
|
||||
vis.visit_after_primary_statement_effect(results, state, stmt, loc);
|
||||
analysis.apply_early_statement_effect(state, stmt, loc);
|
||||
vis.visit_after_early_statement_effect(analysis, state, stmt, loc);
|
||||
analysis.apply_primary_statement_effect(state, stmt, loc);
|
||||
vis.visit_after_primary_statement_effect(analysis, state, stmt, loc);
|
||||
}
|
||||
|
||||
vis.visit_block_start(state);
|
||||
@@ -402,20 +403,21 @@ impl Direction for Forward {
|
||||
|
||||
vis.visit_block_start(state);
|
||||
|
||||
let analysis = &mut results.analysis;
|
||||
for (statement_index, stmt) in block_data.statements.iter().enumerate() {
|
||||
let loc = Location { block, statement_index };
|
||||
results.analysis.apply_early_statement_effect(state, stmt, loc);
|
||||
vis.visit_after_early_statement_effect(results, state, stmt, loc);
|
||||
results.analysis.apply_primary_statement_effect(state, stmt, loc);
|
||||
vis.visit_after_primary_statement_effect(results, state, stmt, loc);
|
||||
analysis.apply_early_statement_effect(state, stmt, loc);
|
||||
vis.visit_after_early_statement_effect(analysis, state, stmt, loc);
|
||||
analysis.apply_primary_statement_effect(state, stmt, loc);
|
||||
vis.visit_after_primary_statement_effect(analysis, state, stmt, loc);
|
||||
}
|
||||
|
||||
let loc = Location { block, statement_index: block_data.statements.len() };
|
||||
let term = block_data.terminator();
|
||||
results.analysis.apply_early_terminator_effect(state, term, loc);
|
||||
vis.visit_after_early_terminator_effect(results, state, term, loc);
|
||||
results.analysis.apply_primary_terminator_effect(state, term, loc);
|
||||
vis.visit_after_primary_terminator_effect(results, state, term, loc);
|
||||
analysis.apply_early_terminator_effect(state, term, loc);
|
||||
vis.visit_after_early_terminator_effect(analysis, state, term, loc);
|
||||
analysis.apply_primary_terminator_effect(state, term, loc);
|
||||
vis.visit_after_primary_terminator_effect(analysis, state, term, loc);
|
||||
|
||||
vis.visit_block_end(state);
|
||||
}
|
||||
|
||||
@@ -729,49 +729,49 @@ where
|
||||
|
||||
fn visit_after_early_statement_effect(
|
||||
&mut self,
|
||||
results: &mut Results<'tcx, A>,
|
||||
analysis: &mut A,
|
||||
state: &A::Domain,
|
||||
_statement: &mir::Statement<'tcx>,
|
||||
_location: Location,
|
||||
) {
|
||||
if let Some(before) = self.before.as_mut() {
|
||||
before.push(diff_pretty(state, &self.prev_state, &results.analysis));
|
||||
before.push(diff_pretty(state, &self.prev_state, analysis));
|
||||
self.prev_state.clone_from(state)
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_after_primary_statement_effect(
|
||||
&mut self,
|
||||
results: &mut Results<'tcx, A>,
|
||||
analysis: &mut A,
|
||||
state: &A::Domain,
|
||||
_statement: &mir::Statement<'tcx>,
|
||||
_location: Location,
|
||||
) {
|
||||
self.after.push(diff_pretty(state, &self.prev_state, &results.analysis));
|
||||
self.after.push(diff_pretty(state, &self.prev_state, analysis));
|
||||
self.prev_state.clone_from(state)
|
||||
}
|
||||
|
||||
fn visit_after_early_terminator_effect(
|
||||
&mut self,
|
||||
results: &mut Results<'tcx, A>,
|
||||
analysis: &mut A,
|
||||
state: &A::Domain,
|
||||
_terminator: &mir::Terminator<'tcx>,
|
||||
_location: Location,
|
||||
) {
|
||||
if let Some(before) = self.before.as_mut() {
|
||||
before.push(diff_pretty(state, &self.prev_state, &results.analysis));
|
||||
before.push(diff_pretty(state, &self.prev_state, analysis));
|
||||
self.prev_state.clone_from(state)
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_after_primary_terminator_effect(
|
||||
&mut self,
|
||||
results: &mut Results<'tcx, A>,
|
||||
analysis: &mut A,
|
||||
state: &A::Domain,
|
||||
_terminator: &mir::Terminator<'tcx>,
|
||||
_location: Location,
|
||||
) {
|
||||
self.after.push(diff_pretty(state, &self.prev_state, &results.analysis));
|
||||
self.after.push(diff_pretty(state, &self.prev_state, analysis));
|
||||
self.prev_state.clone_from(state)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ where
|
||||
/// Called after the "early" effect of the given statement is applied to `state`.
|
||||
fn visit_after_early_statement_effect(
|
||||
&mut self,
|
||||
_results: &mut Results<'tcx, A>,
|
||||
_analysis: &mut A,
|
||||
_state: &A::Domain,
|
||||
_statement: &mir::Statement<'tcx>,
|
||||
_location: Location,
|
||||
@@ -48,7 +48,7 @@ where
|
||||
/// Called after the "primary" effect of the given statement is applied to `state`.
|
||||
fn visit_after_primary_statement_effect(
|
||||
&mut self,
|
||||
_results: &mut Results<'tcx, A>,
|
||||
_analysis: &mut A,
|
||||
_state: &A::Domain,
|
||||
_statement: &mir::Statement<'tcx>,
|
||||
_location: Location,
|
||||
@@ -58,7 +58,7 @@ where
|
||||
/// Called after the "early" effect of the given terminator is applied to `state`.
|
||||
fn visit_after_early_terminator_effect(
|
||||
&mut self,
|
||||
_results: &mut Results<'tcx, A>,
|
||||
_analysis: &mut A,
|
||||
_state: &A::Domain,
|
||||
_terminator: &mir::Terminator<'tcx>,
|
||||
_location: Location,
|
||||
@@ -70,7 +70,7 @@ where
|
||||
/// The `call_return_effect` (if one exists) will *not* be applied to `state`.
|
||||
fn visit_after_primary_terminator_effect(
|
||||
&mut self,
|
||||
_results: &mut Results<'tcx, A>,
|
||||
_analysis: &mut A,
|
||||
_state: &A::Domain,
|
||||
_terminator: &mir::Terminator<'tcx>,
|
||||
_location: Location,
|
||||
|
||||
@@ -127,7 +127,7 @@ where
|
||||
{
|
||||
fn visit_after_primary_statement_effect<'mir>(
|
||||
&mut self,
|
||||
_results: &mut Results<'tcx, A>,
|
||||
_analysis: &mut A,
|
||||
state: &A::Domain,
|
||||
_statement: &'mir mir::Statement<'tcx>,
|
||||
location: Location,
|
||||
@@ -141,7 +141,7 @@ where
|
||||
|
||||
fn visit_after_primary_terminator_effect<'mir>(
|
||||
&mut self,
|
||||
_results: &mut Results<'tcx, A>,
|
||||
_analysis: &mut A,
|
||||
state: &A::Domain,
|
||||
_terminator: &'mir mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
|
||||
Reference in New Issue
Block a user