16
16
#include < util/prefix.h>
17
17
#include < util/arith_tools.h>
18
18
#include < util/ieee_float.h>
19
+ #include < util/expr_util.h>
19
20
20
21
#include < linking/zero_initializer.h>
21
22
33
34
#include < functional>
34
35
#include < unordered_set>
35
36
#include < regex>
36
-
37
- /* ******************************************************************\
38
-
39
- Function: traverse_expr_tree
40
-
41
- Inputs: `expr`: an expression tree to traverse
42
- `parents`: will hold previously-visited nodes
43
- `func`: will be called on each node, takes the node and the `parents`
44
- stack as arguments
45
-
46
- Outputs: None
47
-
48
- Purpose: Abstracts the process of calling a function on each node of the
49
- expression tree.
50
-
51
- \*******************************************************************/
52
-
53
- template <typename Func>
54
- static void traverse_expr_tree (
55
- exprt &expr,
56
- std::vector<exprt*> &parents,
57
- Func func)
58
- {
59
- const auto & parents_ref=parents;
60
- func (expr, parents_ref);
61
-
62
- parents.push_back (&expr);
63
- for (auto &op : expr.operands ())
64
- {
65
- traverse_expr_tree (op, parents, func);
66
- }
67
- parents.pop_back ();
68
- }
37
+ #include < iterator>
69
38
70
39
/* ******************************************************************\
71
40
@@ -83,21 +52,19 @@ Function: traverse_expr_tree
83
52
84
53
static void remove_assert_after_generic_nondet (exprt &expr)
85
54
{
86
- std::vector<exprt*> parents;
87
55
traverse_expr_tree (
88
56
expr,
89
- parents,
90
- [] (exprt &expr, const std::vector<exprt*>& parents)
57
+ [] (exprt &expr, const std::vector<exprt *> &parents)
91
58
{
92
59
const std::regex id_regex (
93
60
" .*org.cprover.CProver.(nondetWithNull|nondetWithoutNull).*" );
94
61
if (expr.id ()==ID_symbol &&
95
- std::regex_match (as_string (to_symbol_expr (expr).get_identifier ()),
62
+ std::regex_match (id2string (to_symbol_expr (expr).get_identifier ()),
96
63
id_regex))
97
64
{
98
65
assert (2 <=parents.size ());
99
- const auto before_1=*(parents.end ()- 1 );
100
- const auto before_2=*(parents.end ()- 2 );
66
+ const auto before_1=*std::prev (parents.end (), 1 );
67
+ const auto before_2=*std::prev (parents.end (), 2 );
101
68
102
69
for (auto it=before_2->operands ().begin (),
103
70
end=before_2->operands ().end ();
@@ -106,11 +73,12 @@ static void remove_assert_after_generic_nondet(exprt &expr)
106
73
{
107
74
if (&(*it)==before_1)
108
75
{
109
- assert (it+1 !=end);
110
- if ((it+1 )->id ()==ID_code &&
111
- to_code (*(it+1 )).get_statement ()==" assert" )
76
+ const auto next_it=std::next (it);
77
+ assert (next_it!=end);
78
+ if (next_it->id ()==ID_code &&
79
+ to_code (*next_it).get_statement ()==" assert" )
112
80
{
113
- *(it+ 1 ) =code_skipt ();
81
+ *next_it =code_skipt ();
114
82
}
115
83
}
116
84
}
@@ -929,11 +897,23 @@ void java_bytecode_convert_methodt::check_static_field_stub(
929
897
}
930
898
}
931
899
932
- static unsigned get_bytecode_type_width (const typet &ty)
900
+ /* ******************************************************************\
901
+
902
+ Function: get_bytecode_type_width
903
+
904
+ Inputs: `type`: A bytecode type.
905
+
906
+ Outputs: The width of the type, in bits.
907
+
908
+ Purpose: Used to check the size of the item on the top of the stack.
909
+
910
+ \*******************************************************************/
911
+
912
+ static unsigned get_bytecode_type_width (const typet &type)
933
913
{
934
- if (ty .id ()==ID_pointer)
914
+ if (type .id ()==ID_pointer)
935
915
return 32 ;
936
- return ty .get_unsigned_int (ID_width);
916
+ return type .get_unsigned_int (ID_width);
937
917
}
938
918
939
919
/* ******************************************************************\
0 commit comments