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

Method eager_create_global_struct

src/VariableSelector.cpp:586–615  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

584}
585
586Variable*
587VariableSelector::eager_create_global_struct(Effect::Access access, const CGContext &cg_context,
588 const Type* type, const CVQualifiers* qfer,
589 eMatchType mt, const vector<const Variable*>& invalid_vars)
590{
591 // We will choose a struct with all of its qualifiers.
592 // choose_var() will rule out invalid field vars.
593 assert(type);
594 int level = type->get_indirect_level();
595 const Type *t = 0;
596 if (level == 0) {
597 t = Type::choose_random_struct_from_type(type, false);
598 GenerateNewGlobal(access, cg_context, t, qfer);
599 }
600 else if (level == 1) {
601 t = Type::choose_random_struct_from_type(t->ptr_type, false);
602 if (qfer) {
603 CVQualifiers qfer1 = qfer->indirect_qualifiers(level);
604 GenerateNewGlobal(access, cg_context, t, &qfer1);
605 }
606 else {
607 GenerateNewGlobal(access, cg_context, t, qfer);
608 }
609 }
610 else
611 return NULL;
612
613 ERROR_GUARD(NULL);
614 return choose_var(GlobalList, access, cg_context, type, qfer, mt, invalid_vars);
615}
616
617Variable*
618VariableSelector::eager_create_local_struct(Block &block, Effect::Access access, const CGContext &cg_context,

Callers

nothing calls this directly

Calls 2

indirect_qualifiersMethod · 0.80
get_indirect_levelMethod · 0.45

Tested by

no test coverage detected