diff options
| author | bors <bors@rust-lang.org> | 2016-03-22 10:00:12 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-03-22 10:00:12 -0700 |
| commit | e3f2dfdececa8053e652eb0fb286db9aef0f82e6 (patch) | |
| tree | 9e313f060d8250a287a0674d6e22279ed579f771 /src/librustc_driver | |
| parent | c7bdfd4442f0bde3412f08336f75b9eabff4a938 (diff) | |
| parent | 782c0cf4a2fb57492012f6093ad7b70be72f654d (diff) | |
| download | rust-e3f2dfdececa8053e652eb0fb286db9aef0f82e6.tar.gz rust-e3f2dfdececa8053e652eb0fb286db9aef0f82e6.zip | |
Auto merge of #32156 - pnkfelix:borrowck-on-mir-move-analysis, r=nikomatsakis
Move analysis for MIR borrowck This PR adds code for doing MIR-based gathering of the moves in a `fn` and the dataflow to determine where uninitialized locations flow to, analogous to how the same thing is done in `borrowck`. It also adds a couple attributes to print out graphviz visualizations of the analyzed MIR that includes the dataflow analysis results. cc @nikomatsakis
Diffstat (limited to 'src/librustc_driver')
| -rw-r--r-- | src/librustc_driver/driver.rs | 2 | ||||
| -rw-r--r-- | src/librustc_driver/pretty.rs | 19 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 8dac25cc0cb..c39d0d7587f 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -880,7 +880,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, time(time_passes, "borrow checking", - || borrowck::check_crate(tcx)); + || borrowck::check_crate(tcx, &mir_map)); // Avoid overwhelming user with errors if type checking failed. // I'm not sure how helpful this is, to be honest, but it avoids diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 4792fa72831..5134278de21 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -56,6 +56,8 @@ use rustc_front::hir; use rustc_front::lowering::{lower_crate, LoweringContext}; use rustc_front::print::pprust as pprust_hir; +use rustc::mir::mir_map::MirMap; + #[derive(Copy, Clone, PartialEq, Debug)] pub enum PpSourceMode { PpmNormal, @@ -875,9 +877,10 @@ pub fn pretty_print_input(sess: Session, &arenas, &id, resolve::MakeGlobMap::No, - |tcx, _, _, _| { + |tcx, mir_map, _, _| { print_flowgraph(variants, tcx, + mir_map.as_ref(), code, mode, out) @@ -911,12 +914,13 @@ pub fn pretty_print_input(sess: Session, } } -fn print_flowgraph<W: Write>(variants: Vec<borrowck_dot::Variant>, - tcx: &TyCtxt, - code: blocks::Code, - mode: PpFlowGraphMode, - mut out: W) - -> io::Result<()> { +fn print_flowgraph<'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>, + tcx: &TyCtxt<'tcx>, + mir_map: Option<&MirMap<'tcx>>, + code: blocks::Code, + mode: PpFlowGraphMode, + mut out: W) + -> io::Result<()> { let cfg = match code { blocks::BlockCode(block) => cfg::CFG::new(tcx, &block), blocks::FnLikeCode(fn_like) => cfg::CFG::new(tcx, &fn_like.body()), @@ -942,6 +946,7 @@ fn print_flowgraph<W: Write>(variants: Vec<borrowck_dot::Variant>, blocks::FnLikeCode(fn_like) => { let (bccx, analysis_data) = borrowck::build_borrowck_dataflow_data_for_fn(tcx, + mir_map, fn_like.to_fn_parts(), &cfg); |
