-
Notifications
You must be signed in to change notification settings - Fork 100
/
verifier.rs
72 lines (59 loc) · 2.42 KB
/
verifier.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! A module that invokes the verifier `prusti-viper`
use crate::specs::typed;
use log::{debug, trace, warn};
use prusti_interface::{
data::{VerificationResult, VerificationTask},
environment::Environment,
};
use prusti_viper::verifier::Verifier;
use rustc_middle::ty::TyCtxt;
use prusti_common::config::ConfigFlags;
use prusti_common::report::user;
pub fn verify<'tcx>(flags: ConfigFlags, tcx: TyCtxt<'tcx>, spec: typed::SpecificationMap<'tcx>) {
trace!("[verify] enter");
let env = Environment::new(tcx);
if env.has_errors() {
warn!("The compiler reported an error, so the program will not be verified.");
} else {
debug!("Specification consists of {} elements.", spec.len());
debug!("Prepare verification task...");
let annotated_procedures = env.get_annotated_procedures();
let verification_task = VerificationTask {
procedures: annotated_procedures,
};
debug!("Verification task: {:?}", &verification_task);
user::message(format!(
"Verification of {} items...",
verification_task.procedures.len()
));
if flags.print_collected_verfication_items {
println!("Collected verification items {}:", verification_task.procedures.len());
for procedure in &verification_task.procedures {
println!("procedure: {} at {:?}", env.get_item_def_path(*procedure), env.get_item_span(*procedure));
}
}
let verification_result = if verification_task.procedures.is_empty() {
VerificationResult::Success
} else {
debug!("Dump borrow checker info...");
env.dump_borrowck_info(&verification_task.procedures);
let mut verifier = Verifier::new(&env, &spec);
let verification_result = verifier.verify(&verification_task);
debug!("Verifier returned {:?}", verification_result);
verification_result
};
match verification_result {
VerificationResult::Success => {
user::message(format!(
"Successful verification of {} items",
verification_task.procedures.len()
));
}
VerificationResult::Failure => {
user::message("Verification failed");
debug_assert!(env.has_errors());
}
};
}
trace!("[verify] exit");
}