MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / is_program_syntax_correct

Method is_program_syntax_correct

src/execution/sanitize.rs:22–38  ·  view source on GitHub ↗

check whether the c program is syntactically and semantically correct.

(&self, program_path: &Path)

Source from the content-addressed store, hash-verified

20impl Executor {
21 /// check whether the c program is syntactically and semantically correct.
22 fn is_program_syntax_correct(&self, program_path: &Path) -> Result<Option<ProgramError>> {
23 let time_logger = TimeUsage::new(get_file_dirname(program_path));
24 let output: std::process::Output = Command::new("clang++")
25 .stdout(Stdio::null())
26 .arg("-fsyntax-only")
27 .arg(&self.header_cmd)
28 .arg(program_path.as_os_str())
29 .output()
30 .expect("failed to execute the syntax check process");
31 time_logger.log("syntax")?;
32 let success = output.status.success();
33 if success {
34 return Ok(None);
35 }
36 let err_msg = String::from_utf8_lossy(&output.stderr).to_string();
37 Ok(Some(ProgramError::Syntax(err_msg)))
38 }
39
40 /// check whether the program is correct in compilation and linkage.
41 fn is_program_link_correct(&self, program_path: &Path) -> Result<Option<ProgramError>> {

Callers 1

Calls 2

get_file_dirnameFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected