Skip to content

Commit

Permalink
analyze: borrowck: don't dump facts to disk for debugging by default
Browse files Browse the repository at this point in the history
  • Loading branch information
spernsteiner committed Aug 6, 2024
1 parent ff75175 commit 4dc0d1e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions c2rust-analyze/src/borrowck/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@
use crate::borrowck::atoms::{AllFacts, AtomMaps, Loan, Origin, Output, Path, Point, Variable};
use rustc_hash::{FxHashMap, FxHashSet};
use std::collections::{BTreeMap, BTreeSet};
use std::env;
use std::error::Error;
use std::fmt::Write as _;
use std::fs::{self, File};
use std::hash::Hash;
use std::io::{BufWriter, Write};
use std::path;

thread_local! {
static DUMP_FACTS: bool = {
env::var("C2RUST_ANALYZE_DUMP_POLONIUS_FACTS").map_or(false, |val| &val == "1")
};
}

pub fn dump_facts_to_dir(
facts: &AllFacts,
maps: &AtomMaps,
dir: impl AsRef<path::Path>,
) -> Result<(), Box<dyn Error>> {
if !DUMP_FACTS.with(|&flag| flag) {
return Ok(());
}
let dir: &path::Path = dir.as_ref();
fs::create_dir_all(dir)?;
let wr = FactWriter { maps, dir };
Expand Down Expand Up @@ -60,6 +70,9 @@ pub fn dump_output_to_dir(
maps: &AtomMaps,
dir: impl AsRef<path::Path>,
) -> Result<(), Box<dyn Error>> {
if !DUMP_FACTS.with(|&flag| flag) {
return Ok(());
}
let dir: &path::Path = dir.as_ref();
fs::create_dir_all(dir)?;
let wr = FactWriter { maps, dir };
Expand Down

0 comments on commit 4dc0d1e

Please sign in to comment.