Skip to content

Commit

Permalink
remove the exit_map field, it is unnecessary.
Browse files Browse the repository at this point in the history
(Factoring of aatch CFG code, Part 2.)
  • Loading branch information
Aatch authored and pnkfelix committed Feb 22, 2015
1 parent 97c1711 commit a0b7bad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
13 changes: 2 additions & 11 deletions src/librustc/middle/cfg/construct.rs
Expand Up @@ -16,11 +16,9 @@ use middle::ty;
use syntax::ast;
use syntax::ast_util;
use syntax::ptr::P;
use util::nodemap::NodeMap;

struct CFGBuilder<'a, 'tcx: 'a> {
tcx: &'a ty::ctxt<'tcx>,
exit_map: NodeMap<CFGIndex>,
graph: CFGGraph,
fn_exit: CFGIndex,
loop_scopes: Vec<LoopScope>,
Expand All @@ -46,17 +44,15 @@ pub fn construct(tcx: &ty::ctxt,
let block_exit;

let mut cfg_builder = CFGBuilder {
exit_map: NodeMap(),
graph: graph,
fn_exit: fn_exit,
tcx: tcx,
loop_scopes: Vec::new()
};
block_exit = cfg_builder.block(blk, entry);
cfg_builder.add_contained_edge(block_exit, fn_exit);
let CFGBuilder {exit_map, graph, ..} = cfg_builder;
CFG {exit_map: exit_map,
graph: graph,
let CFGBuilder {graph, ..} = cfg_builder;
CFG {graph: graph,
entry: entry,
exit: fn_exit}
}
Expand Down Expand Up @@ -512,7 +508,6 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
}

fn add_ast_node(&mut self, id: ast::NodeId, preds: &[CFGIndex]) -> CFGIndex {
assert!(!self.exit_map.contains_key(&id));
assert!(id != ast::DUMMY_NODE_ID);
self.add_node(CFGNodeData::AST(id), preds)
}
Expand All @@ -523,10 +518,6 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {

fn add_node(&mut self, data: CFGNodeData, preds: &[CFGIndex]) -> CFGIndex {
let node = self.graph.add_node(data);
if let CFGNodeData::AST(id) = data {
assert!(!self.exit_map.contains_key(&id));
self.exit_map.insert(id, node);
}
for &pred in preds {
self.add_contained_edge(pred, node);
}
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/middle/cfg/mod.rs
Expand Up @@ -14,13 +14,11 @@
use middle::graph;
use middle::ty;
use syntax::ast;
use util::nodemap::NodeMap;

mod construct;
pub mod graphviz;

pub struct CFG {
pub exit_map: NodeMap<CFGIndex>,
pub graph: CFGGraph,
pub entry: CFGIndex,
pub exit: CFGIndex,
Expand Down

0 comments on commit a0b7bad

Please sign in to comment.