1212
1313#include < list>
1414
15- #include " expr.h"
1615#include " expr_cast.h"
1716#include " invariant.h"
17+ #include " std_expr.h"
1818
1919// / Data structure for representing an arbitrary statement in a program. Every
2020// / specific type of statement (e.g. block of statements, assignment,
@@ -338,28 +338,25 @@ inline code_declt &to_code_decl(codet &code)
338338class code_deadt :public codet
339339{
340340public:
341- DEPRECATED (" use code_deadt(symbol) instead" )
342- code_deadt ():codet(ID_dead)
341+ explicit code_deadt (const symbol_exprt &symbol) : codet(ID_dead)
343342 {
344- operands (). resize ( 1 );
343+ add_to_operands (symbol );
345344 }
346345
347- explicit code_deadt ( const exprt &symbol):codet(ID_dead )
346+ symbol_exprt &symbol ( )
348347 {
349- copy_to_operands (symbol );
348+ return static_cast <symbol_exprt &>( op0 () );
350349 }
351350
352- exprt &symbol ()
351+ const symbol_exprt &symbol () const
353352 {
354- return op0 ();
353+ return static_cast < const symbol_exprt &>( op0 () );
355354 }
356355
357- const exprt & symbol () const
356+ const irep_idt & get_identifier () const
358357 {
359- return op0 ();
358+ return symbol (). get_identifier ();
360359 }
361-
362- const irep_idt &get_identifier () const ;
363360};
364361
365362template <> inline bool can_cast_expr<code_deadt>(const exprt &base)
@@ -377,6 +374,9 @@ inline const code_deadt &to_code_dead(const codet &code)
377374 PRECONDITION (code.get_statement () == ID_dead);
378375 DATA_INVARIANT (
379376 code.operands ().size () == 1 , " dead statement must have one operand" );
377+ DATA_INVARIANT (
378+ to_unary_expr (code).op ().id () == ID_symbol,
379+ " dead statement must take symbol operand" );
380380 return static_cast <const code_deadt &>(code);
381381}
382382
@@ -385,6 +385,9 @@ inline code_deadt &to_code_dead(codet &code)
385385 PRECONDITION (code.get_statement () == ID_dead);
386386 DATA_INVARIANT (
387387 code.operands ().size () == 1 , " dead statement must have one operand" );
388+ DATA_INVARIANT (
389+ to_unary_expr (code).op ().id () == ID_symbol,
390+ " dead statement must take symbol operand" );
388391 return static_cast <code_deadt &>(code);
389392}
390393
0 commit comments