@@ -846,7 +846,10 @@ void smt2_convt::convert_address_of_rec(
846
846
struct_op_type.id () == ID_struct || struct_op_type.id () == ID_struct_tag,
847
847
" member expression operand shall have struct type" );
848
848
849
- const struct_typet &struct_type = to_struct_type (ns.follow (struct_op_type));
849
+ const struct_typet &struct_type =
850
+ struct_op_type.id () == ID_struct_tag
851
+ ? ns.follow_tag (to_struct_tag_type (struct_op_type))
852
+ : to_struct_type (struct_op_type);
850
853
851
854
const irep_idt &component_name = member_expr.get_component_name ();
852
855
@@ -3159,7 +3162,10 @@ void smt2_convt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr)
3159
3162
3160
3163
void smt2_convt::convert_struct (const struct_exprt &expr)
3161
3164
{
3162
- const struct_typet &struct_type = to_struct_type (ns.follow (expr.type ()));
3165
+ const struct_typet &struct_type =
3166
+ expr.type ().id () == ID_struct_tag
3167
+ ? ns.follow_tag (to_struct_tag_type (expr.type ()))
3168
+ : to_struct_type (expr.type ());
3163
3169
3164
3170
const struct_typet::componentst &components=
3165
3171
struct_type.components ();
@@ -3262,10 +3268,9 @@ void smt2_convt::flatten_array(const exprt &expr)
3262
3268
3263
3269
void smt2_convt::convert_union (const union_exprt &expr)
3264
3270
{
3265
- const union_typet &union_type = to_union_type (ns.follow (expr.type ()));
3266
3271
const exprt &op=expr.op ();
3267
3272
3268
- std::size_t total_width= boolbv_width (union_type );
3273
+ std::size_t total_width = boolbv_width (expr. type () );
3269
3274
3270
3275
std::size_t member_width=boolbv_width (op.type ());
3271
3276
@@ -4182,7 +4187,10 @@ void smt2_convt::convert_with(const with_exprt &expr)
4182
4187
}
4183
4188
else if (expr_type.id () == ID_struct || expr_type.id () == ID_struct_tag)
4184
4189
{
4185
- const struct_typet &struct_type = to_struct_type (ns.follow (expr_type));
4190
+ const struct_typet &struct_type =
4191
+ expr_type.id () == ID_struct_tag
4192
+ ? ns.follow_tag (to_struct_tag_type (expr_type))
4193
+ : to_struct_type (expr_type);
4186
4194
4187
4195
const exprt &index = expr.where ();
4188
4196
const exprt &value = expr.new_value ();
@@ -4253,11 +4261,9 @@ void smt2_convt::convert_with(const with_exprt &expr)
4253
4261
}
4254
4262
else if (expr_type.id () == ID_union || expr_type.id () == ID_union_tag)
4255
4263
{
4256
- const union_typet &union_type = to_union_type (ns.follow (expr_type));
4257
-
4258
4264
const exprt &value = expr.new_value ();
4259
4265
4260
- std::size_t total_width= boolbv_width (union_type );
4266
+ std::size_t total_width = boolbv_width (expr_type );
4261
4267
4262
4268
std::size_t member_width=boolbv_width (value.type ());
4263
4269
@@ -4399,7 +4405,10 @@ void smt2_convt::convert_member(const member_exprt &expr)
4399
4405
4400
4406
if (struct_op_type.id () == ID_struct || struct_op_type.id () == ID_struct_tag)
4401
4407
{
4402
- const struct_typet &struct_type = to_struct_type (ns.follow (struct_op_type));
4408
+ const struct_typet &struct_type =
4409
+ struct_op_type.id () == ID_struct_tag
4410
+ ? ns.follow_tag (to_struct_tag_type (struct_op_type))
4411
+ : to_struct_type (struct_op_type);
4403
4412
4404
4413
INVARIANT (
4405
4414
struct_type.has_component (name), " struct should have accessed component" );
@@ -4496,7 +4505,9 @@ void smt2_convt::flatten2bv(const exprt &expr)
4496
4505
if (use_datatypes)
4497
4506
{
4498
4507
// concatenate elements
4499
- const struct_typet &struct_type = to_struct_type (ns.follow (type));
4508
+ const struct_typet &struct_type =
4509
+ type.id () == ID_struct_tag ? ns.follow_tag (to_struct_tag_type (type))
4510
+ : to_struct_type (type);
4500
4511
4501
4512
const struct_typet::componentst &components=
4502
4513
struct_type.components ();
@@ -4622,7 +4633,9 @@ void smt2_convt::unflatten(
4622
4633
4623
4634
out << " (mk-" << smt_typename;
4624
4635
4625
- const struct_typet &struct_type = to_struct_type (ns.follow (type));
4636
+ const struct_typet &struct_type =
4637
+ type.id () == ID_struct_tag ? ns.follow_tag (to_struct_tag_type (type))
4638
+ : to_struct_type (type);
4626
4639
4627
4640
const struct_typet::componentst &components=
4628
4641
struct_type.components ();
@@ -5501,8 +5514,11 @@ void smt2_convt::convert_type(const typet &type)
5501
5514
else if (type.id () == ID_union || type.id () == ID_union_tag)
5502
5515
{
5503
5516
std::size_t width=boolbv_width (type);
5517
+ const union_typet &union_type = type.id () == ID_union_tag
5518
+ ? ns.follow_tag (to_union_tag_type (type))
5519
+ : to_union_type (type);
5504
5520
CHECK_RETURN_WITH_DIAGNOSTICS (
5505
- to_union_type (ns. follow (type)) .components ().empty () || width != 0 ,
5521
+ union_type .components ().empty () || width != 0 ,
5506
5522
" failed to get width of union" );
5507
5523
5508
5524
out << " (_ BitVec " << width << " )" ;
0 commit comments