ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
frame_enforcer.h
Go to the documentation of this file.
1
19
20#ifndef GOTO_PROGRAMS_FRAME_ENFORCER_H
21#define GOTO_PROGRAMS_FRAME_ENFORCER_H
22
24#include <util/symtab/context.h>
25#include <irep2/irep2_expr.h>
26#include <map>
27#include <set>
28#include <vector>
29
32enum class frame_modet
33{
36};
37
39{
40public:
48
49 frame_enforcert(contextt &_context);
50
61 const std::vector<expr2tc> &vars_to_snapshot,
62 goto_programt &dest,
63 const locationt &loc,
64 const std::string &scope_prefix);
65
78 const std::vector<expr2tc> &explicit_assigns,
79 goto_programt &dest,
80 const locationt &loc,
82
90
96 expr2tc in_pre_state(const expr2tc &expr) const;
97
110
112 const std::vector<snapshot_entryt> &get_active_snapshots() const
113 {
114 return active_snapshots;
115 }
116
123 static std::vector<expr2tc> collect_global_variables(const contextt &context);
124
130 {
131 std::vector<expr2tc>
133 std::vector<expr2tc>
140 std::map<irep_idt, std::set<irep_idt>> struct_field_targets;
145 std::map<irep_idt, std::set<irep_idt>> ptr_field_targets;
150 std::map<irep_idt, std::vector<expr2tc>> array_elem_targets;
151 };
152
159 classify_assigns_targets(const std::vector<expr2tc> &explicit_assigns);
160
161private:
162 contextt &context;
163
165 std::vector<snapshot_entryt> active_snapshots;
166
168 size_t snapshot_counter;
169
178 expr2tc create_snapshot_symbol(
179 const expr2tc &original,
180 const std::string &prefix,
181 size_t index);
182};
183
184#endif /* GOTO_PROGRAMS_FRAME_ENFORCER_H */
Definition context.h:57
expr2tc replace_old_with_snapshots(const expr2tc &expr) const
Replace old() references in an expression with snapshot variables.
Definition frame_enforcer.cpp:618
expr2tc in_pre_state(const expr2tc &expr) const
Rewrite expr to denote what it denoted before the havoc or call, by substituting each snapshotted sym...
Definition frame_enforcer.cpp:588
const std::vector< snapshot_entryt > & get_active_snapshots() const
Get the active snapshots (for debugging/inspection).
Definition frame_enforcer.h:112
void enforce_frame_rule(const std::vector< expr2tc > &explicit_assigns, goto_programt &dest, const locationt &loc, frame_modet mode=frame_modet::ASSUME)
Enforce frame rule with configurable mode.
Definition frame_enforcer.cpp:429
void patch_old_snapshot_assigns(goto_programt &prog) const
Patch old_snapshot side effects in a GOTO program to use frame snapshots.
Definition frame_enforcer.cpp:543
void materialize_snapshots(const std::vector< expr2tc > &vars_to_snapshot, goto_programt &dest, const locationt &loc, const std::string &scope_prefix)
Materialize snapshots for a set of variables.
Definition frame_enforcer.cpp:18
frame_enforcert(contextt &_context)
Definition frame_enforcer.cpp:13
static classified_assignst classify_assigns_targets(const std::vector< expr2tc > &explicit_assigns)
Classify assigns targets into direct and pointer categories.
Definition frame_enforcer.cpp:90
static std::vector< expr2tc > collect_global_variables(const contextt &context)
Collect all accessible global variables from the symbol table.
Definition frame_enforcer.cpp:508
A generic container class for a control flow graph for one function, in the form of a goto-program.
Definition goto_program.h:63
Definition location.h:7
frame_modet
Enforcement mode: ASSUME constrains search space (loops), ASSERT checks compliance (contracts).
Definition frame_enforcer.h:33
@ ASSUME
Definition frame_enforcer.h:34
@ ASSERT
Definition goto_program.h:32
@ ASSUME
Definition goto_program.h:31
irep_container< expr2t > expr2tc
Definition irep2.h:431
Classification of assigns targets into direct, pointer, and struct-field categories.
Definition frame_enforcer.h:130
std::map< irep_idt, std::vector< expr2tc > > array_elem_targets
Array-element targets: maps an array symbol name to the indices the clause names.
Definition frame_enforcer.h:150
std::map< irep_idt, std::set< irep_idt > > ptr_field_targets
Pointer-struct-field targets: maps pointer symbol name to the set of field names explicitly assigned ...
Definition frame_enforcer.h:145
std::vector< expr2tc > direct_targets
Non-pointer targets matched structurally.
Definition frame_enforcer.h:132
std::map< irep_idt, std::set< irep_idt > > struct_field_targets
Direct struct field targets: maps global struct symbol name to the set of field names explicitly assi...
Definition frame_enforcer.h:140
std::vector< expr2tc > pointer_targets
Pointer-typed targets from *ptr pattern.
Definition frame_enforcer.h:134
Snapshot entry: maps an original expression to its snapshot symbol.
Definition frame_enforcer.h:43
expr2tc snapshot_sym
The snapshot symbol (e.g., "__ESBMC_frame_snap_loop_0_i").
Definition frame_enforcer.h:45
expr2tc original_expr
The variable being snapshotted (e.g., "i").
Definition frame_enforcer.h:44