Block ends with the call of a function. #Arguments `func` - The function that’s being called `args` - Arguments the function is called with. These are owned by the callee, which is free to modify them. This allows the memory occupied by "by-value" arguments to be reused across function calls without duplicating the contents. `destination` - Destination for the return value. If some, the call retu
(
&mut self,
func: &mir::Operand<'tcx>,
args: &[Spanned<mir::Operand<'tcx>>],
destination: mir::Place<'tcx>,
_target: Option<mir::BasicBlock>,
_unwind:
| 1277 | /// * `call_source` - Where this call came from in HIR/THIR. |
| 1278 | /// operator. True for overloaded function call. |
| 1279 | fn visit_call( |
| 1280 | &mut self, |
| 1281 | func: &mir::Operand<'tcx>, |
| 1282 | args: &[Spanned<mir::Operand<'tcx>>], |
| 1283 | destination: mir::Place<'tcx>, |
| 1284 | _target: Option<mir::BasicBlock>, |
| 1285 | _unwind: mir::UnwindAction, |
| 1286 | _call_source: mir::CallSource, |
| 1287 | _fn_span: &rustc_span::Span, |
| 1288 | ) { |
| 1289 | // debug!("source location {:?}", self.body_visitor.current_span); |
| 1290 | debug!("function operand: {:?}, arguments: {:?}", func, args); |
| 1291 | debug!( |
| 1292 | "self.generic_argument_map {:?}", |
| 1293 | self.body_visitor.type_visitor.generic_argument_map |
| 1294 | ); |
| 1295 | debug!("Before visit_call, env: {:?}", self.state()); |
| 1296 | // Get `SymbolicValue` from `mir::Operand::Constant` |
| 1297 | let func_to_call = self.visit_operand(func); |
| 1298 | info!("func_to_call is {:?}", func_to_call); |
| 1299 | let actual_args: Vec<(Rc<Path>, Rc<SymbolicValue>)> = args |
| 1300 | .iter() |
| 1301 | .map(|arg| { |
| 1302 | ( |
| 1303 | self.get_operand_path(&arg.node), |
| 1304 | self.visit_operand(&arg.node), |
| 1305 | ) |
| 1306 | }) |
| 1307 | .collect(); |
| 1308 | let actual_argument_types: Vec<Ty<'tcx>> = args |
| 1309 | .iter() |
| 1310 | .map(|arg| { |
| 1311 | let arg_ty = self.get_operand_rustc_type(&arg.node); |
| 1312 | self.body_visitor |
| 1313 | .type_visitor |
| 1314 | .specialize_generic_argument_type( |
| 1315 | arg_ty, |
| 1316 | &self.body_visitor.type_visitor.generic_argument_map, |
| 1317 | ) |
| 1318 | }) |
| 1319 | .collect(); |
| 1320 | // Get `FunctionReference` from `SymbolicValue` |
| 1321 | let func_ref = self.get_func_ref(&func_to_call); |
| 1322 | // If the function cannot be reliably analyzed, simply ignore it and return |
| 1323 | let func_ref_to_call = if let Some(fr) = func_ref { |
| 1324 | fr |
| 1325 | } else { |
| 1326 | let destination_path = self.get_path_for_place(&destination); |
| 1327 | self.body_visitor |
| 1328 | .state |
| 1329 | .update_value_at(destination_path, symbolic_value::TOP.into()); |
| 1330 | for ((path, _), ty) in actual_args.iter().zip(actual_argument_types.iter()) { |
| 1331 | if matches!( |
| 1332 | ty.kind(), |
| 1333 | TyKind::Ref(_, _, rustc_hir::Mutability::Mut) |
| 1334 | | TyKind::RawPtr(_, rustc_hir::Mutability::Mut) |
| 1335 | ) { |
| 1336 | self.body_visitor.state.forget_paths_rooted_by(path); |
no test coverage detected