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

Method make_random

src/ExpressionFuncall.cpp:71–101  ·  view source on GitHub ↗

* */

Source from the content-addressed store, hash-verified

69 *
70 */
71Expression *
72ExpressionFuncall::make_random(CGContext &cg_context, const Type* type, const CVQualifiers* qfer)
73{
74 Expression *e = 0;
75 bool std_func = ExpressionFunctionProbability(cg_context);
76 ERROR_GUARD(NULL);
77 // unary/binary "functions" produce scalar types only
78 if (type && (type->eType != eSimple || type->simple_type == eVoid))
79 std_func = false;
80
81 Effect effect_accum = cg_context.get_accum_effect();
82 Effect effect_stm = cg_context.get_effect_stm();
83 FactMgr* fm = get_fact_mgr(&cg_context);
84 vector<const Fact*> facts_copy = fm->global_facts;
85 FunctionInvocation *fi = FunctionInvocation::make_random(std_func, cg_context, type, qfer);
86 ERROR_GUARD(NULL);
87
88 if (fi->failed) {
89 // if it's a invalid invocation, (see FunctionInvocationUser::revisit)
90 // restore the env, and replace invocation with a simple var
91 cg_context.reset_effect_accum(effect_accum);
92 cg_context.reset_effect_stm(effect_stm);
93 fm->restore_facts(facts_copy);
94 e = ExpressionVariable::make_random(cg_context, type, qfer);
95 delete fi;
96 }
97 else {
98 e = new ExpressionFuncall(*fi);
99 }
100 return e;
101}
102
103/*
104 *

Callers

nothing calls this directly

Calls 6

get_fact_mgrFunction · 0.85
get_accum_effectMethod · 0.80
reset_effect_accumMethod · 0.80
reset_effect_stmMethod · 0.80
restore_factsMethod · 0.80

Tested by

no test coverage detected