@@ -692,8 +692,9 @@ void value_sett::get_value_set_rec(
692
692
expr.id () == ID_bitnand || expr.id () == ID_bitnor ||
693
693
expr.id () == ID_bitxnor)
694
694
{
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" );
697
698
698
699
object_mapt pointer_expr_set;
699
700
std::optional<mp_integer> i;
@@ -803,8 +804,9 @@ void value_sett::get_value_set_rec(
803
804
// this is to do stuff like
804
805
// (int*)((sel*(ulong)&a)+((sel^0x1)*(ulong)&b))
805
806
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" );
808
810
809
811
object_mapt pointer_expr_set;
810
812
@@ -858,7 +860,7 @@ void value_sett::get_value_set_rec(
858
860
if (statement==ID_function_call)
859
861
{
860
862
// these should be gone
861
- throw " unexpected function_call sideeffect " ;
863
+ UNREACHABLE ;
862
864
}
863
865
else if (statement==ID_allocate)
864
866
{
@@ -876,6 +878,8 @@ void value_sett::get_value_set_rec(
876
878
else if (statement==ID_cpp_new ||
877
879
statement==ID_cpp_new_array)
878
880
{
881
+ // this is rewritten in the front-end, should be gone
882
+ UNREACHABLE;
879
883
PRECONDITION (suffix.empty ());
880
884
PRECONDITION (expr.type ().id () == ID_pointer);
881
885
@@ -1360,9 +1364,6 @@ void value_sett::get_reference_set_rec(
1360
1364
}
1361
1365
else if (expr.id ()==ID_index)
1362
1366
{
1363
- if (expr.operands ().size ()!=2 )
1364
- throw " index expected to have two operands" ;
1365
-
1366
1367
const index_exprt &index_expr=to_index_expr (expr);
1367
1368
const exprt &array=index_expr.array ();
1368
1369
const exprt &offset=index_expr.index ();
@@ -1676,8 +1677,9 @@ void value_sett::assign_rec(
1676
1677
}
1677
1678
else if (lhs.id ()==ID_dereference)
1678
1679
{
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" );
1681
1683
1682
1684
object_mapt reference_set;
1683
1685
get_reference_set (lhs, reference_set, ns);
@@ -1763,7 +1765,7 @@ void value_sett::assign_rec(
1763
1765
// which we don't track
1764
1766
}
1765
1767
else
1766
- throw " assign NYI: '" + lhs.id_string () + " '" ;
1768
+ UNIMPLEMENTED_FEATURE ( " assign NYI: '" + lhs.id_string () + " '" ) ;
1767
1769
}
1768
1770
1769
1771
void value_sett::do_function_call (
@@ -1842,36 +1844,28 @@ void value_sett::apply_code_rec(
1842
1844
}
1843
1845
else if (statement==ID_assign)
1844
1846
{
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 );
1849
1849
}
1850
1850
else if (statement==ID_decl)
1851
1851
{
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 ();
1861
1855
1862
1856
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))
1866
1860
{
1867
1861
// 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))
1869
1863
{
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 );
1872
1866
}
1873
1867
else
1874
- assign (lhs , exprt (ID_invalid), ns, false , false );
1868
+ assign (symbol , exprt (ID_invalid), ns, false , false );
1875
1869
}
1876
1870
}
1877
1871
else if (statement==ID_expression)
@@ -1944,8 +1938,8 @@ void value_sett::apply_code_rec(
1944
1938
}
1945
1939
else
1946
1940
{
1947
- // std::cerr << code.pretty() << '\n';
1948
- throw " value_sett: unexpected statement: " + id2string (statement);
1941
+ UNIMPLEMENTED_FEATURE (
1942
+ " value_sett: unexpected statement: " + id2string (statement) );
1949
1943
}
1950
1944
}
1951
1945
0 commit comments