Skip to content

Commit

Permalink
analyze: rewrite::unlower: factor out debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
spernsteiner committed May 30, 2023
1 parent 9d25103 commit cda2242
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions c2rust-analyze/src/rewrite/expr/unlower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,16 @@ pub fn unlower<'tcx>(
};
intravisit::Visitor::visit_body(&mut visitor, hir);

// Print results.
debug_print_unlower_map(tcx, mir, &visitor.mir_map);

visitor.mir_map
}

fn debug_print_unlower_map<'tcx>(
tcx: TyCtxt<'tcx>,
mir: &Body<'tcx>,
unlower_map: &BTreeMap<(Location, Vec<SubLoc>), MirOrigin>,
) {
eprintln!("unlowering for {:?}:", mir.source);
for (bb_id, bb) in mir.basic_blocks().iter_enumerated() {
eprintln!(" block {bb_id:?}:");
Expand All @@ -350,7 +359,7 @@ pub fn unlower<'tcx>(
};

eprintln!(" {loc:?}: {stmt:?}");
for (k, v) in visitor.mir_map.range(&(loc, vec![])..) {
for (k, v) in unlower_map.range(&(loc, vec![])..) {
if k.0 != loc {
break;
}
Expand All @@ -368,7 +377,7 @@ pub fn unlower<'tcx>(
};

eprintln!(" {loc:?}: {term:?}");
for (k, v) in visitor.mir_map.range(&(loc, vec![])..) {
for (k, v) in unlower_map.range(&(loc, vec![])..) {
if k.0 != loc {
break;
}
Expand All @@ -378,6 +387,4 @@ pub fn unlower<'tcx>(
}
}
}

visitor.mir_map
}

0 comments on commit cda2242

Please sign in to comment.