CBMC
Loading...
Searching...
No Matches
process_goto_program.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Process a Goto Program
4
5Author: Martin Brain, martin.brain@cs.ox.ac.uk
6
7\*******************************************************************/
8
11
13
14#include <util/message.h>
15#include <util/options.h>
16
21#include <goto-programs/mm_io.h>
30
33
34#include "goto_check.h"
35
37 goto_modelt &goto_model,
38 const optionst &options,
40{
41 if(options.get_bool_option("string-abstraction"))
42 string_instrumentation(goto_model);
43
44 // remove function pointers
45 log.status() << "Removal of function pointers and virtual functions"
47 remove_function_pointers(log.get_message_handler(), goto_model, false);
48
49 mm_io(goto_model, log.get_message_handler());
50
51 // instrument library preconditions
52 instrument_preconditions(goto_model);
53
54 // do partial inlining
55 if(options.get_bool_option("partial-inline"))
56 {
57 log.status() << "Partial Inlining" << messaget::eom;
58 goto_partial_inline(goto_model, log.get_message_handler());
59 }
60
61 // remove returns, gcc vectors, complex
62 if(
63 options.get_bool_option("remove-returns") ||
64 options.get_bool_option("string-abstraction"))
65 {
66 remove_returns(goto_model);
67 }
68
69 remove_vector(goto_model);
70 remove_complex(goto_model);
71
72 if(options.get_bool_option("rewrite-union"))
73 rewrite_union(goto_model);
74
75 if(options.get_bool_option("rewrite-rw-ok"))
76 rewrite_rw_ok(goto_model);
77
78 // Drop unused functions before property instrumentation to avoid
79 // instrumenting functions that will never be reached. The entry point
80 // has been set, and function pointers have already been removed above,
81 // so the static call graph is now an accurate reachability oracle.
82 if(options.get_bool_option("drop-unused-functions"))
83 {
84 log.status() << "Removing unused functions" << messaget::eom;
85 remove_unused_functions(goto_model, log.get_message_handler());
86 }
87
88 // add generic checks
89 log.status() << "Generic Property Instrumentation" << messaget::eom;
90 goto_check_c(options, goto_model, log.get_message_handler());
91 transform_assertions_assumptions(options, goto_model);
92
93 // checks don't know about adjusted float expressions
94 adjust_float_expressions(goto_model);
95
96 if(options.get_bool_option("string-abstraction"))
97 {
98 log.status() << "String Abstraction" << messaget::eom;
99 string_abstraction(goto_model, log.get_message_handler());
100 }
101
102 // recalculate numbers, etc.
103 goto_model.goto_functions.update();
104
105 return false;
106}
void adjust_float_expressions(exprt &expr, const exprt &rounding_mode)
Replaces arithmetic operations and typecasts involving floating point numbers with their equivalent f...
Symbolic Execution.
goto_functionst goto_functions
GOTO functions.
Definition goto_model.h:34
Class that provides messages with a built-in verbosity 'level'.
Definition message.h:154
static eomt eom
Definition message.h:289
bool get_bool_option(const std::string &option) const
Definition options.cpp:44
static void transform_assertions_assumptions(goto_programt &goto_program, bool enable_assertions, bool enable_built_in_assertions, bool enable_assumptions)
Checks for Errors in C and Java Programs.
void goto_check_c(const irep_idt &function_identifier, goto_functionst::goto_functiont &goto_function, const namespacet &ns, const optionst &options, message_handlert &message_handler)
Program Transformation.
void goto_partial_inline(goto_modelt &goto_model, message_handlert &message_handler, unsigned smallfunc_limit, bool adjust_function)
Inline all function calls to functions either marked as "inlined" or smaller than smallfunc_limit (by...
Function Inlining This gives a number of different interfaces to the function inlining functionality ...
Symbol Table + CFG.
void instrument_preconditions(const goto_modelt &goto_model, goto_programt &goto_program)
double log(double x)
Definition math.c:2416
void mm_io(symbol_tablet &symbol_table, goto_functionst &goto_functions, message_handlert &message_handler)
Definition mm_io.cpp:154
Perform Memory-mapped I/O instrumentation.
Options.
bool process_goto_program(goto_modelt &goto_model, const optionst &options, messaget &log)
Common processing and simplification of goto_programts.
static void remove_complex(typet &)
removes complex data type
Remove the 'complex' data type by compilation into structs.
void remove_function_pointers(message_handlert &_message_handler, goto_modelt &goto_model, bool only_remove_const_fps)
Remove Indirect Function Calls.
void remove_returns(symbol_table_baset &symbol_table, goto_functionst &goto_functions)
removes returns
Replace function returns by assignments to global variables.
void remove_unused_functions(goto_modelt &goto_model, message_handlert &message_handler)
Unused function removal.
static void remove_vector(typet &)
removes vector data type
Remove the 'vector' data type by compilation into arrays.
static std::optional< exprt > rewrite_rw_ok(exprt expr, const namespacet &ns)
Rewrite r/w/rw_ok expressions to ones including prophecy variables recording the state.
void rewrite_union(exprt &expr)
We rewrite u.c for unions u into byte_extract(u, 0), and { .c = v } into byte_update(NIL,...
Symbolic Execution.
void string_abstraction(goto_modelt &goto_model, message_handlert &message_handler)
String Abstraction.
void string_instrumentation(symbol_table_baset &symbol_table, goto_programt &dest)
String Abstraction.