Skip to content

Commit

Permalink
Better splits
Browse files Browse the repository at this point in the history
  • Loading branch information
adpaco-aws committed Apr 8, 2024
1 parent 7b40ef3 commit 952c406
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ pub mod rustc_smir {
// println!("COVERAGE: {:?}", &cov_info.mappings);
for mapping in &cov_info.mappings {
if mapping.kind.terms().next().unwrap() == coverage {
println!("COVERAGE: {:?}", mapping.code_region.clone());
return Some(mapping.code_region.clone());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<'tcx> GotocCtx<'tcx> {
let instance = self.current_fn().instance_stable();
let cov_info = format!("{cov:?} ({fun})");
// NOTE: This helps see the coverage info we're processing
println!("COVERAGE: {:?} {:?} {:?}", cov, fun, stmt.span);
// println!("COVERAGE: {:?} {:?} {:?}", cov, fun, stmt.span);
let cov_span = coverage_opaque_span(self.tcx, cov.clone(), instance);
if let Some(code_region) = cov_span {
let coverage_stmt = self.codegen_coverage(&cov_info, stmt.span, code_region);
Expand Down
14 changes: 9 additions & 5 deletions kani-driver/src/coverage/cov_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ impl Display for CoverageRegion {

impl CoverageRegion {
pub fn from_str(str: String) -> Self {
let str_splits: Vec<&str> = str.split([':', '-']).map(|s| s.trim()).collect();
assert_eq!(str_splits.len(), 5, "{str:?}");
let file = str_splits[0].to_string();
let start = (str_splits[1].parse().unwrap(), str_splits[2].parse().unwrap());
let end = (str_splits[3].parse().unwrap(), str_splits[4].parse().unwrap());
let blank_splits: Vec<&str> = str.split_whitespace().map(|s| s.trim()).collect();
assert!(blank_splits[1] == "-");
let str_splits1: Vec<&str> = blank_splits[0].split([':']).collect();
let str_splits2: Vec<&str> = blank_splits[2].split([':']).collect();
assert_eq!(str_splits1.len(), 3, "{str:?}");
assert_eq!(str_splits2.len(), 2, "{str:?}");
let file = str_splits1[0].to_string();
let start = (str_splits1[1].parse().unwrap(), str_splits1[2].parse().unwrap());
let end = (str_splits2[0].parse().unwrap(), str_splits2[1].parse().unwrap());
Self { file, start, end }
}
}
Expand Down

0 comments on commit 952c406

Please sign in to comment.