Skip to content

Commit ab81ffc

Browse files
tautschnigDaniel Kroening
authored and
Daniel Kroening
committed
Replace use of deprecated nil_typet in get_type
Use optionalt<typet> as recommended in the deprecation note.
1 parent ab6abf8 commit ab81ffc

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Diff for: src/goto-programs/builtin_functions.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -260,26 +260,26 @@ void goto_convertt::do_scanf(
260260

261261
for(const auto &t : token_list)
262262
{
263-
typet type=get_type(t);
263+
const auto type = get_type(t);
264264

265-
if(type.is_not_nil())
265+
if(type.has_value())
266266
{
267267
if(argument_number<arguments.size())
268268
{
269269
const typecast_exprt ptr(
270-
arguments[argument_number], pointer_type(type));
270+
arguments[argument_number], pointer_type(*type));
271271
argument_number++;
272272

273-
if(type.id()==ID_array)
273+
if(type->id() == ID_array)
274274
{
275275
#if 0
276276
// A string. We first need a nondeterministic size.
277277
exprt size=side_effect_expr_nondett(size_type());
278-
to_array_type(type).size()=size;
278+
to_array_type(*type).size()=size;
279279

280280
const symbolt &tmp_symbol=
281281
new_tmp_symbol(
282-
type, "scanf_string", dest, function.source_location());
282+
*type, "scanf_string", dest, function.source_location());
283283

284284
const address_of_exprt rhs(
285285
index_exprt(
@@ -298,9 +298,9 @@ void goto_convertt::do_scanf(
298298
copy(array_copy_statement, OTHER, dest);
299299
#else
300300
const index_exprt new_lhs(
301-
dereference_exprt(ptr, type), from_integer(0, index_type()));
301+
dereference_exprt(ptr, *type), from_integer(0, index_type()));
302302
const side_effect_expr_nondett rhs(
303-
type.subtype(), function.source_location());
303+
type->subtype(), function.source_location());
304304
code_assignt assign(new_lhs, rhs);
305305
assign.add_source_location()=function.source_location();
306306
copy(assign, ASSIGN, dest);
@@ -309,9 +309,9 @@ void goto_convertt::do_scanf(
309309
else
310310
{
311311
// make it nondet for now
312-
const dereference_exprt new_lhs(ptr, type);
312+
const dereference_exprt new_lhs(ptr, *type);
313313
const side_effect_expr_nondett rhs(
314-
type, function.source_location());
314+
*type, function.source_location());
315315
code_assignt assign(new_lhs, rhs);
316316
assign.add_source_location()=function.source_location();
317317
copy(assign, ASSIGN, dest);

Diff for: src/goto-programs/format_strings.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ format_token_listt parse_format_string(const std::string &arg_string)
226226
return token_list;
227227
}
228228

229-
typet get_type(const format_tokent &token)
229+
optionalt<typet> get_type(const format_tokent &token)
230230
{
231231
switch(token.type)
232232
{
@@ -291,7 +291,7 @@ typet get_type(const format_tokent &token)
291291
}
292292

293293
default:
294-
return nil_typet();
294+
return {};
295295
}
296296

297297
UNREACHABLE;

Diff for: src/goto-programs/format_strings.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@ typedef std::list<format_tokent> format_token_listt;
8888

8989
format_token_listt parse_format_string(const std::string &);
9090

91-
typet get_type(const format_tokent &);
91+
optionalt<typet> get_type(const format_tokent &);
9292

9393
#endif // CPROVER_GOTO_PROGRAMS_FORMAT_STRINGS_H

0 commit comments

Comments
 (0)