void mutex_init_instrumentation( const symbol_tablet &symbol_table, goto_programt &goto_program, typet lock_type) { symbol_tablet::symbolst::const_iterator f_it= symbol_table.symbols.find("__CPROVER_set_must"); if(f_it==symbol_table.symbols.end()) return; Forall_goto_program_instructions(it, goto_program) { if(it->is_assign()) { const code_assignt &code_assign= to_code_assign(it->code); if(code_assign.lhs().type()==lock_type) { goto_programt::targett t=goto_program.insert_after(it); code_function_callt call; call.function()=f_it->second.symbol_expr(); call.arguments().resize(2); call.arguments()[0]=address_of_exprt(code_assign.lhs()); call.arguments()[1]=address_of_exprt(string_constantt("mutex-init")); t->make_function_call(call); t->source_location=it->source_location; } } } }
goto_programt::targett cegis_assign(const symbol_tablet &st, goto_programt &body, const goto_programt::targett &insert_after_pos, const exprt &lhs, const exprt &rhs, const source_locationt &loc) { const goto_programt::targett assign=body.insert_after(insert_after_pos); cegis_assign(st, *assign, lhs, rhs, loc); return assign; }
goto_programt::targett add_return_assignment(goto_programt &body, goto_programt::targett pos, const irep_idt &func_id, const exprt &value) { const source_locationt &loc=pos->source_location; pos=body.insert_after(pos); pos->make_assignment(); pos->source_location=loc; pos->code=code_assignt(get_ret_val_var(func_id, value.type()), value); return pos; }
void remove_return(goto_programt &body, const goto_programt::targett pos) { code_function_callt &call=to_code_function_call(pos->code); const irep_idt &id=to_symbol_expr(call.function()).get_identifier(); const typet &type=call.lhs().type(); const source_locationt &loc=pos->source_location; const irep_idt &func=pos->function; const goto_programt::targett assign=body.insert_after(pos); assign->make_assignment(); assign->source_location=loc; assign->code=code_assignt(call.lhs(), get_ret_val_var(id, type)); assign->function=func; call.lhs().make_nil(); }