Check if `pointer` points to `pointee`. First get the pts(`pointer`), then check alias between each node in pts(`pointer`) and `pointee`. Choose the highest alias kind.
(&mut self, pointer: AliasId, pointee: AliasId)
| 766 | /// then check alias between each node in pts(`pointer`) and `pointee`. |
| 767 | /// Choose the highest alias kind. |
| 768 | pub fn points_to(&mut self, pointer: AliasId, pointee: AliasId) -> ApproximateAliasKind { |
| 769 | let AliasId { |
| 770 | instance_id: id1, |
| 771 | local: local1, |
| 772 | } = pointer; |
| 773 | let AliasId { |
| 774 | instance_id: id2, |
| 775 | local: local2, |
| 776 | } = pointee; |
| 777 | |
| 778 | let instance1 = self |
| 779 | .callgraph |
| 780 | .index_to_instance(id1) |
| 781 | .map(CallGraphNode::instance); |
| 782 | let instance2 = self |
| 783 | .callgraph |
| 784 | .index_to_instance(id2) |
| 785 | .map(CallGraphNode::instance); |
| 786 | |
| 787 | match (instance1, instance2) { |
| 788 | (Some(instance1), Some(instance2)) => { |
| 789 | let node1 = ConstraintNode::Place(Place::from(local1).as_ref()); |
| 790 | let node2 = ConstraintNode::Place(Place::from(local2).as_ref()); |
| 791 | if instance1.def_id() == instance2.def_id() { |
| 792 | self.intra_points_to(instance1, node1, node2) |
| 793 | } else { |
| 794 | self.inter_points_to(instance1, node1, instance2, node2) |
| 795 | } |
| 796 | } |
| 797 | _ => ApproximateAliasKind::Unknown, |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | pub fn intra_points_to( |
| 802 | &mut self, |
no test coverage detected