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

Method make_random

src/StatementFor.cpp:268–292  ·  view source on GitHub ↗

* Generate a somewhat-trivial `for' loop */

Source from the content-addressed store, hash-verified

266 * Generate a somewhat-trivial `for' loop
267 */
268StatementFor *
269StatementFor::make_random(CGContext &cg_context)
270{
271 FactMgr* fm = get_fact_mgr(&cg_context);
272 assert(fm);
273 cg_context.get_effect_stm().clear();
274
275 StatementAssign* init = NULL;
276 StatementAssign* incr = NULL;
277 Expression* test = NULL;
278 unsigned int bound = 0;
279 const Variable* iv = make_iteration(cg_context, init, test, incr, bound);
280 // record the effect and facts before loop body
281 Effect pre_effects = cg_context.get_effect_stm();
282 vector<const Fact*> pre_facts = fm->global_facts;
283
284 // create CGContext for body
285 CGContext body_cg_context(cg_context, cg_context.rw_directive, iv, bound);
286 Block *body = Block::make_random(body_cg_context, true);
287 ERROR_GUARD_AND_DEL3(NULL, init, test, incr);
288
289 StatementFor* sf = new StatementFor(cg_context.get_current_block(), *init, *test, *incr, *body);
290 sf->post_loop_analysis(cg_context, pre_facts, pre_effects);
291 return sf;
292}
293
294/* generate loop traversing array(s) */
295StatementFor *

Callers

nothing calls this directly

Calls 4

get_fact_mgrFunction · 0.85
get_current_blockMethod · 0.80
post_loop_analysisMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected