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

Function eliminate_irrelative_ast

src/execution/ast.rs:145–162  ·  view source on GitHub ↗

elimitate the irrelative asts that included in this file.

(ast: &'a mut Node, headers: &Vec<PathBuf>)

Source from the content-addressed store, hash-verified

143
144/// elimitate the irrelative asts that included in this file.
145fn eliminate_irrelative_ast<'a>(ast: &'a mut Node, headers: &Vec<PathBuf>) -> &'a Node {
146 ast.inner.retain_mut(|child| match &child.kind {
147 Clang::EnumDecl(el) => is_defined_in_headers(&el.loc, headers),
148 Clang::FunctionDecl(fd) => is_defined_in_headers(&fd.loc, headers),
149 Clang::RecordDecl(rd) => is_defined_in_headers(&rd.loc, headers),
150 Clang::CXXRecordDecl(crd) => is_defined_in_headers(&crd.loc, headers),
151 Clang::TypedefDecl(td) => is_defined_in_headers(&td.loc, headers),
152 Clang::LinkageSpecDecl(lsd) => {
153 if is_defined_in_headers(&lsd.loc, headers) {
154 eliminate_irrelative_ast(child, headers);
155 return true;
156 }
157 false
158 }
159 _ => false,
160 });
161 ast
162}
163
164/// whether the ast element is definied inside the header file
165fn is_defined_in_headers(loc: &SourceLocation, headers: &Vec<PathBuf>) -> bool {

Callers 1

parse_header_astMethod · 0.85

Calls 1

is_defined_in_headersFunction · 0.85

Tested by

no test coverage detected