diff --git a/crates/flowistry/src/pdg/construct.rs b/crates/flowistry/src/pdg/construct.rs index de85159f6..6f7ab47a7 100644 --- a/crates/flowistry/src/pdg/construct.rs +++ b/crates/flowistry/src/pdg/construct.rs @@ -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() diff --git a/crates/flowistry/tests/pdg.rs b/crates/flowistry/tests/pdg.rs index c8152fbdd..7beab8fad 100644 --- a/crates/flowistry/tests/pdg.rs +++ b/crates/flowistry/tests/pdg.rs @@ -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,