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

Method SelectGlobal

src/VariableSelector.cpp:654–677  ·  view source on GitHub ↗

-------------------------------------------------------------- Select a random global variable.

Source from the content-addressed store, hash-verified

652// --------------------------------------------------------------
653// Select a random global variable.
654Variable *
655VariableSelector::SelectGlobal(Effect::Access access, const CGContext &cg_context, const Type* type, const CVQualifiers* qfer, eMatchType mt, const vector<const Variable*>& invalid_vars)
656{
657 Variable* var = choose_var(GlobalList, access, cg_context, type, qfer, mt, invalid_vars);
658 ERROR_GUARD(NULL);
659 if (var == 0) {
660 if (CGOptions::expand_struct()) {
661 var = VariableSelector::eager_create_global_struct(access, cg_context, type, qfer, mt, invalid_vars);
662 ERROR_GUARD(NULL);
663 if (var)
664 return var;
665 }
666
667 DEPTH_GUARD_BY_TYPE_RETURN(dtSelectGlobal, NULL);
668 bool no_volatile = false;
669 if (qfer && !qfer->wildcard && !qfer->is_volatile()) {
670 no_volatile = true;
671 }
672 const Type* t = Type::random_type_from_type(type, no_volatile);
673 ERROR_GUARD(NULL);
674 return GenerateNewGlobal(access, cg_context, t, qfer);
675 }
676 return var;
677}
678
679void
680VariableSelector::find_all_non_bitfield_visible_vars(const Block *b, vector<Variable*> &vars)

Callers

nothing calls this directly

Calls 1

is_volatileMethod · 0.45

Tested by

no test coverage detected