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

Method change_call_arg

src/program/transform.rs:345–367  ·  view source on GitHub ↗
(&mut self, call: &Node, arg_pos: usize, change_to: &str)

Source from the content-addressed store, hash-verified

343 }
344
345 pub fn change_call_arg(&mut self, call: &Node, arg_pos: usize, change_to: &str) -> Result<()> {
346 if let Clang::CallExpr(ce) = &call.kind {
347 // Cannot proceed macro on AST.
348 if is_macro_stmt(&ce.range) {
349 return Ok(());
350 }
351 let args = ce.get_childs_no_ignore(call);
352 if let Some(arg) = args.get(arg_pos) {
353 if let Clang::CXXDefaultArgExpr = &arg.kind {
354 return Ok(());
355 }
356 if arg.is_macro_expansion() {
357 return Ok(());
358 }
359 let (begin, end) = arg.get_source_range()?;
360 let len = end - begin;
361 self.seek_and_rewrite(begin, len, change_to)?;
362 return Ok(());
363 }
364 eyre::bail!("access arg_pos `{arg_pos}` out of bound: `{}`", args.len())
365 }
366 eyre::bail!("cannot change args for not CallExpr")
367 }
368
369 fn create_string_fuzzer_var(&mut self, str_var: String, ty: &str) -> Result<()> {
370 if ty == "void" {

Callers 5

makeup_call_list_argMethod · 0.80

Calls 5

is_macro_stmtFunction · 0.85
get_childs_no_ignoreMethod · 0.80
is_macro_expansionMethod · 0.80
get_source_rangeMethod · 0.80
seek_and_rewriteMethod · 0.80

Tested by

no test coverage detected