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

Method get_var_name

src/ast/helper.rs:88–123  ·  view source on GitHub ↗

Get the varialbe name of the given stmt.

(&self)

Source from the content-addressed store, hash-verified

86
87 /// Get the varialbe name of the given stmt.
88 fn get_var_name(&self) -> VarName {
89 let mut worklist = WorkList::new();
90 worklist.push(self);
91 let mut names = vec![];
92 let mut kinds = vec![];
93 let mut ids = vec![];
94 while !worklist.empty() {
95 let curr = worklist.pop();
96 if let Clang::DeclRefExpr(dre) = &curr.kind {
97 if let clang_ast::Kind::EnumConstantDecl = dre.referenced_decl.kind {
98 continue;
99 }
100 names.push(dre.get_name_as_string());
101 kinds.push(VarKind::Base);
102 ids.push(dre.referenced_decl.id);
103 }
104 if let Clang::ArraySubscriptExpr(ase) = &curr.kind {
105 names.push("i".to_owned());
106 kinds.push(VarKind::Arrary);
107 ids.push(curr.id);
108 worklist.push(ase.get_lhs(curr));
109 continue;
110 }
111 if let Clang::MemberExpr(me) = &curr.kind {
112 let name = me.get_name_as_string();
113 names.push(name);
114 // Currently only retain the member relationship, ignore the "is_arrow" attribute.
115 kinds.push(VarKind::Member);
116 ids.push(curr.id);
117 }
118 for child in &curr.inner {
119 worklist.push(child);
120 }
121 }
122 VarName::from_vec(names, kinds, ids)
123 }
124
125 fn is_call(&self) -> bool {
126 matches!(&self.ignore_cast().kind, Clang::CallExpr(_))

Callers 4

adg_precallMethod · 0.80
fdsan_precallFunction · 0.80
visit_binary_operatorMethod · 0.80
get_rvalueMethod · 0.80

Calls 5

emptyMethod · 0.80
popMethod · 0.80
get_name_as_stringMethod · 0.80
get_lhsMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected