File tree Expand file tree Collapse file tree 4 files changed +26
-19
lines changed Expand file tree Collapse file tree 4 files changed +26
-19
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ complexity_limitert::check_complexity(goto_symex_statet &state)
136
136
if (!complexity_limits_active () || !state.reachable )
137
137
return complexity_violationt::NONE;
138
138
139
- std::size_t complexity = state.complexity ( );
139
+ std::size_t complexity = state.guard . as_expr (). bounded_size (max_complexity );
140
140
if (complexity == 0 )
141
141
return complexity_violationt::NONE;
142
142
Original file line number Diff line number Diff line change @@ -71,15 +71,6 @@ class goto_statet
71
71
// / Threads
72
72
unsigned atomic_section_id = 0 ;
73
73
74
- // / Get the complexity for this state. Used to short-circuit states if they
75
- // / have become too computationally complex.
76
- inline std::size_t complexity ()
77
- {
78
- // TODO: This isn't too efficent for BDDs, try using a different size
79
- // like DAG size.
80
- return guard.as_expr ().size ();
81
- }
82
-
83
74
// / Constructors
84
75
goto_statet () = delete ;
85
76
goto_statet &operator =(const goto_statet &other) = delete ;
Original file line number Diff line number Diff line change 24
24
25
25
#include < stack>
26
26
27
- std::size_t exprt::size () const
27
+ // / Returns the size of the exprt added to count without searching significantly
28
+ // / beyond the supplied limit.
29
+ std::size_t exprt::bounded_size (std::size_t count, std::size_t limit) const
28
30
{
29
- // Initial size of 1 to count self.
30
- std:: size_t size = 1 ;
31
- for (const auto &op : operands () )
31
+ const auto &ops = operands ();
32
+ count += ops. size () ;
33
+ for (const auto &op : ops )
32
34
{
33
- size += op.size ();
35
+ if (count >= limit)
36
+ {
37
+ return count;
38
+ }
39
+ count = op.bounded_size (count, limit);
34
40
}
41
+ return count;
42
+ }
35
43
36
- return size;
44
+ // / Returns the size of the exprt without significantly searching beyond the
45
+ // / supplied limit.
46
+ std::size_t exprt::bounded_size (std::size_t limit) const
47
+ {
48
+ return bounded_size (1 , limit);
37
49
}
38
50
39
51
// / Return whether the expression is a constant.
Original file line number Diff line number Diff line change @@ -85,9 +85,9 @@ class exprt:public irept
85
85
return static_cast <const typet &>(find (ID_type));
86
86
}
87
87
88
- // / Amount of nodes this expression tree contains. This is the size of the
89
- // / actual tree, ignoring memory/sub-tree sharing.
90
- std::size_t size ( ) const ;
88
+ // / Amount of nodes in this expression tree approximately bounded by limit.
89
+ // / This is the size of the actual tree, ignoring memory/sub-tree sharing.
90
+ std::size_t bounded_size (std:: size_t limit ) const ;
91
91
92
92
// / Return true if there is at least one operand.
93
93
bool has_operands () const
@@ -124,6 +124,10 @@ class exprt:public irept
124
124
const exprt &op3 () const
125
125
{ return operands ()[3 ]; }
126
126
127
+ // / Amount of nodes this expression tree contains, with a bound on how far
128
+ // / to search. Starts with an existing count.
129
+ std::size_t bounded_size (std::size_t count, std::size_t limit) const ;
130
+
127
131
public:
128
132
void reserve_operands (operandst::size_type n)
129
133
{ operands ().reserve (n) ; }
You can’t perform that action at this time.
0 commit comments