@@ -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
@@ -3167,7 +3170,10 @@ void smt2_convt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr)
3167
3170
3168
3171
void smt2_convt::convert_struct (const struct_exprt &expr)
3169
3172
{
3170
- const struct_typet &struct_type = to_struct_type (ns.follow (expr.type ()));
3173
+ const struct_typet &struct_type =
3174
+ expr.type ().id () == ID_struct_tag
3175
+ ? ns.follow_tag (to_struct_tag_type (expr.type ()))
3176
+ : to_struct_type (expr.type ());
3171
3177
3172
3178
const struct_typet::componentst &components=
3173
3179
struct_type.components ();
@@ -3270,10 +3276,9 @@ void smt2_convt::flatten_array(const exprt &expr)
3270
3276
3271
3277
void smt2_convt::convert_union (const union_exprt &expr)
3272
3278
{
3273
- const union_typet &union_type = to_union_type (ns.follow (expr.type ()));
3274
3279
const exprt &op=expr.op ();
3275
3280
3276
- std::size_t total_width= boolbv_width (union_type );
3281
+ std::size_t total_width = boolbv_width (expr. type () );
3277
3282
3278
3283
std::size_t member_width=boolbv_width (op.type ());
3279
3284
@@ -4190,7 +4195,10 @@ void smt2_convt::convert_with(const with_exprt &expr)
4190
4195
}
4191
4196
else if (expr_type.id () == ID_struct || expr_type.id () == ID_struct_tag)
4192
4197
{
4193
- const struct_typet &struct_type = to_struct_type (ns.follow (expr_type));
4198
+ const struct_typet &struct_type =
4199
+ expr_type.id () == ID_struct_tag
4200
+ ? ns.follow_tag (to_struct_tag_type (expr_type))
4201
+ : to_struct_type (expr_type);
4194
4202
4195
4203
const exprt &index = expr.where ();
4196
4204
const exprt &value = expr.new_value ();
@@ -4261,11 +4269,9 @@ void smt2_convt::convert_with(const with_exprt &expr)
4261
4269
}
4262
4270
else if (expr_type.id () == ID_union || expr_type.id () == ID_union_tag)
4263
4271
{
4264
- const union_typet &union_type = to_union_type (ns.follow (expr_type));
4265
-
4266
4272
const exprt &value = expr.new_value ();
4267
4273
4268
- std::size_t total_width= boolbv_width (union_type );
4274
+ std::size_t total_width = boolbv_width (expr_type );
4269
4275
4270
4276
std::size_t member_width=boolbv_width (value.type ());
4271
4277
@@ -4407,7 +4413,10 @@ void smt2_convt::convert_member(const member_exprt &expr)
4407
4413
4408
4414
if (struct_op_type.id () == ID_struct || struct_op_type.id () == ID_struct_tag)
4409
4415
{
4410
- const struct_typet &struct_type = to_struct_type (ns.follow (struct_op_type));
4416
+ const struct_typet &struct_type =
4417
+ struct_op_type.id () == ID_struct_tag
4418
+ ? ns.follow_tag (to_struct_tag_type (struct_op_type))
4419
+ : to_struct_type (struct_op_type);
4411
4420
4412
4421
INVARIANT (
4413
4422
struct_type.has_component (name), " struct should have accessed component" );
@@ -4504,7 +4513,9 @@ void smt2_convt::flatten2bv(const exprt &expr)
4504
4513
if (use_datatypes)
4505
4514
{
4506
4515
// concatenate elements
4507
- const struct_typet &struct_type = to_struct_type (ns.follow (type));
4516
+ const struct_typet &struct_type =
4517
+ type.id () == ID_struct_tag ? ns.follow_tag (to_struct_tag_type (type))
4518
+ : to_struct_type (type);
4508
4519
4509
4520
const struct_typet::componentst &components=
4510
4521
struct_type.components ();
@@ -4630,7 +4641,9 @@ void smt2_convt::unflatten(
4630
4641
4631
4642
out << " (mk-" << smt_typename;
4632
4643
4633
- const struct_typet &struct_type = to_struct_type (ns.follow (type));
4644
+ const struct_typet &struct_type =
4645
+ type.id () == ID_struct_tag ? ns.follow_tag (to_struct_tag_type (type))
4646
+ : to_struct_type (type);
4634
4647
4635
4648
const struct_typet::componentst &components=
4636
4649
struct_type.components ();
@@ -5509,8 +5522,11 @@ void smt2_convt::convert_type(const typet &type)
5509
5522
else if (type.id () == ID_union || type.id () == ID_union_tag)
5510
5523
{
5511
5524
std::size_t width=boolbv_width (type);
5525
+ const union_typet &union_type = type.id () == ID_union_tag
5526
+ ? ns.follow_tag (to_union_tag_type (type))
5527
+ : to_union_type (type);
5512
5528
CHECK_RETURN_WITH_DIAGNOSTICS (
5513
- to_union_type (ns. follow (type)) .components ().empty () || width != 0 ,
5529
+ union_type .components ().empty () || width != 0 ,
5514
5530
" failed to get width of union" );
5515
5531
5516
5532
out << " (_ BitVec " << width << " )" ;
0 commit comments