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

Method eager_create_local_struct

src/VariableSelector.cpp:617–649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

615}
616
617Variable*
618VariableSelector::eager_create_local_struct(Block &block, Effect::Access access, const CGContext &cg_context,
619 const Type* type, const CVQualifiers* qfer,
620 eMatchType mt, const vector<const Variable*>& invalid_vars)
621{
622 // We will choose a struct with all of its qualifiers.
623 // choose_var() will rule out invalid field vars.
624 assert(type);
625 int level = type->get_indirect_level();
626 const Type *t = 0;
627 if (level == 0) {
628 t = Type::choose_random_struct_from_type(type, true);
629 GenerateNewParentLocal(block, access, cg_context, t, qfer);
630 }
631 else if (level == 1) {
632 t = Type::choose_random_struct_from_type(t->ptr_type, true);
633 if (qfer) {
634 CVQualifiers qfer1 = qfer->indirect_qualifiers(level);
635 GenerateNewParentLocal(block, access, cg_context, t, &qfer1);
636 }
637 else {
638 GenerateNewParentLocal(block, access, cg_context, t, qfer);
639 }
640 }
641 else
642 return NULL;
643 ERROR_GUARD(NULL);
644 if (!t)
645 return NULL;
646
647 ERROR_GUARD(NULL);
648 return choose_var(block.local_vars, access, cg_context, type, qfer, mt, invalid_vars);
649}
650
651
652// --------------------------------------------------------------

Callers

nothing calls this directly

Calls 2

indirect_qualifiersMethod · 0.80
get_indirect_levelMethod · 0.45

Tested by

no test coverage detected