mark any local variable in point_to_vars as dead, note this create a new fact, and if no local variable is in point-to set, return null to indicate no update is neccessary */
| 138 | point-to set, return null to indicate no update is neccessary |
| 139 | */ |
| 140 | FactPointTo* |
| 141 | FactPointTo::mark_func_end(const Statement* stm) |
| 142 | { |
| 143 | vector<const Variable*> var_set = point_to_vars; |
| 144 | size_t len = var_set.size(); |
| 145 | bool changed = false; |
| 146 | bool has_garbage_ptr = (find_variable_in_set(var_set, garbage_ptr) >= 0); |
| 147 | const Function* func = stm->func; |
| 148 | |
| 149 | for (size_t i=0; i<len; i++) { |
| 150 | const Variable* v = var_set[i]; |
| 151 | if (func->is_var_on_stack(v, stm)) { |
| 152 | if (has_garbage_ptr) { |
| 153 | var_set.erase(var_set.begin() + i); |
| 154 | i--; |
| 155 | len--; |
| 156 | } |
| 157 | else { |
| 158 | var_set[i] = garbage_ptr; |
| 159 | has_garbage_ptr = true; |
| 160 | } |
| 161 | changed = true; |
| 162 | } |
| 163 | } |
| 164 | if (changed) { |
| 165 | return FactPointTo::make_fact(var, var_set); |
| 166 | } |
| 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | int |
| 171 | FactPointTo::size() const |
no test coverage detected