Skip to content

Commit 76b2c26

Browse files
committed
Replace make_typecast by typecast_exprt or typecast_exprt::conditional_cast
make_typecast is deprecated.
1 parent 55302b7 commit 76b2c26

30 files changed

+150
-180
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,8 +2166,7 @@ void java_bytecode_convert_methodt::convert_invoke(
21662166
type == java_byte_type() || type == java_short_type() ||
21672167
type.id() == ID_pointer)
21682168
{
2169-
if(type != arguments[i].type())
2170-
arguments[i].make_typecast(type);
2169+
arguments[i] = typecast_exprt::conditional_cast(arguments[i], type);
21712170
}
21722171
}
21732172

jbmc/src/java_bytecode/java_bytecode_instrument.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,7 @@ code_ifthenelset java_bytecode_instrumentt::check_class_cast(
225225
class1, ID_java_instanceof, class2);
226226

227227
pointer_typet voidptr=pointer_type(empty_typet());
228-
exprt null_check_op=class1;
229-
if(null_check_op.type()!=voidptr)
230-
null_check_op.make_typecast(voidptr);
228+
exprt null_check_op = typecast_exprt::conditional_cast(class1, voidptr);
231229

232230
optionalt<codet> check_code;
233231
if(throw_runtime_exceptions)

src/ansi-c/ansi_c_entry_point.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,10 @@ bool generate_ansi_c_start_function(
406406
zero_string.type().subtype()=char_type();
407407
zero_string.type().set(ID_size, "infinity");
408408
const index_exprt index(zero_string, from_integer(0, uint_type()));
409-
exprt address_of=address_of_exprt(index, pointer_type(char_type()));
410-
411-
if(argv_symbol.type.subtype()!=address_of.type())
412-
address_of.make_typecast(argv_symbol.type.subtype());
409+
exprt address_of =
410+
typecast_exprt::conditional_cast(
411+
address_of_exprt(index, pointer_type(char_type())),
412+
argv_symbol.type.subtype());
413413
414414
// assign argv[*] to the address of a string-object
415415
array_of_exprt array_of(address_of, argv_symbol.type);

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2596,10 +2596,11 @@ exprt c_typecheck_baset::do_special_functions(
25962596
throw 0;
25972597
}
25982598

2599-
expr.arguments()[0].make_typecast(bool_typet());
2600-
make_constant(expr.arguments()[0]);
2599+
exprt arg0 =
2600+
typecast_exprt::conditional_cast(expr.arguments()[0], bool_typet());
2601+
make_constant(arg0);
26012602

2602-
if(expr.arguments()[0].is_true())
2603+
if(arg0.is_true())
26032604
return expr.arguments()[1];
26042605
else
26052606
return expr.arguments()[2];
@@ -2953,7 +2954,7 @@ void c_typecheck_baset::typecheck_expr_binary_arithmetic(exprt &expr)
29532954
is_number(o_type1))
29542955
{
29552956
// convert op1 to the vector type
2956-
op1.make_typecast(o_type0);
2957+
op1 = typecast_exprt(op1, o_type0);
29572958
expr.type() = o_type0;
29582959
return;
29592960
}
@@ -2962,7 +2963,7 @@ void c_typecheck_baset::typecheck_expr_binary_arithmetic(exprt &expr)
29622963
is_number(o_type0))
29632964
{
29642965
// convert op0 to the vector type
2965-
op0.make_typecast(o_type1);
2966+
op0 = typecast_exprt(op0, o_type1);
29662967
expr.type() = o_type1;
29672968
return;
29682969
}

src/cpp/cpp_typecheck_conversions.cpp

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ bool cpp_typecheckt::standard_conversion_integral_promotion(
210210
std::size_t width=to_signedbv_type(expr.type()).get_width();
211211
if(width >= config.ansi_c.int_width)
212212
return false;
213-
new_expr=expr;
214-
new_expr.make_typecast(int_type);
213+
new_expr = typecast_exprt::conditional_cast(expr, int_type);
215214
return true;
216215
}
217216

@@ -220,24 +219,21 @@ bool cpp_typecheckt::standard_conversion_integral_promotion(
220219
std::size_t width=to_unsignedbv_type(expr.type()).get_width();
221220
if(width >= config.ansi_c.int_width)
222221
return false;
223-
new_expr=expr;
224222
if(width==config.ansi_c.int_width)
225223
int_type.id(ID_unsignedbv);
226-
new_expr.make_typecast(int_type);
224+
new_expr = typecast_exprt::conditional_cast(expr, int_type);
227225
return true;
228226
}
229227

230228
if(expr.type().id() == ID_bool || expr.type().id() == ID_c_bool)
231229
{
232-
new_expr = expr;
233-
new_expr.make_typecast(int_type);
230+
new_expr = typecast_exprt::conditional_cast(expr, int_type);
234231
return true;
235232
}
236233

237234
if(expr.type().id()==ID_c_enum_tag)
238235
{
239-
new_expr=expr;
240-
new_expr.make_typecast(int_type);
236+
new_expr = typecast_exprt::conditional_cast(expr, int_type);
241237
return true;
242238
}
243239

