Check if two memory cells alias with each other. If they are from the same func, then perform intraproc alias analysis; otherwise, perform interproc alias analysis.
(&mut self, aid1: AliasId, aid2: AliasId)
| 724 | /// If they are from the same func, then perform intraproc alias analysis; |
| 725 | /// otherwise, perform interproc alias analysis. |
| 726 | pub fn alias(&mut self, aid1: AliasId, aid2: AliasId) -> ApproximateAliasKind { |
| 727 | let AliasId { |
| 728 | instance_id: id1, |
| 729 | local: local1, |
| 730 | } = aid1; |
| 731 | let AliasId { |
| 732 | instance_id: id2, |
| 733 | local: local2, |
| 734 | } = aid2; |
| 735 | |
| 736 | let instance1 = self |
| 737 | .callgraph |
| 738 | .index_to_instance(id1) |
| 739 | .map(CallGraphNode::instance); |
| 740 | let instance2 = self |
| 741 | .callgraph |
| 742 | .index_to_instance(id2) |
| 743 | .map(CallGraphNode::instance); |
| 744 | |
| 745 | match (instance1, instance2) { |
| 746 | (Some(instance1), Some(instance2)) => { |
| 747 | let node1 = ConstraintNode::Place(Place::from(local1).as_ref()); |
| 748 | let node2 = ConstraintNode::Place(Place::from(local2).as_ref()); |
| 749 | if instance1.def_id() == instance2.def_id() { |
| 750 | if local1 == local2 { |
| 751 | return ApproximateAliasKind::Probably; |
| 752 | } |
| 753 | self.intraproc_alias(instance1, &node1, &node2) |
| 754 | .unwrap_or(ApproximateAliasKind::Unknown) |
| 755 | } else { |
| 756 | self.interproc_alias(instance1, &node1, instance2, &node2) |
| 757 | .unwrap_or(ApproximateAliasKind::Unknown) |
| 758 | } |
| 759 | } |
| 760 | _ => ApproximateAliasKind::Unknown, |
| 761 | } |
| 762 | } |
| 763 | |
| 764 | /// Check if `pointer` points to `pointee`. |
| 765 | /// First get the pts(`pointer`), |
no test coverage detected