CBMC
goto_symex_can_forward_propagate.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Symbolic Execution Constant Propagation
4 
5 Author: 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 {
20 public:
23  {
24  }
25 
26 protected:
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
Determine whether an expression is constant.
Definition: expr_util.h:89
virtual bool is_constant(const exprt &) const
This function determines what expressions are to be propagated as "constants".
Definition: expr_util.cpp:229
const namespacet & ns
Definition: expr_util.h:102
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:384
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
Deprecated expression utility functions.