Skip to content

Commit a59a62a

Browse files
committed
---
yaml --- r: 271483 b: refs/heads/auto c: 0d93989 h: refs/heads/master i: 271481: d2cd212 271479: fec24e3
1 parent fef79a1 commit a59a62a

File tree

2 files changed

+37
-13
lines changed

2 files changed

+37
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: d32bde3311a035f2a0d7c26cf3170cf98860d701
11+
refs/heads/auto: 0d93989cf5dd479a097a4d58984a482920982aa5
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/librustc_mir/pretty.rs

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use build::Location;
11+
use build::{Location, ScopeAuxiliary};
1212
use rustc::mir::repr::*;
1313
use rustc::middle::ty::{self, TyCtxt};
1414
use rustc_data_structures::fnv::FnvHashMap;
@@ -25,14 +25,13 @@ pub fn write_mir_pretty<'a, 'tcx, I>(tcx: &TyCtxt<'tcx>,
2525
-> io::Result<()>
2626
where I: Iterator<Item=(&'a NodeId, &'a Mir<'tcx>)>, 'tcx: 'a
2727
{
28-
let no_annotations = FnvHashMap();
2928
for (&node_id, mir) in iter {
30-
write_mir_fn(tcx, node_id, mir, w, &no_annotations)?;
29+
write_mir_fn(tcx, node_id, mir, w, None)?;
3130
}
3231
Ok(())
3332
}
3433

35-
pub enum Annotation {
34+
enum Annotation {
3635
EnterScope(ScopeId),
3736
ExitScope(ScopeId),
3837
}
@@ -41,21 +40,39 @@ pub fn write_mir_fn<'tcx>(tcx: &TyCtxt<'tcx>,
4140
node_id: NodeId,
4241
mir: &Mir<'tcx>,
4342
w: &mut Write,
44-
annotations: &FnvHashMap<Location, Vec<Annotation>>)
43+
auxiliary: Option<&Vec<ScopeAuxiliary>>)
4544
-> io::Result<()> {
45+
// compute scope/entry exit annotations
46+
let mut annotations = FnvHashMap();
47+
if let Some(auxiliary) = auxiliary {
48+
for (index, auxiliary) in auxiliary.iter().enumerate() {
49+
let scope_id = ScopeId::new(index);
50+
51+
annotations.entry(auxiliary.dom)
52+
.or_insert(vec![])
53+
.push(Annotation::EnterScope(scope_id));
54+
55+
for &loc in &auxiliary.postdoms {
56+
annotations.entry(loc)
57+
.or_insert(vec![])
58+
.push(Annotation::ExitScope(scope_id));
59+
}
60+
}
61+
}
62+
4663
write_mir_intro(tcx, node_id, mir, w)?;
4764
for block in mir.all_basic_blocks() {
48-
write_basic_block(tcx, block, mir, w, annotations)?;
65+
write_basic_block(tcx, block, mir, w, &annotations)?;
4966
}
5067

51-
// construct a scope tree
68+
// construct a scope tree and write it out
5269
let mut scope_tree: FnvHashMap<Option<ScopeId>, Vec<ScopeId>> = FnvHashMap();
5370
for (index, scope_data) in mir.scopes.vec.iter().enumerate() {
5471
scope_tree.entry(scope_data.parent_scope)
5572
.or_insert(vec![])
5673
.push(ScopeId::new(index));
5774
}
58-
write_scope_tree(tcx, mir, &scope_tree, w, None, 1)?;
75+
write_scope_tree(tcx, mir, auxiliary, &scope_tree, w, None, 1)?;
5976

6077
writeln!(w, "}}")?;
6178
Ok(())
@@ -115,6 +132,7 @@ fn comment(tcx: &TyCtxt,
115132

116133
fn write_scope_tree(tcx: &TyCtxt,
117134
mir: &Mir,
135+
auxiliary: Option<&Vec<ScopeAuxiliary>>,
118136
scope_tree: &FnvHashMap<Option<ScopeId>, Vec<ScopeId>>,
119137
w: &mut Write,
120138
parent: Option<ScopeId>,
@@ -125,14 +143,20 @@ fn write_scope_tree(tcx: &TyCtxt,
125143
let data = &mir.scopes[child];
126144
assert_eq!(data.parent_scope, parent);
127145
writeln!(w, "{0:1$}Scope({2}) {{", "", indent, child.index())?;
146+
128147
let indent = indent + INDENT.len();
129148
if let Some(parent) = parent {
130149
writeln!(w, "{0:1$}Parent: Scope({2})", "", indent, parent.index())?;
131150
}
132-
writeln!(w, "{0:1$}Extent: {2:?}",
133-
"", indent,
134-
tcx.region_maps.code_extent_data(data.extent))?;
135-
write_scope_tree(tcx, mir, scope_tree, w, Some(child), depth + 1)?;
151+
152+
if let Some(auxiliary) = auxiliary {
153+
let extent = auxiliary[child.index()].extent;
154+
let data = tcx.region_maps.code_extent_data(extent);
155+
writeln!(w, "{0:1$}Extent: {2:?}", "", indent, data)?;
156+
}
157+
158+
write_scope_tree(tcx, mir, auxiliary, scope_tree, w,
159+
Some(child), depth + 1)?;
136160
}
137161
Ok(())
138162
}

0 commit comments

Comments
 (0)