@@ -210,8 +210,7 @@ bool cpp_typecheckt::standard_conversion_integral_promotion(
210
210
std::size_t width=to_signedbv_type (expr.type ()).get_width ();
211
211
if (width >= config.ansi_c .int_width )
212
212
return false ;
213
- new_expr=expr;
214
- new_expr.make_typecast (int_type);
213
+ new_expr = typecast_exprt::conditional_cast (expr, int_type);
215
214
return true ;
216
215
}
217
216
@@ -220,24 +219,21 @@ bool cpp_typecheckt::standard_conversion_integral_promotion(
220
219
std::size_t width=to_unsignedbv_type (expr.type ()).get_width ();
221
220
if (width >= config.ansi_c .int_width )
222
221
return false ;
223
- new_expr=expr;
224
222
if (width==config.ansi_c .int_width )
225
223
int_type.id (ID_unsignedbv);
226
- new_expr. make_typecast ( int_type);
224
+ new_expr = typecast_exprt::conditional_cast (expr, int_type);
227
225
return true ;
228
226
}
229
227
230
228
if (expr.type ().id () == ID_bool || expr.type ().id () == ID_c_bool)
231
229
{
232
- new_expr = expr;
233
- new_expr.make_typecast (int_type);
230
+ new_expr = typecast_exprt::conditional_cast (expr, int_type);
234
231
return true ;
235
232
}
236
233
237
234
if (expr.type ().id ()==ID_c_enum_tag)
238
235
{
239
- new_expr=expr;
240
- new_expr.make_typecast (int_type);
236
+ new_expr = typecast_exprt::conditional_cast (expr, int_type);
241
237
return true ;
242
238
}
243
239
@@ -271,8 +267,7 @@ bool cpp_typecheckt::standard_conversion_floating_point_promotion(
271
267
c_qualifierst qual_from;
272
268
qual_from.read (expr.type ());
273
269
274
- new_expr=expr;
275
- new_expr.make_typecast (double_type ());
270
+ new_expr = typecast_exprt::conditional_cast (expr, double_type ());
276
271
qual_from.write (new_expr.type ());
277
272
278
273
return true ;
@@ -328,8 +323,7 @@ bool cpp_typecheckt::standard_conversion_integral_conversion(
328
323
329
324
c_qualifierst qual_from;
330
325
qual_from.read (expr.type ());
331
- new_expr=expr;
332
- new_expr.make_typecast (type);
326
+ new_expr = typecast_exprt::conditional_cast (expr, type);
333
327
qual_from.write (new_expr.type ());
334
328
335
329
return true ;
@@ -382,8 +376,7 @@ bool cpp_typecheckt::standard_conversion_floating_integral_conversion(
382
376
383
377
c_qualifierst qual_from;
384
378
qual_from.read (expr.type ());
385
- new_expr=expr;
386
- new_expr.make_typecast (type);
379
+ new_expr = typecast_exprt::conditional_cast (expr, type);
387
380
qual_from.write (new_expr.type ());
388
381
389
382
return true ;
@@ -425,8 +418,7 @@ bool cpp_typecheckt::standard_conversion_floating_point_conversion(
425
418
c_qualifierst qual_from;
426
419
427
420
qual_from.read (expr.type ());
428
- new_expr=expr;
429
- new_expr.make_typecast (type);
421
+ new_expr = typecast_exprt::conditional_cast (expr, type);
430
422
qual_from.write (new_expr.type ());
431
423
432
424
return true ;
@@ -508,8 +500,7 @@ bool cpp_typecheckt::standard_conversion_pointer(
508
500
{
509
501
c_qualifierst qual_from;
510
502
qual_from.read (expr.type ().subtype ());
511
- new_expr=expr;
512
- new_expr.make_typecast (type);
503
+ new_expr = typecast_exprt::conditional_cast (expr, type);
513
504
qual_from.write (new_expr.type ().subtype ());
514
505
return true ;
515
506
}
@@ -614,8 +605,7 @@ bool cpp_typecheckt::standard_conversion_pointer_to_member(
614
605
if (expr.id ()==ID_constant &&
615
606
expr.get (ID_value)==ID_NULL)
616
607
{
617
- new_expr=expr;
618
- new_expr.make_typecast (type);
608
+ new_expr = typecast_exprt::conditional_cast (expr, type);
619
609
return true ;
620
610
}
621
611
@@ -627,8 +617,7 @@ bool cpp_typecheckt::standard_conversion_pointer_to_member(
627
617
628
618
if (subtype_typecast (to_struct, from_struct))
629
619
{
630
- new_expr=expr;
631
- new_expr.make_typecast (type);
620
+ new_expr = typecast_exprt::conditional_cast (expr, type);
632
621
return true ;
633
622
}
634
623
@@ -664,8 +653,7 @@ bool cpp_typecheckt::standard_conversion_boolean(
664
653
typet Bool = c_bool_type ();
665
654
qual_from.write (Bool);
666
655
667
- new_expr=expr;
668
- new_expr.make_typecast (Bool);
656
+ new_expr = typecast_exprt::conditional_cast (expr, Bool);
669
657
return true ;
670
658
}
671
659
@@ -705,7 +693,7 @@ bool cpp_typecheckt::standard_conversion_sequence(
705
693
706
694
// we turn bit fields into their underlying type
707
695
if (curr_expr.type ().id ()==ID_c_bit_field)
708
- curr_expr. make_typecast ( curr_expr.type ().subtype ());
696
+ curr_expr = typecast_exprt (curr_expr, curr_expr.type ().subtype ());
709
697
710
698
if (curr_expr.type ().id ()==ID_array)
711
699
{
@@ -791,7 +779,7 @@ bool cpp_typecheckt::standard_conversion_sequence(
791
779
if (expr.type ().subtype ().id ()==ID_nullptr)
792
780
{
793
781
// std::nullptr_t to _any_ pointer type is ok
794
- new_expr. make_typecast ( type);
782
+ new_expr = typecast_exprt::conditional_cast (new_expr, type);
795
783
}
796
784
else if (!standard_conversion_pointer (curr_expr, type, new_expr))
797
785
{
@@ -1278,7 +1266,7 @@ bool cpp_typecheckt::reference_binding(
1278
1266
{
1279
1267
c_qualifierst qual_from;
1280
1268
qual_from.read (expr.type ());
1281
- new_expr. make_typecast ( type);
1269
+ new_expr = typecast_exprt::conditional_cast (new_expr, type);
1282
1270
qual_from.write (new_expr.type ().subtype ());
1283
1271
}
1284
1272
@@ -1805,8 +1793,7 @@ bool cpp_typecheckt::reinterpret_typecast(
1805
1793
(type.id ()==ID_unsignedbv || type.id ()==ID_signedbv))
1806
1794
{
1807
1795
// pointer to integer, always ok
1808
- new_expr=e;
1809
- new_expr.make_typecast (type);
1796
+ new_expr = typecast_exprt::conditional_cast (e, type);
1810
1797
return true ;
1811
1798
}
1812
1799
@@ -1825,8 +1812,7 @@ bool cpp_typecheckt::reinterpret_typecast(
1825
1812
}
1826
1813
else
1827
1814
{
1828
- new_expr=e;
1829
- new_expr.make_typecast (type);
1815
+ new_expr = typecast_exprt::conditional_cast (e, type);
1830
1816
}
1831
1817
return true ;
1832
1818
}
@@ -1837,16 +1823,13 @@ bool cpp_typecheckt::reinterpret_typecast(
1837
1823
{
1838
1824
// pointer to pointer: we ok it all.
1839
1825
// This is more generous than the standard.
1840
- new_expr=expr;
1841
- new_expr.make_typecast (type);
1826
+ new_expr = typecast_exprt::conditional_cast (expr, type);
1842
1827
return true ;
1843
1828
}
1844
1829
1845
1830
if (is_reference (type) && e.get_bool (ID_C_lvalue))
1846
1831
{
1847
- exprt tmp=address_of_exprt (e);
1848
- tmp.make_typecast (type);
1849
- new_expr.swap (tmp);
1832
+ new_expr = typecast_exprt::conditional_cast (address_of_exprt (e), type);
1850
1833
return true ;
1851
1834
}
1852
1835
@@ -1919,8 +1902,7 @@ bool cpp_typecheckt::static_typecast(
1919
1902
1920
1903
if (type.id ()==ID_empty)
1921
1904
{
1922
- new_expr=e;
1923
- new_expr.make_typecast (type);
1905
+ new_expr = typecast_exprt::conditional_cast (e, type);
1924
1906
return true ;
1925
1907
}
1926
1908
@@ -1930,8 +1912,7 @@ bool cpp_typecheckt::static_typecast(
1930
1912
e.type ().id ()==ID_unsignedbv ||
1931
1913
e.type ().id ()==ID_c_enum_tag))
1932
1914
{
1933
- new_expr=e;
1934
- new_expr.make_typecast (type);
1915
+ new_expr = typecast_exprt::conditional_cast (e, type);
1935
1916
new_expr.remove (ID_C_lvalue);
1936
1917
return true ;
1937
1918
}
@@ -1966,9 +1947,8 @@ bool cpp_typecheckt::static_typecast(
1966
1947
1967
1948
if (from.id ()==ID_empty)
1968
1949
{
1969
- e.make_typecast (type);
1970
- new_expr.swap (e);
1971
- return true ;
1950
+ new_expr = typecast_exprt::conditional_cast (e, type);
1951
+ return true ;
1972
1952
}
1973
1953
1974
1954
if (to.id ()==ID_struct && from.id ()==ID_struct)
@@ -2007,8 +1987,7 @@ bool cpp_typecheckt::static_typecast(
2007
1987
2008
1988
if (subtype_typecast (from_struct, to_struct))
2009
1989
{
2010
- new_expr=e;
2011
- new_expr.make_typecast (type);
1990
+ new_expr = typecast_exprt::conditional_cast (e, type);
2012
1991
return true ;
2013
1992
}
2014
1993
}
0 commit comments