Skip to content

Commit e17eb29

Browse files
committed
Replace use of deprecated nil_typet in c_bit_field_replacement_type
Use optionalt<typet> as recommended in the deprecation note.
1 parent 7ffaaec commit e17eb29

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

src/solvers/flattening/boolbv_typecast.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,18 @@ bool boolbvt::type_conversion(
3838
bvtypet src_bvtype=get_bvtype(src_type);
3939

4040
if(src_bvtype==bvtypet::IS_C_BIT_FIELD)
41-
return
42-
type_conversion(
43-
c_bit_field_replacement_type(to_c_bit_field_type(src_type), ns),
44-
src,
45-
dest_type,
46-
dest);
41+
return type_conversion(
42+
*c_bit_field_replacement_type(to_c_bit_field_type(src_type), ns),
43+
src,
44+
dest_type,
45+
dest);
4746

4847
if(dest_bvtype==bvtypet::IS_C_BIT_FIELD)
49-
return
50-
type_conversion(
51-
src_type,
52-
src,
53-
c_bit_field_replacement_type(to_c_bit_field_type(dest_type), ns),
54-
dest);
48+
return type_conversion(
49+
src_type,
50+
src,
51+
*c_bit_field_replacement_type(to_c_bit_field_type(dest_type), ns),
52+
dest);
5553

5654
std::size_t src_width=src.size();
5755
std::size_t dest_width=boolbv_width(dest_type);

src/solvers/flattening/c_bit_field_replacement_type.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ Author: Daniel Kroening, [email protected]
99

1010
#include "c_bit_field_replacement_type.h"
1111

12-
typet c_bit_field_replacement_type(
13-
const c_bit_field_typet &src,
14-
const namespacet &ns)
12+
#include <util/namespace.h>
13+
14+
optionalt<typet>
15+
c_bit_field_replacement_type(const c_bit_field_typet &src, const namespacet &ns)
1516
{
1617
const typet &subtype=src.subtype();
1718

@@ -35,9 +36,7 @@ typet c_bit_field_replacement_type(
3536
result.set_width(src.get_width());
3637
return std::move(result);
3738
}
38-
else
39-
return nil_typet();
4039
}
41-
else
42-
return nil_typet();
40+
41+
return {};
4342
}

src/solvers/flattening/c_bit_field_replacement_type.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ Author: Daniel Kroening, [email protected]
1010
#ifndef CPROVER_SOLVERS_FLATTENING_C_BIT_FIELD_REPLACEMENT_TYPE_H
1111
#define CPROVER_SOLVERS_FLATTENING_C_BIT_FIELD_REPLACEMENT_TYPE_H
1212

13+
#include <util/optional.h>
1314
#include <util/std_types.h>
14-
#include <util/namespace.h>
1515

16-
typet c_bit_field_replacement_type(
17-
const c_bit_field_typet &,
18-
const namespacet &);
16+
class namespacet;
17+
18+
optionalt<typet>
19+
c_bit_field_replacement_type(const c_bit_field_typet &, const namespacet &);
1920

2021
#endif // CPROVER_SOLVERS_FLATTENING_C_BIT_FIELD_REPLACEMENT_TYPE_H

src/solvers/smt2/smt2_conv.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,8 +2176,9 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr)
21762176
convert_expr(src); // ignore
21772177
else
21782178
{
2179-
typet t=c_bit_field_replacement_type(to_c_bit_field_type(src_type), ns);
2180-
typecast_exprt tmp(typecast_exprt(src, t), dest_type);
2179+
const auto t =
2180+
c_bit_field_replacement_type(to_c_bit_field_type(src_type), ns);
2181+
typecast_exprt tmp(typecast_exprt(src, *t), dest_type);
21812182
convert_typecast(tmp);
21822183
}
21832184
}
@@ -2416,8 +2417,9 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr)
24162417
convert_expr(src); // ignore
24172418
else
24182419
{
2419-
typet t=c_bit_field_replacement_type(to_c_bit_field_type(dest_type), ns);
2420-
typecast_exprt tmp(typecast_exprt(src, t), dest_type);
2420+
const auto t =
2421+
c_bit_field_replacement_type(to_c_bit_field_type(dest_type), ns);
2422+
typecast_exprt tmp(typecast_exprt(src, *t), dest_type);
24212423
convert_typecast(tmp);
24222424
}
24232425
}
@@ -4527,7 +4529,7 @@ void smt2_convt::convert_type(const typet &type)
45274529
}
45284530
else if(type.id()==ID_c_bit_field)
45294531
{
4530-
convert_type(c_bit_field_replacement_type(to_c_bit_field_type(type), ns));
4532+
convert_type(*c_bit_field_replacement_type(to_c_bit_field_type(type), ns));
45314533
}
45324534
else
45334535
{

0 commit comments

Comments
 (0)