CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
goto_symex_can_forward_propagate.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Symbolic Execution Constant Propagation
4
5Author: Michael Tautschig, tautschn@amazon.com
6
7\*******************************************************************/
8
11
12#ifndef CPROVER_GOTO_SYMEX_GOTO_SYMEX_CAN_FORWARD_PROPAGATE_H
13#define CPROVER_GOTO_SYMEX_GOTO_SYMEX_CAN_FORWARD_PROPAGATE_H
14
15#include <util/expr.h>
16#include <util/expr_util.h>
17
19{
20public:
25
26protected:
27 bool is_constant(const exprt &expr) const override
28 {
29 if(expr.id() == ID_mult)
30 {
31 bool found_non_constant = false;
32
33 // propagate stuff with sizeof in it
34 for(const auto &op : expr.operands())
35 {
36 if(op.find(ID_C_c_sizeof_type).is_not_nil())
37 return true;
38 else if(!is_constant(op))
39 found_non_constant = true;
40 }
41
42 return !found_non_constant;
43 }
44 else if(expr.id() == ID_with)
45 {
46 // this is bad
47#if 0
48 for(const auto &op : expr.operands())
49 {
50 if(!is_constant(op))
51 return false;
52 }
53
54 return true;
55#else
56 return false;
57#endif
58 }
59
61 }
62};
63
64#endif // CPROVER_GOTO_SYMEX_GOTO_SYMEX_CAN_FORWARD_PROPAGATE_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
Determine whether an expression is constant.
Definition expr_util.h:91
virtual bool is_constant(const exprt &) const
This function determines what expressions are to be propagated as "constants".
const namespacet & ns
Definition expr_util.h:104
Base class for all expressions.
Definition expr.h:56
operandst & operands()
Definition expr.h:94
bool is_constant(const exprt &expr) const override
This function determines what expressions are to be propagated as "constants".
const irep_idt & id() const
Definition irep.h:388
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
Deprecated expression utility functions.