@@ -271,8 +267,7 @@ bool cpp_typecheckt::standard_conversion_floating_point_promotion(
271267
c_qualifierst qual_from;
272268
qual_from.read(expr.type());
273269

274-
new_expr=expr;
275-
new_expr.make_typecast(double_type());
270+
new_expr = typecast_exprt(expr, double_type());
276271
qual_from.write(new_expr.type());
277272

278273
return true;
@@ -328,8 +323,7 @@ bool cpp_typecheckt::standard_conversion_integral_conversion(
328323

329324
c_qualifierst qual_from;
330325
qual_from.read(expr.type());
331-
new_expr=expr;
332-
new_expr.make_typecast(type);
326+
new_expr = typecast_exprt::conditional_cast(expr, type);
333327
qual_from.write(new_expr.type());
334328

335329
return true;
@@ -382,8 +376,7 @@ bool cpp_typecheckt::standard_conversion_floating_integral_conversion(
382376

383377
c_qualifierst qual_from;
384378
qual_from.read(expr.type());
385-
new_expr=expr;
386-
new_expr.make_typecast(type);
379+
new_expr = typecast_exprt::conditional_cast(expr, type);
387380
qual_from.write(new_expr.type());
388381

389382
return true;
@@ -425,8 +418,7 @@ bool cpp_typecheckt::standard_conversion_floating_point_conversion(
425418
c_qualifierst qual_from;
426419

427420
qual_from.read(expr.type());
428-
new_expr=expr;
429-
new_expr.make_typecast(type);
421+
new_expr = typecast_exprt::conditional_cast(expr, type);
430422
qual_from.write(new_expr.type());
431423

432424
return true;
@@ -508,8 +500,7 @@ bool cpp_typecheckt::standard_conversion_pointer(
508500
{
509501
c_qualifierst qual_from;
510502
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);
513504
qual_from.write(new_expr.type().subtype());
514505
return true;
515506
}
@@ -614,8 +605,7 @@ bool cpp_typecheckt::standard_conversion_pointer_to_member(
614605
if(expr.id()==ID_constant &&
615606
expr.get(ID_value)==ID_NULL)
616607
{
617-
new_expr=expr;
618-
new_expr.make_typecast(type);
608+
new_expr = typecast_exprt::conditional_cast(expr, type);
619609
return true;
620610
}
621611

@@ -627,8 +617,7 @@ bool cpp_typecheckt::standard_conversion_pointer_to_member(
627617

628618
if(subtype_typecast(to_struct, from_struct))
629619
{
630-
new_expr=expr;
631-
new_expr.make_typecast(type);
620+
new_expr = typecast_exprt::conditional_cast(expr, type);
632621
return true;
633622
}
634623

@@ -664,8 +653,7 @@ bool cpp_typecheckt::standard_conversion_boolean(
664653
typet Bool = c_bool_type();
665654
qual_from.write(Bool);
666655

667-
new_expr=expr;
668-
new_expr.make_typecast(Bool);
656+
new_expr = typecast_exprt::conditional_cast(expr, Bool);
669657
return true;
670658
}
671659

@@ -705,7 +693,7 @@ bool cpp_typecheckt::standard_conversion_sequence(
705693

706694
// we turn bit fields into their underlying type
707695
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());
709697

710698
if(curr_expr.type().id()==ID_array)
711699
{
@@ -791,7 +779,7 @@ bool cpp_typecheckt::standard_conversion_sequence(
791779
if(expr.type().subtype().id()==ID_nullptr)
792780
{
793781
// 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);
795783
}
796784
else if(!standard_conversion_pointer(curr_expr, type, new_expr))
797785
{
@@ -1278,7 +1266,7 @@ bool cpp_typecheckt::reference_binding(
12781266
{
12791267
c_qualifierst qual_from;
12801268
qual_from.read(expr.type());
1281-
new_expr.make_typecast(type);
1269+
new_expr = typecast_exprt::conditional_cast(new_expr, type);
12821270
qual_from.write(new_expr.type().subtype());
12831271
}
12841272

@@ -1805,8 +1793,7 @@ bool cpp_typecheckt::reinterpret_typecast(
18051793
(type.id()==ID_unsignedbv || type.id()==ID_signedbv))
18061794
{
18071795
// pointer to integer, always ok
1808-
new_expr=e;
1809-
new_expr.make_typecast(type);
1796+
new_expr = typecast_exprt::conditional_cast(e, type);
18101797
return true;
18111798
}
18121799

@@ -1825,8 +1812,7 @@ bool cpp_typecheckt::reinterpret_typecast(
18251812
}
18261813
else
18271814
{
1828-
new_expr=e;
1829-
new_expr.make_typecast(type);
1815+
new_expr = typecast_exprt::conditional_cast(e, type);
18301816
}
18311817
return true;
18321818
}
@@ -1837,16 +1823,13 @@ bool cpp_typecheckt::reinterpret_typecast(
18371823
{
18381824
// pointer to pointer: we ok it all.
18391825
// 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);
18421827
return true;
18431828
}
18441829

18451830
if(is_reference(type) && e.get_bool(ID_C_lvalue))
18461831
{
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);
18501833
return true;
18511834
}
18521835

@@ -1919,8 +1902,7 @@ bool cpp_typecheckt::static_typecast(
19191902

19201903
if(type.id()==ID_empty)
19211904
{
1922-
new_expr=e;
1923-
new_expr.make_typecast(type);
1905+
new_expr = typecast_exprt::conditional_cast(e, type);
19241906
return true;
19251907
}
19261908

@@ -1930,8 +1912,7 @@ bool cpp_typecheckt::static_typecast(
19301912
e.type().id()==ID_unsignedbv ||
19311913
e.type().id()==ID_c_enum_tag))
19321914
{
1933-
new_expr=e;
1934-
new_expr.make_typecast(type);
1915+
new_expr = typecast_exprt::conditional_cast(e, type);
19351916
new_expr.remove(ID_C_lvalue);
19361917
return true;
19371918
}
@@ -1966,9 +1947,8 @@ bool cpp_typecheckt::static_typecast(
19661947

19671948
if(from.id()==ID_empty)
19681949
{
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;
19721952
}
19731953

19741954
if(to.id()==ID_struct && from.id()==ID_struct)
@@ -2007,8 +1987,7 @@ bool cpp_typecheckt::static_typecast(
20071987

20081988
if(subtype_typecast(from_struct, to_struct))
20091989
{
2010-
new_expr=e;
2011-
new_expr.make_typecast(type);
1990+
new_expr = typecast_exprt::conditional_cast(e, type);
20121991
return true;
20131992
}
20141993
}

src/cpp/cpp_typecheck_initializer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ void cpp_typecheckt::zero_initializer(
296296
const unsignedbv_typet enum_type(
297297
to_bitvector_type(final_type.subtype()).get_width());
298298

299-
exprt zero(from_integer(0, enum_type));
300-
zero.make_typecast(type);
299+
exprt zero =
300+
typecast_exprt::conditional_cast(from_integer(0, enum_type), type);
301301
already_typechecked(zero);
302302

303303
code_assignt assign;

src/cpp/cpp_typecheck_static_assert.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ void cpp_typecheckt::convert(cpp_static_assertt &cpp_static_assert)
1919
typecheck_expr(cpp_static_assert.op0());
2020
typecheck_expr(cpp_static_assert.op1());
2121

22-
cpp_static_assert.op0().make_typecast(bool_typet());
22+
cpp_static_assert.op0() =
23+
typecast_exprt::conditional_cast(cpp_static_assert.op0(), bool_typet());
2324
make_constant(cpp_static_assert.op0());
2425

2526
if(cpp_static_assert.op0().is_true())

src/goto-cc/linker_script_merge.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,7 @@ int linker_script_merget::ls_data2instructions(
576576
unsigned_int_type().get_width()),
577577
unsigned_int_type());
578578

579-
exprt rhs_tc(rhs);
580-
rhs_tc.make_typecast(pointer_type(char_type()));
579+
typecast_exprt rhs_tc(rhs, pointer_type(char_type()));
581580

582581
linker_values.emplace(
583582
irep_idt(d["sym"].value), std::make_pair(lhs, rhs_tc));
@@ -640,8 +639,8 @@ int linker_script_merget::ls_data2instructions(
640639
string2integer(d["val"].value), unsigned_int_type().get_width()));
641640
rhs.type()=unsigned_int_type();
642641
643-
exprt rhs_tc(rhs);
644-
rhs_tc.make_typecast(pointer_type(char_type()));
642+
exprt rhs_tc =
643+
typecast_exprt::conditional_cast(rhs, pointer_type(char_type()));
645644
646645
linker_values.emplace(
647646
irep_idt(d["sym"].value), std::make_pair(lhs, rhs_tc));

src/goto-instrument/goto_program2code.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,7 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast)
18461846

18471847
const typet &t=expr.type();
18481848

1849-
expr.make_typecast(t);
1849+
expr = typecast_exprt(expr, t);
18501850
add_local_types(t);
18511851

18521852
const irep_idt &typedef_str=expr.type().get(ID_C_typedef);
@@ -1944,10 +1944,10 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast)
19441944
else if(expr.type().id()==ID_bool ||
19451945
expr.type().id()==ID_c_bool)
19461946
{
1947-
expr=from_integer(
1948-
expr.is_true()?1:0,
1949-
signedbv_typet(config.ansi_c.int_width));
1950-
expr.make_typecast(bool_typet());
1947+
expr = typecast_exprt(
1948+
from_integer(
1949+
expr.is_true() ? 1 : 0, signedbv_typet(config.ansi_c.int_width)),
1950+
bool_typet());
19511951
}
19521952

19531953
const irept &c_sizeof_type=expr.find(ID_C_c_sizeof_type);

0 commit comments

Comments
 (0)