Skip to content

Commit 065a5f2

Browse files
committed
Move goto_symex_is_constantt into its own file
No behavioural change.
1 parent 42357e6 commit 065a5f2

File tree

2 files changed

+54
-35
lines changed

2 files changed

+54
-35
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*******************************************************************\
2+
3+
Module: Symbolic Execution Constant Propagation
4+
5+
Author: Michael Tautschig, [email protected]
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// GOTO Symex constant propagation
11+
12+
#ifndef CPROVER_GOTO_SYMEX_GOTO_SYMEX_IS_CONSTANT_H
13+
#define CPROVER_GOTO_SYMEX_GOTO_SYMEX_IS_CONSTANT_H
14+
15+
#include <util/expr.h>
16+
#include <util/expr_util.h>
17+
18+
class goto_symex_is_constantt : public is_constantt
19+
{
20+
protected:
21+
bool is_constant(const exprt &expr) const override
22+
{
23+
if(expr.id() == ID_mult)
24+
{
25+
// propagate stuff with sizeof in it
26+
forall_operands(it, expr)
27+
{
28+
if(it->find(ID_C_c_sizeof_type).is_not_nil())
29+
return true;
30+
else if(!is_constant(*it))
31+
return false;
32+
}
33+
34+
return true;
35+
}
36+
else if(expr.id() == ID_with)
37+
{
38+
// this is bad
39+
/*
40+
forall_operands(it, expr)
41+
if(!is_constant(expr.op0()))
42+
return false;
43+
44+
return true;
45+
*/
46+
return false;
47+
}
48+
49+
return is_constantt::is_constant(expr);
50+
}
51+
};
52+
53+
#endif // CPROVER_GOTO_SYMEX_GOTO_SYMEX_IS_CONSTANT_H

src/goto-symex/goto_symex_state.cpp

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Author: Daniel Kroening, [email protected]
1010
/// Symbolic Execution
1111

1212
#include "goto_symex_state.h"
13+
#include "goto_symex_is_constant.h"
1314

1415
#include <cstdlib>
1516
#include <iostream>
@@ -130,41 +131,6 @@ static bool check_renaming(const exprt &expr)
130131
return false;
131132
}
132133

133-
class goto_symex_is_constantt : public is_constantt
134-
{
135-
protected:
136-
bool is_constant(const exprt &expr) const override
137-
{
138-
if(expr.id() == ID_mult)
139-
{
140-
// propagate stuff with sizeof in it
141-
forall_operands(it, expr)
142-
{
143-
if(it->find(ID_C_c_sizeof_type).is_not_nil())
144-
return true;
145-
else if(!is_constant(*it))
146-
return false;
147-
}
148-
149-
return true;
150-
}
151-
else if(expr.id() == ID_with)
152-
{
153-
// this is bad
154-
/*
155-
forall_operands(it, expr)
156-
if(!is_constant(expr.op0()))
157-
return false;
158-
159-
return true;
160-
*/
161-
return false;
162-
}
163-
164-
return is_constantt::is_constant(expr);
165-
}
166-
};
167-
168134
template <>
169135
renamedt<ssa_exprt, L0>
170136
goto_symex_statet::set_indices<L0>(ssa_exprt ssa_expr, const namespacet &ns)

0 commit comments

Comments
 (0)