MCPcopy Create free account
hub / github.com/csmith-project/csmith / visit_facts

Method visit_facts

src/StatementArrayOp.cpp:292–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292bool
293StatementArrayOp::visit_facts(vector<const Fact*>& inputs, CGContext& cg_context) const
294{
295 // walk the iterations
296 size_t i;
297 for (i=0; i<array_var->get_dimension(); i++) {
298 const Variable *cv = ctrl_vars[i];
299 if (!cg_context.check_write_var(cv, inputs)) {
300 return false;
301 }
302 }
303 FactMgr* fm = get_fact_mgr(&cg_context);
304 // walk the body (if there is one)
305 if (body) {
306 FactVec facts_copy = inputs;
307 Effect eff = cg_context.get_effect_stm();
308 if (!body->visit_facts(inputs, cg_context)) {
309 return false;
310 }
311 // if body must return, means the control reached end of for-loop with pre-loop env
312 if (body->must_return()) {
313 inputs = facts_copy;
314 } else {
315 inputs = fm->map_facts_in[body];
316 }
317 // include the facts from "break" statements
318 // find edges leading to the end of this statement, and merge
319 vector<const CFGEdge*> edges;
320 find_edges_in(edges, true, false);
321 for (i=0; i<edges.size(); i++) {
322 const Statement* src = edges[i]->src;
323 FactMgr::merge_jump_facts(inputs, fm->map_facts_out[src]);
324 }
325 // compute accumulated effect
326 set_accumulated_effect_after_block(eff, body, cg_context);
327 }
328 // walk the initializing value, if this is an array initialization
329 else if (init_value) {
330 Lhs lhs(*array_var);
331 if (!init_value->visit_facts(inputs, cg_context)) {
332 return false;
333 }
334 if (!lhs.visit_facts(inputs, cg_context)) {
335 return false;
336 }
337 FactMgr::update_fact_for_assign(&lhs, init_value, inputs);
338 fm->map_stm_effect[this] = cg_context.get_effect_stm();
339 }
340 return true;
341}
342
343///////////////////////////////////////////////////////////////////////////////
344

Callers 1

Calls 5

get_fact_mgrFunction · 0.85
check_write_varMethod · 0.80
sizeMethod · 0.80
get_dimensionMethod · 0.45
must_returnMethod · 0.45

Tested by

no test coverage detected