mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-03 13:37:37 +00:00
update gsgdt
This commit is contained in:
parent
5b049e107b
commit
a4e94ec9b8
@ -1342,9 +1342,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gsgdt"
|
name = "gsgdt"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9cb4a3313cdc3c65906272ddd8987c7291ff6df4b5c9997c1232b6acd1ceab24"
|
checksum = "a0d876ce7262df96262a2a19531da6ff9a86048224d49580a585fc5c04617825"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
@ -10,7 +10,7 @@ doctest = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
either = "1.5.0"
|
either = "1.5.0"
|
||||||
rustc_graphviz = { path = "../rustc_graphviz" }
|
rustc_graphviz = { path = "../rustc_graphviz" }
|
||||||
gsgdt = "0.1.1"
|
gsgdt = "0.1.2"
|
||||||
itertools = "0.9"
|
itertools = "0.9"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
polonius-engine = "0.12.0"
|
polonius-engine = "0.12.0"
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
use gsgdt::{Edge, Graph, GraphKind, Node, NodeStyle};
|
use gsgdt::{Edge, Graph, Node, NodeStyle};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_index::vec::Idx;
|
use rustc_index::vec::Idx;
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
|
|
||||||
/// Convert an MIR function into a gsgdt Graph
|
/// Convert an MIR function into a gsgdt Graph
|
||||||
pub fn mir_fn_to_generic_graph<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'_>, subgraph: bool) -> Graph {
|
pub fn mir_fn_to_generic_graph<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'_>) -> Graph {
|
||||||
let def_id = body.source.def_id();
|
let def_id = body.source.def_id();
|
||||||
let kind = if subgraph { GraphKind::Subgraph } else { GraphKind::Digraph };
|
|
||||||
let def_name = graphviz_safe_def_name(def_id);
|
let def_name = graphviz_safe_def_name(def_id);
|
||||||
let graph_name = format!("Mir_{}", def_name);
|
let graph_name = format!("Mir_{}", def_name);
|
||||||
let dark_mode = tcx.sess.opts.debugging_opts.graphviz_dark_mode;
|
let dark_mode = tcx.sess.opts.debugging_opts.graphviz_dark_mode;
|
||||||
@ -33,7 +32,7 @@ pub fn mir_fn_to_generic_graph<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'_>, subgrap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Graph::new(graph_name, kind, nodes, edges)
|
Graph::new(graph_name, nodes, edges)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bb_to_graph_node(block: BasicBlock, body: &Body<'_>, dark_mode: bool) -> Node {
|
fn bb_to_graph_node(block: BasicBlock, body: &Body<'_>, dark_mode: bool) -> Node {
|
||||||
|
@ -60,14 +60,14 @@ where
|
|||||||
let mut label = String::from("");
|
let mut label = String::from("");
|
||||||
// FIXME: remove this unwrap
|
// FIXME: remove this unwrap
|
||||||
write_graph_label(tcx, body, &mut label).unwrap();
|
write_graph_label(tcx, body, &mut label).unwrap();
|
||||||
let g = mir_fn_to_generic_graph(tcx, body, subgraph);
|
let g = mir_fn_to_generic_graph(tcx, body);
|
||||||
let settings = GraphvizSettings {
|
let settings = GraphvizSettings {
|
||||||
graph_attrs: Some(graph_attrs.join(" ")),
|
graph_attrs: Some(graph_attrs.join(" ")),
|
||||||
node_attrs: Some(content_attrs.join(" ")),
|
node_attrs: Some(content_attrs.join(" ")),
|
||||||
edge_attrs: Some(content_attrs.join(" ")),
|
edge_attrs: Some(content_attrs.join(" ")),
|
||||||
graph_label: Some(label),
|
graph_label: Some(label),
|
||||||
};
|
};
|
||||||
g.to_dot(w, &settings)
|
g.to_dot(w, &settings, subgraph)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write the graphviz DOT label for the overall graph. This is essentially a block of text that
|
/// Write the graphviz DOT label for the overall graph. This is essentially a block of text that
|
||||||
|
Loading…
Reference in New Issue
Block a user