CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
invariant_set_domain.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Invariant Set Domain
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
11
13
14#include <util/expr_util.h>
15#include <util/simplify_expr.h>
16
20 const irep_idt &function_to,
22 ai_baset &ai,
23 const namespacet &ns)
24{
25 locationt from_l(trace_from->current_location());
26 locationt to_l(trace_to->current_location());
27
28 switch(from_l->type())
29 {
30 case GOTO:
31 {
32 // Comparing iterators is safe as the target must be within the same list
33 // of instructions because this is a GOTO.
34 exprt tmp(from_l->condition());
35
36 if(std::next(from_l) == to_l)
38
39 simplify(tmp, ns);
41 }
42 break;
43
44 case ASSERT:
45 case ASSUME:
46 {
47 exprt tmp(from_l->condition());
48 simplify(tmp, ns);
50 }
51 break;
52
54 // ignore
55 break;
56
57 case ASSIGN:
58 invariant_set.assignment(from_l->assign_lhs(), from_l->assign_rhs());
59 break;
60
61 case OTHER:
62 if(from_l->get_other().is_not_nil())
64 break;
65
66 case DECL:
68 break;
69
70 case FUNCTION_CALL:
72 break;
73
74 case START_THREAD:
76 break;
77
78 case CATCH:
79 case THROW:
80 DATA_INVARIANT(false, "Exceptions must be removed before analysis");
81 break;
82 case DEAD: // No action required
83 case ATOMIC_BEGIN: // Ignoring is a valid over-approximation
84 case ATOMIC_END: // Ignoring is a valid over-approximation
85 case END_FUNCTION: // No action required
86 case LOCATION: // No action required
87 case END_THREAD: // Require a concurrent analysis at higher level
88 case SKIP: // No action required
89 break;
90 case INCOMPLETE_GOTO:
92 DATA_INVARIANT(false, "Only complete instructions can be analyzed");
93 break;
94 }
95}
This is the basic interface of the abstract interpreter with default implementations of the core func...
Definition ai.h:117
ai_history_baset::trace_ptrt trace_ptrt
Definition ai_domain.h:73
goto_programt::const_targett locationt
Definition ai_domain.h:72
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
Base class for all expressions.
Definition expr.h:56
virtual void transform(const irep_idt &function_from, trace_ptrt trace_from, const irep_idt &function_to, trace_ptrt trace_to, ai_baset &ai, const namespacet &ns) final override
how function calls are treated: a) there is an edge from each call site to the function head b) there...
void apply_code(const codet &code)
void strengthen(const exprt &expr)
void assignment(const exprt &lhs, const exprt &rhs)
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
exprt boolean_negate(const exprt &src)
negate a Boolean expression, possibly removing a not_exprt, and swapping false and true
Deprecated expression utility functions.
@ FUNCTION_CALL
@ ATOMIC_END
@ DEAD
@ LOCATION
@ END_FUNCTION
@ ASSIGN
@ ASSERT
@ SET_RETURN_VALUE
@ ATOMIC_BEGIN
@ CATCH
@ END_THREAD
@ SKIP
@ NO_INSTRUCTION_TYPE
@ START_THREAD
@ THROW
@ DECL
@ OTHER
@ GOTO
@ INCOMPLETE_GOTO
@ ASSUME
bool simplify(exprt &expr, const namespacet &ns)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition invariant.h:534