Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rust-code-analysis-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ fn act_on_file(language: Option<LANG>, path: PathBuf, cfg: &Config) -> std::io::
} else if cfg.preproc_lock.is_some() {
if let Some(language) = guess_language(&source, &path).0 {
if language == LANG::Cpp {
let mut results = cfg.preproc_lock.as_ref().unwrap().lock().unwrap();
preprocess(
&PreprocParser::new(source, &path, None),
&path,
cfg.preproc_lock.as_ref().unwrap().clone(),
&mut results,
);
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/preproc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use petgraph::{
};
use std::collections::{hash_map, HashMap, HashSet};
use std::path::PathBuf;
use std::sync::{Arc, Mutex};

use crate::langs::*;
use crate::languages::language_preproc::*;
Expand Down Expand Up @@ -178,12 +177,11 @@ pub fn fix_includes<S: ::std::hash::BuildHasher>(
}

/// Extracts preprocessor data from a `C/C++` file
/// and inserts these data in a [`PreprocResults`]
/// object shared among threads.
/// and inserts these data in a [`PreprocResults`] object.
///
///
/// [`PreprocResults`]: struct.PreprocResults.html
pub fn preprocess(parser: &PreprocParser, path: &PathBuf, results: Arc<Mutex<PreprocResults>>) {
pub fn preprocess(parser: &PreprocParser, path: &PathBuf, results: &mut PreprocResults) {
let node = parser.get_root();
let mut cursor = node.walk();
let mut stack = Vec::new();
Expand Down Expand Up @@ -238,6 +236,5 @@ pub fn preprocess(parser: &PreprocParser, path: &PathBuf, results: Arc<Mutex<Pre
}
}

let mut results = results.lock().unwrap();
results.files.insert(path.to_path_buf(), file_result);
}