(&mut self, _compiler: &interface::Compiler, tcx: TyCtxt<'tcx>)
| 88 | let crate_name = tcx.crate_name(LOCAL_CRATE).to_string(); |
| 89 | match &self.options.crate_name_list { |
| 90 | CrateNameList::White(crates) if !crates.is_empty() && !crates.contains(&crate_name) => { |
| 91 | return |
| 92 | } |
| 93 | CrateNameList::Black(crates) if crates.contains(&crate_name) => return, |
| 94 | _ => {} |
| 95 | }; |
| 96 | if tcx.sess.opts.unstable_opts.no_codegen || !tcx.sess.opts.output_types.should_codegen() { |
| 97 | return; |
| 98 | } |
| 99 | let cgus = tcx.collect_and_partition_mono_items(()).codegen_units; |
| 100 | let instances: Vec<Instance<'tcx>> = cgus |
| 101 | .iter() |
| 102 | .flat_map(|cgu| { |
| 103 | cgu.items().iter().filter_map(|(mono_item, _)| { |
| 104 | if let MonoItem::Fn(instance) = mono_item { |
| 105 | Some(*instance) |
| 106 | } else { |
| 107 | None |
| 108 | } |
| 109 | }) |
| 110 | }) |
| 111 | .collect(); |
| 112 | let mut callgraph = CallGraph::new(); |
| 113 | let typing_env = TypingEnv::fully_monomorphized(); |
| 114 | callgraph.analyze(instances.clone(), tcx, typing_env); |
| 115 | let mut alias_analysis = AliasAnalysis::new(tcx, &callgraph); |
| 116 | match self.options.detector_kind { |
| 117 | DetectorKind::Deadlock => { |
| 118 | debug!("Detecting deadlock"); |
| 119 | let mut deadlock_detector = DeadlockDetector::new(tcx, typing_env); |
| 120 | let reports = deadlock_detector.detect(&callgraph, &mut alias_analysis); |
| 121 | if !reports.is_empty() { |
| 122 | let j = serde_json::to_string_pretty(&reports).unwrap(); |
| 123 | warn!("{}", j); |
| 124 | let stats = report_stats(&crate_name, &reports); |
| 125 | warn!("{}", stats); |
| 126 | } |
| 127 | } |
| 128 | DetectorKind::AtomicityViolation => { |
| 129 | debug!("Detecting atomicity violation"); |
| 130 | let mut atomicity_violation_detector = AtomicityViolationDetector::new(tcx); |
| 131 | let reports = filter_std_reports( |
| 132 | atomicity_violation_detector.detect(&callgraph, &mut alias_analysis), |
| 133 | ); |
| 134 | if !reports.is_empty() { |
| 135 | let j = serde_json::to_string_pretty(&reports).unwrap(); |
| 136 | warn!("{}", j); |
| 137 | let stats = report_stats(&crate_name, &reports); |
| 138 | warn!("{}", stats); |
| 139 | } |
| 140 | } |
| 141 | DetectorKind::Memory => { |
| 142 | debug!("Detecting memory bugs"); |
| 143 | let mut reports = { |
| 144 | let invalid_free_detector = InvalidFreeDetector::new(tcx); |
| 145 | invalid_free_detector.detect(&callgraph, &mut alias_analysis) |
| 146 | }; |
| 147 | let reports2 = { |
no test coverage detected