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

Method get_function_body_begin_loc

src/ast/visitor.rs:305–318  ·  view source on GitHub ↗

Get begin location of function body, where suitable to insert any VarDecl.

(&self)

Source from the content-addressed store, hash-verified

303
304 /// Get begin location of function body, where suitable to insert any VarDecl.
305 pub fn get_function_body_begin_loc(&self) -> Result<usize> {
306 let mut worklist = WorkList::new();
307 worklist.push(&self.ast);
308 while !worklist.empty() {
309 let curr = worklist.pop();
310 if let Clang::CompoundStmt(cs) = &curr.kind {
311 let begin = get_sr_begin_loc(&cs.range)?;
312 let begin_loc = begin.offset + begin.tok_len;
313 return Ok(begin_loc);
314 }
315 worklist.push_childs(curr.get_childs());
316 }
317 eyre::bail!("Cannot found suitable location to insert vardecl")
318 }
319
320 /// get this var node in the updated ast.
321 pub fn get_var_node(&self, node: &Node) -> Result<&Node> {

Callers 5

handle_set_jumpMethod · 0.80
change_fd_paramsMethod · 0.80

Calls 6

get_sr_begin_locFunction · 0.85
emptyMethod · 0.80
popMethod · 0.80
push_childsMethod · 0.80
pushMethod · 0.45
get_childsMethod · 0.45

Tested by

no test coverage detected