@@ -1558,25 +1558,34 @@ optionalt<std::string> simplify_exprt::expr2bits(
1558
1558
1559
1559
if (expr.id ()==ID_constant)
1560
1560
{
1561
+ const auto &value = to_constant_expr (expr).get_value ();
1562
+
1561
1563
if (type.id ()==ID_unsignedbv ||
1562
1564
type.id ()==ID_signedbv ||
1563
- type.id ()==ID_c_enum ||
1564
- type.id ()==ID_c_enum_tag ||
1565
1565
type.id ()==ID_floatbv ||
1566
1566
type.id ()==ID_fixedbv)
1567
1567
{
1568
1568
const auto width = to_bitvector_type (type).get_width ();
1569
- const auto &bvrep = to_constant_expr (expr).get_value ();
1570
1569
1571
1570
endianness_mapt map (type, little_endian, ns);
1572
1571
1573
1572
std::string result (width, ' ' );
1574
1573
1575
1574
for (std::string::size_type i = 0 ; i < width; ++i)
1576
- result[map.map_bit (i)] = get_bvrep_bit (bvrep , width, i) ? ' 1' : ' 0' ;
1575
+ result[map.map_bit (i)] = get_bvrep_bit (value , width, i) ? ' 1' : ' 0' ;
1577
1576
1578
1577
return result;
1579
1578
}
1579
+ else if (type.id () == ID_c_enum_tag)
1580
+ {
1581
+ const typet &c_enum_type = ns.follow_tag (to_c_enum_tag_type (type));
1582
+ return expr2bits (constant_exprt (value, c_enum_type), little_endian);
1583
+ }
1584
+ else if (type.id () == ID_c_enum)
1585
+ {
1586
+ return expr2bits (
1587
+ constant_exprt (value, to_c_enum_type (type).subtype (), little_endian);
1588
+ }
1580
1589
}
1581
1590
else if (expr.id ()==ID_union)
1582
1591
{
0 commit comments