Skip to content

Commit

Permalink
Debug dumping and attempting immutable argument connections
Browse files Browse the repository at this point in the history
  • Loading branch information
JustusAdam committed Jan 16, 2024
1 parent 4354a7b commit a1ab5c7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
22 changes: 15 additions & 7 deletions crates/flowistry/src/pdg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,15 +682,23 @@ impl<'tcx> GraphConstructor<'tcx> {
// Find every reference to a parent-able node in the child's graph.
let is_arg = |node: &DepNode<'tcx>| {
node.at.leaf().function == child_constructor.def_id
&& (node.place.local == RETURN_PLACE
&& (node.place.local == RETURN_PLACE
|| node.place.is_arg(&child_constructor.body))
};
let parentable_srcs = child_graph
.edges
.iter()
.map(|(src, _, _)| *src)
.filter(is_arg)
.filter(|node| node.at.leaf().location.is_start());
// An attempt at getting immutable arguments to connect
let parentable_srcs = if self.params.false_call_edges {
Either::Right(child_constructor.body.args_iter()
.map(|local| Place::from(local))
.flat_map(|place| child_constructor.place_info.children(place).into_iter().chain([place]))
.map(|place| DepNode::new(place, child_constructor.make_call_string(RichLocation::Start), self.tcx, child_constructor.body.as_ref())))
} else {
Either::Left(child_graph
.edges
.iter()
.map(|(src, _, _)| *src)
.filter(is_arg)
.filter(|node| node.at.leaf().location.is_start()))
};
let parentable_dsts = child_graph
.edges
.iter()
Expand Down
6 changes: 6 additions & 0 deletions crates/flowistry/tests/pdg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,12 @@ fn main() {

let ref with_edges = flowistry::pdg::compute_pdg(params.with_false_call_edges());

with_edges.generate_graphviz(
"graph.pdf"
).unwrap();

println!("Running in {}", std::env::current_dir().unwrap().display());

assert!(connects(
tcx,
with_edges,
Expand Down

0 comments on commit a1ab5c7

Please sign in to comment.