Skip to content

Commit 7e8ecdc

Browse files
committed
Revert "Try to keep struct and SMTLIB data types in sync"
This reverts commit 0ba0d32.
1 parent 8c7ef17 commit 7e8ecdc

File tree

1 file changed

+19
-38
lines changed

1 file changed

+19
-38
lines changed

src/solvers/smt2/smt2_conv.cpp

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -612,14 +612,21 @@ smt2_convt::parse_struct(const irept &src, const struct_typet &type)
612612
{
613613
// Structs look like:
614614
// (mk-struct.1 <component0> <component1> ... <componentN>)
615-
616-
if(src.get_sub().size()!=components.size()+1)
617-
return result; // give up
618-
615+
std::size_t j = 1;
619616
for(std::size_t i=0; i<components.size(); i++)
620617
{
621618
const struct_typet::componentt &c=components[i];
622-
result.operands()[i]=parse_rec(src.get_sub()[i+1], c.type());
619+
if(is_zero_width(components[i].type(), ns))
620+
{
621+
result.operands()[i] = nil_exprt{};
622+
}
623+
else
624+
{
625+
DATA_INVARIANT(
626+
src.get_sub().size() > j, "insufficient number of component values");
627+
result.operands()[i] = parse_rec(src.get_sub()[j], c.type());
628+
++j;
629+
}
623630
}
624631
}
625632
else
@@ -3218,6 +3225,8 @@ void smt2_convt::convert_struct(const struct_exprt &expr)
32183225
"number of struct components as indicated by the struct type shall be equal"
32193226
"to the number of operands of the struct expression");
32203227

3228+
DATA_INVARIANT(!components.empty(), "struct shall have struct components");
3229+
32213230
if(use_datatypes)
32223231
{
32233232
const std::string &smt_typename = datatype_map.at(struct_type);
@@ -3231,29 +3240,16 @@ void smt2_convt::convert_struct(const struct_exprt &expr)
32313240
it!=components.end();
32323241
it++, i++)
32333242
{
3234-
if(
3235-
it->type().id() != ID_struct_tag && it->type().id() != ID_struct &&
3236-
is_zero_width(it->type(), ns))
3237-
{
3243+
if(is_zero_width(it->type(), ns))
32383244
continue;
3239-
}
3240-
32413245
out << " ";
32423246
convert_expr(expr.operands()[i]);
32433247
}
32443248

3245-
if(components.empty())
3246-
{
3247-
out << " ";
3248-
convert_expr(from_integer(0, unsignedbv_typet{1}));
3249-
}
3250-
32513249
out << ")";
32523250
}
32533251
else
32543252
{
3255-
DATA_INVARIANT(!components.empty(), "struct shall have struct components");
3256-
32573253
if(components.size()==1)
32583254
{
32593255
const exprt &op = expr.op0();
@@ -4907,6 +4903,9 @@ void smt2_convt::unflatten(
49074903
it!=components.end();
49084904
it++, i++)
49094905
{
4906+
if(is_zero_width(it->type(), ns))
4907+
continue;
4908+
49104909
std::size_t member_width=boolbv_width(it->type());
49114910

49124911
out << " ";
@@ -4917,12 +4916,6 @@ void smt2_convt::unflatten(
49174916
offset+=member_width;
49184917
}
49194918

4920-
if(components.empty())
4921-
{
4922-
out << " ";
4923-
convert_expr(from_integer(0, unsignedbv_typet{1}));
4924-
}
4925-
49264919
out << "))"; // mk-, let
49274920
}
49284921
}
@@ -5947,27 +5940,15 @@ void smt2_convt::find_symbols_rec(
59475940

59485941
for(const auto &component : components)
59495942
{
5950-
if(
5951-
component.type().id() != ID_struct_tag &&
5952-
component.type().id() != ID_struct &&
5953-
is_zero_width(component.type(), ns))
5954-
{
5943+
if(is_zero_width(component.type(), ns))
59555944
continue;
5956-
}
59575945

59585946
out << "(" << smt_typename << "." << component.get_name()
59595947
<< " ";
59605948
convert_type(component.type());
59615949
out << ") ";
59625950
}
59635951

5964-
if(components.empty())
5965-
{
5966-
out << "(" << smt_typename << ".0 ";
5967-
convert_type(unsignedbv_typet{1});
5968-
out << ") ";
5969-
}
5970-
59715952
out << "))))" << "\n";
59725953

59735954
// Let's also declare convenience functions to update individual

0 commit comments

Comments
 (0)