Go to the documentation of this file.
70 const auto function_name =
id2string(function_symbol.get_identifier());
72 R
"(.*org\.cprover\.CProver\.nondet)"
73 R"((?:Boolean|Byte|Char|Short|Int|Long|Float|Double|With(out)?Null.*))");
74 std::smatch match_results;
75 if(!std::regex_match(function_name, match_results, reg))
91 if(!(instr->is_function_call() && instr->code.id() == ID_code))
95 const auto &code = instr->code;
97 code.get_statement() == ID_function_call,
98 "function_call should have ID_function_call");
109 return expr.
id() == ID_symbol &&
120 if(!(expr.
id() == ID_typecast && expr.
operands().size() == 1))
125 if(!(typecast.op().id() == ID_symbol && !typecast.op().has_operands()))
131 return op_symbol.get_identifier() == identifier;
201 const auto next_instr = std::next(target);
203 instr_info.get_instruction_type() ==
211 const bool remove_returns_not_run =
215 if(remove_returns_not_run)
225 next_instr->is_assign(),
226 "the code_function_callt for a nondet-returning library function should "
227 "either have a variable for the return value in its lhs() or the next "
228 "instruction should be an assignment of the return value to a temporary "
230 const exprt &return_value_assignment =
235 !(return_value_assignment.
id() == ID_symbol &&
249 auto target_instruction = std::find_if(
257 if(target_instruction == end)
259 target_instruction = std::find_if(
268 target_instruction != end,
269 "failed to find return of the temporary return variable or assignment of "
270 "the temporary return variable into a target variable");
277 if(target_instruction->is_return())
279 const auto &nondet_var =
283 nondet_var.type(), target_instruction->source_location);
285 instr_info.get_nullable_type() ==
288 target_instruction->code.add_source_location() =
289 target_instruction->source_location;
291 else if(target_instruction->is_assign())
297 nondet_var.type(), target_instruction->source_location);
299 instr_info.get_nullable_type() ==
301 target_instruction->code =
code_assignt(nondet_var, inserted_expr);
302 target_instruction->code.add_source_location() =
303 target_instruction->source_location;
308 return std::next(target_instruction);
317 for(
auto instruction_iterator = goto_program.
instructions.begin(),
319 instruction_iterator != end;)
321 instruction_iterator =
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
nondet_instruction_infot()
void remove_skip(goto_programt &goto_program, goto_programt::targett begin, goto_programt::targett end)
remove unnecessary skip statements
void update()
Update all indices.
Base class for all expressions.
static bool is_typecast_with_id(const exprt &expr, const irep_idt &identifier)
Return whether the expression is a typecast with the specified identifier.
function_mapt function_map
codet representation of a function call statement.
void turn_into_skip()
Transforms an existing instruction into a skip, retaining the source_location.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
bool has_operands() const
Return true if there is at least one operand.
const std::string & id2string(const irep_idt &d)
codet code
Do not read or modify directly – use get_X() instead.
const irep_idt & get_identifier() const
void set_nullable(bool nullable)
static bool is_assignment_from(const goto_programt::instructiont &instr, const irep_idt &identifier)
Return whether the instruction is an assignment, and the rhs is a symbol or typecast expression with ...
static bool is_return_with_variable(const goto_programt::instructiont &instr, const irep_idt &identifier)
Return whether the instruction is a return, and the rhs is a symbol or typecast expression with the s...
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const irep_idt & id() const
const code_function_callt & to_code_function_call(const codet &code)
const code_returnt & to_code_return(const codet &code)
static bool is_symbol_with_id(const exprt &expr, const irep_idt &identifier)
Return whether the expression is a symbol with the specified identifier.
A side_effect_exprt that returns a non-deterministically chosen value.
static nondet_instruction_infot is_nondet_returning_object(const code_function_callt &function_call)
Checks whether the function call is one of our nondet library functions.
instructionst instructions
The list of instructions in the goto program.
A collection of goto functions.
is_nullablet get_nullable_type() const
codet representation of a "return from a function" statement.
goto_functionst goto_functions
GOTO functions.
const code_assignt & to_code_assign(const codet &code)
is_nondett get_instruction_type() const
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
static goto_programt::targett check_and_replace_target(goto_programt &goto_program, const goto_programt::targett &target)
Given an iterator into a list of instructions, modify the list to replace 'nondet' library functions ...
A generic container class for the GOTO intermediate representation of one function.
static void replace_java_nondet(goto_programt &goto_program)
Checks each instruction in the goto program to see whether it is a method returning nondet.
instructionst::const_iterator const_targett
Holds information about any discovered nondet methods, with extreme type- safety.
static nondet_instruction_infot get_nondet_instruction_info(const goto_programt::const_targett &instr)
Check whether the instruction is a function call which matches one of the recognised nondet library m...
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
const exprt & return_value() const
A codet representing an assignment in the program.
This class represents an instruction in the GOTO intermediate representation.
Interface providing access to a single function in a GOTO model, plus its associated symbol table.
instructionst::iterator targett
nondet_instruction_infot(is_nullablet is_nullable)
Replace Java Nondet expressions.