@@ -692,8 +692,9 @@ void value_sett::get_value_set_rec(
692692 expr.id () == ID_bitnand || expr.id () == ID_bitnor ||
693693 expr.id () == ID_bitxnor)
694694 {
695- if (expr.operands ().size ()<2 )
696- throw expr.id_string ()+" expected to have at least two operands" ;
695+ DATA_INVARIANT (
696+ expr.operands ().size () >= 2 ,
697+ expr.id_string () + " expected to have at least two operands" );
697698
698699 object_mapt pointer_expr_set;
699700 std::optional<mp_integer> i;
@@ -803,8 +804,9 @@ void value_sett::get_value_set_rec(
803804 // this is to do stuff like
804805 // (int*)((sel*(ulong)&a)+((sel^0x1)*(ulong)&b))
805806
806- if (expr.operands ().size ()<2 )
807- throw expr.id_string ()+" expected to have at least two operands" ;
807+ DATA_INVARIANT (
808+ expr.operands ().size () >= 2 ,
809+ expr.id_string () + " expected to have at least two operands" );
808810
809811 object_mapt pointer_expr_set;
810812
@@ -858,7 +860,7 @@ void value_sett::get_value_set_rec(
858860 if (statement==ID_function_call)
859861 {
860862 // these should be gone
861- throw " unexpected function_call sideeffect " ;
863+ UNREACHABLE ;
862864 }
863865 else if (statement==ID_allocate)
864866 {
@@ -876,6 +878,8 @@ void value_sett::get_value_set_rec(
876878 else if (statement==ID_cpp_new ||
877879 statement==ID_cpp_new_array)
878880 {
881+ // this is rewritten in the front-end, should be gone
882+ UNREACHABLE;
879883 PRECONDITION (suffix.empty ());
880884 PRECONDITION (expr.type ().id () == ID_pointer);
881885
@@ -1360,9 +1364,6 @@ void value_sett::get_reference_set_rec(
13601364 }
13611365 else if (expr.id ()==ID_index)
13621366 {
1363- if (expr.operands ().size ()!=2 )
1364- throw " index expected to have two operands" ;
1365-
13661367 const index_exprt &index_expr=to_index_expr (expr);
13671368 const exprt &array=index_expr.array ();
13681369 const exprt &offset=index_expr.index ();
@@ -1676,8 +1677,9 @@ void value_sett::assign_rec(
16761677 }
16771678 else if (lhs.id ()==ID_dereference)
16781679 {
1679- if (lhs.operands ().size ()!=1 )
1680- throw lhs.id_string ()+" expected to have one operand" ;
1680+ DATA_INVARIANT (
1681+ lhs.operands ().size () == 1 ,
1682+ lhs.id_string () + " expected to have one operand" );
16811683
16821684 object_mapt reference_set;
16831685 get_reference_set (lhs, reference_set, ns);
@@ -1763,7 +1765,7 @@ void value_sett::assign_rec(
17631765 // which we don't track
17641766 }
17651767 else
1766- throw " assign NYI: '" + lhs.id_string () + " '" ;
1768+ UNIMPLEMENTED_FEATURE ( " assign NYI: '" + lhs.id_string () + " '" ) ;
17671769}
17681770
17691771void value_sett::do_function_call (
@@ -1842,36 +1844,28 @@ void value_sett::apply_code_rec(
18421844 }
18431845 else if (statement==ID_assign)
18441846 {
1845- if (code.operands ().size ()!=2 )
1846- throw " assignment expected to have two operands" ;
1847-
1848- assign (code.op0 (), code.op1 (), ns, false , false );
1847+ const code_assignt &a = to_code_assign (code);
1848+ assign (a.lhs (), a.rhs (), ns, false , false );
18491849 }
18501850 else if (statement==ID_decl)
18511851 {
1852- if (code.operands ().size ()!=1 )
1853- throw " decl expected to have one operand" ;
1854-
1855- const exprt &lhs=code.op0 ();
1856-
1857- if (lhs.id ()!=ID_symbol)
1858- throw " decl expected to have symbol on lhs" ;
1859-
1860- const typet &lhs_type = lhs.type ();
1852+ const code_declt &decl = to_code_decl (code);
1853+ const symbol_exprt &symbol = decl.symbol ();
1854+ const typet &symbol_type = symbol.type ();
18611855
18621856 if (
1863- lhs_type .id () == ID_pointer ||
1864- (lhs_type .id () == ID_array &&
1865- to_array_type (lhs_type ).element_type ().id () == ID_pointer))
1857+ symbol_type .id () == ID_pointer ||
1858+ (symbol_type .id () == ID_array &&
1859+ to_array_type (symbol_type ).element_type ().id () == ID_pointer))
18661860 {
18671861 // assign the address of the failed object
1868- if (auto failed = get_failed_symbol (to_symbol_expr (lhs) , ns))
1862+ if (auto failed = get_failed_symbol (symbol , ns))
18691863 {
1870- address_of_exprt address_of_expr (*failed, to_pointer_type (lhs. type () ));
1871- assign (lhs , address_of_expr, ns, false , false );
1864+ address_of_exprt address_of_expr (*failed, to_pointer_type (symbol_type ));
1865+ assign (symbol , address_of_expr, ns, false , false );
18721866 }
18731867 else
1874- assign (lhs , exprt (ID_invalid), ns, false , false );
1868+ assign (symbol , exprt (ID_invalid), ns, false , false );
18751869 }
18761870 }
18771871 else if (statement==ID_expression)
@@ -1944,8 +1938,8 @@ void value_sett::apply_code_rec(
19441938 }
19451939 else
19461940 {
1947- // std::cerr << code.pretty() << '\n';
1948- throw " value_sett: unexpected statement: " + id2string (statement);
1941+ UNIMPLEMENTED_FEATURE (
1942+ " value_sett: unexpected statement: " + id2string (statement) );
19491943 }
19501944}
19511945
0 commit comments