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

Method SelectLType

src/Type.cpp:1636–1671  ·  view source on GitHub ↗

-------------------------------------------------------------- Select a left hand type for assignments ************************************************************/

Source from the content-addressed store, hash-verified

1634 /* Select a left hand type for assignments
1635 ************************************************************/
1636const Type *
1637Type::SelectLType(bool no_volatile, eAssignOps op)
1638{
1639 const Type* type = NULL;
1640 // occasionally we want to play with pointers
1641 // We haven't implemented pointer arith,
1642 // so choose pointer types iff we create simple assignment
1643 // (see Statement::make_random)
1644 if (op == eSimpleAssign && rnd_flipcoin(PointerAsLTypeProb)) {
1645 ERROR_GUARD(NULL);
1646 type = Type::make_random_pointer_type();
1647 }
1648 ERROR_GUARD(NULL);
1649
1650 // choose a struct type as LHS type
1651 if (!type && (op == eSimpleAssign)) {
1652 vector<Type *> ok_struct_types;
1653 get_all_ok_struct_union_types(ok_struct_types, true, no_volatile, false, true);
1654 if ((ok_struct_types.size() > 0) && rnd_flipcoin(StructAsLTypeProb)) {
1655 type = Type::choose_random_struct_union_type(ok_struct_types);
1656 }
1657 }
1658
1659 // choose float as LHS type
1660 if (!type) {
1661 if (StatementAssign::AssignOpWorksForFloat(op) && rnd_flipcoin(FloatAsLTypeProb)) {
1662 type = &Type::get_simple_type(eFloat);
1663 }
1664 }
1665
1666 // default is any integer type
1667 if (!type) {
1668 type = get_int_type();
1669 }
1670 return type;
1671}
1672
1673void
1674Type::get_int_subfield_names(string prefix, vector<string>& names,

Callers

nothing calls this directly

Calls 3

rnd_flipcoinFunction · 0.85
get_int_typeFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected