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

Method find_vardecl

src/ast/visitor.rs:125–145  ·  view source on GitHub ↗
(&self, var_name: &str)

Source from the content-addressed store, hash-verified

123 }
124
125 pub fn find_vardecl(&self, var_name: &str) -> Option<&Node> {
126 let mut worklist = WorkList::new();
127 worklist.push(&self.ast);
128 while !worklist.empty() {
129 let curr = worklist.pop();
130 if let Clang::VarDecl(vd) = &curr.kind {
131 let name = vd.get_name_as_string();
132 if name == var_name {
133 return Some(curr);
134 }
135 }
136 if let Clang::ParmVarDecl(pvd) = &curr.kind {
137 let name = pvd.get_name_as_string();
138 if name == var_name {
139 return Some(curr);
140 }
141 }
142 worklist.push_childs(curr.get_childs());
143 }
144 None
145 }
146
147 pub fn find_binary_operator(&self, var_name: &str) -> Option<&Node> {
148 let mut worklist = WorkList::new();

Callers 4

get_var_declMethod · 0.80
get_var_initMethod · 0.80
is_format_stringFunction · 0.80
is_sizeof_expr_of_varFunction · 0.80

Calls 6

emptyMethod · 0.80
popMethod · 0.80
get_name_as_stringMethod · 0.80
push_childsMethod · 0.80
pushMethod · 0.45
get_childsMethod · 0.45

Tested by

no test coverage detected