Skip to content

Commit

Permalink
analyze: ignore !UNIQUE from pdg if --skip-borrowck is set
Browse files Browse the repository at this point in the history
  • Loading branch information
spernsteiner committed Dec 9, 2024
1 parent c7c5a2d commit 6c3455e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions c2rust-analyze/src/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,8 @@ fn run(tcx: TyCtxt) {
}
}

let skip_borrowck_everywhere = env::var("C2RUST_ANALYZE_SKIP_BORROWCK").as_deref() == Ok("1");

// Load permission info from PDG
let pdg_compare = env::var("C2RUST_ANALYZE_COMPARE_PDG").as_deref() == Ok("1");
// In compare mode, we load the PDG for comparison after analysis, not before.
Expand All @@ -796,6 +798,7 @@ fn run(tcx: TyCtxt) {
&mut func_info,
&mut asn,
&mut updates_forbidden,
skip_borrowck_everywhere,
pdg_file_path,
);
}
Expand Down Expand Up @@ -877,8 +880,6 @@ fn run(tcx: TyCtxt) {
debug!("=== ADT Metadata ===");
debug!("{:?}", gacx.adt_metadata);

let skip_borrowck_everywhere = env::var("C2RUST_ANALYZE_SKIP_BORROWCK").as_deref() == Ok("1");

let mut loop_count = 0;
loop {
// Loop until the global assignment reaches a fixpoint. The inner loop also runs until a
Expand Down Expand Up @@ -2242,6 +2243,7 @@ fn pdg_update_permissions<'tcx>(
func_info: &mut HashMap<LocalDefId, FuncInfo<'tcx>>,
asn: &mut Assignment,
updates_forbidden: &mut GlobalPointerTable<PermissionSet>,
skip_borrowck_everywhere: bool,
pdg_file_path: impl AsRef<Path>,
) {
let allow_unsound =
Expand Down Expand Up @@ -2280,8 +2282,8 @@ fn pdg_update_permissions<'tcx>(
if node_info.flows_to.neg_offset.is_some() {
perms.insert(PermissionSet::OFFSET_SUB);
}
if !node_info.unique {
//perms.remove(PermissionSet::UNIQUE);
if !node_info.unique && !skip_borrowck_everywhere {
perms.remove(PermissionSet::UNIQUE);
}
}

Expand Down

0 comments on commit 6c3455e

Please sign in to comment.