@@ -22,7 +22,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu
2222// / \param object: non-typechecked object
2323// / \param operands: non-typechecked operands
2424// / \return typechecked code
25- codet cpp_typecheckt::cpp_constructor (
25+ optionalt< codet> cpp_typecheckt::cpp_constructor (
2626 const source_locationt &source_location,
2727 const exprt &object,
2828 const exprt::operandst &operands)
@@ -56,11 +56,7 @@ codet cpp_typecheckt::cpp_constructor(
5656 assert (operands.empty () || operands.size ()==1 );
5757
5858 if (operands.empty () && cpp_is_pod (tmp_type))
59- {
60- codet nil;
61- nil.make_nil ();
62- return nil;
63- }
59+ return {};
6460
6561 const exprt &size_expr=
6662 to_array_type (tmp_type).size ();
@@ -122,16 +118,15 @@ codet cpp_typecheckt::cpp_constructor(
122118 tmp_operands.push_back (operand);
123119 }
124120
125- exprt i_code =
126- cpp_constructor (source_location, index, tmp_operands);
121+ auto i_code = cpp_constructor (source_location, index, tmp_operands);
127122
128- if (i_code.is_nil ())
123+ if (! i_code.has_value ())
129124 {
130125 new_code.is_nil ();
131126 break ;
132127 }
133128
134- new_code.move_to_operands (i_code);
129+ new_code.move (i_code. value () );
135130 }
136131 return new_code;
137132 }
@@ -316,15 +311,14 @@ void cpp_typecheckt::new_temporary(
316311
317312 already_typechecked (new_object);
318313
319- codet new_code =
320- cpp_constructor (source_location, new_object, ops);
314+ auto new_code = cpp_constructor (source_location, new_object, ops);
321315
322- if (new_code.is_not_nil ())
316+ if (new_code.has_value ())
323317 {
324- if (new_code. get (ID_statement)== ID_assign)
325- tmp_object_expr.move_to_operands (new_code. op1 ());
318+ if (new_code-> get_statement () == ID_assign)
319+ tmp_object_expr.move_to_operands (new_code-> op1 ());
326320 else
327- tmp_object_expr.add (ID_initializer)= new_code;
321+ tmp_object_expr.add (ID_initializer) = * new_code;
328322 }
329323
330324 temporary.swap (tmp_object_expr);
0 commit comments