MCPcopy Create free account
hub / github.com/Rust-API/Rust-API-Bypass-Checker / visit_aggregate

Method visit_aggregate

src/analysis/mir_visitor/block_visitor.rs:1656–1788  ·  view source on GitHub ↗

operands contains a list of values E.g. Aggregate(Array(i32), [const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32])

(
        &mut self,
        path: Rc<Path>,
        aggregate_kind: &mir::AggregateKind<'tcx>,
        operands: &IndexVec<FieldIdx, mir::Operand<'tcx>>,
    )

Source from the content-addressed store, hash-verified

1654 // operands contains a list of values
1655 // E.g. Aggregate(Array(i32), [const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32])
1656 fn visit_aggregate(
1657 &mut self,
1658 path: Rc<Path>,
1659 aggregate_kind: &mir::AggregateKind<'tcx>,
1660 operands: &IndexVec<FieldIdx, mir::Operand<'tcx>>,
1661 ) {
1662 // assert!(matches!(aggregate_kind, mir::AggregateKind::Array(..)));
1663 // let length_path = Path::new_length(path.clone()).refine_paths(&self.state());
1664 // let length_value = self.body_visitor.get_u128_const_val(operands.len() as u128);
1665 // self.body_visitor
1666 // .state
1667 // .update_value_at(length_path, length_value);
1668
1669 // // Handle the list of operands
1670 // for (i, operand) in operands.iter().enumerate() {
1671 // let index_value = self.body_visitor.get_u128_const_val(i as u128);
1672 // let index_path = Path::new_index(path.clone(), index_value).refine_paths(&self.state());
1673 // self.visit_used_operand(index_path, operand);
1674 // }
1675 match aggregate_kind {
1676 mir::AggregateKind::Array(_ty) => {
1677 let length_path = Path::new_length(path.clone());
1678 let length_value = self.body_visitor.get_u128_const_val(operands.len() as u128);
1679 self.body_visitor
1680 .state
1681 .update_value_at(length_path, length_value);
1682 for (i, operand) in operands.iter().enumerate() {
1683 let index_value = self.body_visitor.get_u128_const_val(i as u128);
1684 let index_path = Path::new_index(path.clone(), index_value);
1685 // self.type_visitor_mut()
1686 // .set_path_rustc_type(index_path.clone(), *ty);
1687 self.visit_use(index_path, operand);
1688 }
1689 }
1690 mir::AggregateKind::Tuple => {
1691 let ty = self
1692 .body_visitor
1693 .type_visitor
1694 .get_path_rustc_type(&path, self.body_visitor.current_span);
1695 let _types = if let TyKind::Tuple(types) = ty.kind() {
1696 types.as_slice()
1697 } else {
1698 &[]
1699 };
1700 for (i, operand) in operands.iter().enumerate() {
1701 let index_path = Path::new_field(path.clone(), i);
1702 // if let Some(ty) = types.get(i) {
1703 // self.type_visitor_mut()
1704 // .set_path_rustc_type(index_path.clone(), *ty);
1705 // };
1706 self.visit_use(index_path, operand);
1707 }
1708 }
1709 mir::AggregateKind::Adt(def, variant_idx, args, _, _case_index) => {
1710 let path = path;
1711 let adt_def = self.body_visitor.context.tcx.adt_def(def);
1712 let variant_def = &adt_def.variants()[*variant_idx];
1713 let _adt_ty = self.body_visitor.context.tcx.type_of(def).skip_binder();

Callers 1

visit_rvalueMethod · 0.80

Calls 8

get_u128_const_valMethod · 0.80
update_value_atMethod · 0.80
visit_useMethod · 0.80
get_path_rustc_typeMethod · 0.80
set_path_rustc_typeMethod · 0.80
is_emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected