24
24
#include < linking/static_lifetime_init.h>
25
25
26
26
#include " ansi_c_entry_point.h"
27
+ #include " c_nondet_symbol_factory.h"
27
28
28
29
/* ******************************************************************\
29
30
@@ -40,66 +41,31 @@ Function: build_function_environment
40
41
exprt::operandst build_function_environment (
41
42
const code_typet::parameterst ¶meters,
42
43
code_blockt &init_code,
43
- symbol_tablet &symbol_table)
44
+ symbol_tablet &symbol_table,
45
+ message_handlert &message_handler)
44
46
{
45
- exprt::operandst result ;
46
- result .resize (parameters.size ());
47
+ exprt::operandst main_arguments ;
48
+ main_arguments .resize (parameters.size ());
47
49
48
- std::size_t i =0 ;
49
-
50
- for ( const auto &p : parameters )
50
+ for ( std::size_t param_number =0 ;
51
+ param_number<parameters. size ();
52
+ param_number++ )
51
53
{
52
- irep_idt base_name=p.get_base_name ().empty ()?
53
- (" argument#" +std::to_string (i)):p.get_base_name ();
54
- irep_idt identifier=id2string (goto_functionst::entry_point ())+
55
- " ::" +id2string (base_name);
56
-
57
- {
58
- auxiliary_symbolt new_symbol;
59
- new_symbol.mode =ID_C;
60
- new_symbol.is_static_lifetime =false ;
61
- new_symbol.name =identifier;
62
- new_symbol.base_name =base_name;
63
- new_symbol.type =p.type ();
64
-
65
- symbol_table.move (new_symbol);
66
- }
67
-
68
- symbol_exprt symbol_expr (identifier, p.type ());
69
-
70
- code_declt decl;
71
- decl.symbol ()=symbol_expr;
72
-
73
- init_code.add (decl);
74
-
75
- // nondet init for _Bool
76
- if (decl.symbol ().type ().id ()==ID_c_bool)
77
- {
78
- code_assignt assign (
79
- decl.symbol (),
80
- typecast_exprt (
81
- side_effect_expr_nondett (bool_typet ()),
82
- decl.symbol ().type ()));
83
-
84
- init_code.move_to_operands (assign);
85
- }
86
-
87
- codet input (ID_input);
88
- input.operands ().resize (2 );
89
-
90
- // record as an input
91
- input.op0 ()=address_of_exprt (
92
- index_exprt (string_constantt (base_name), from_integer (0 , index_type ())));
93
- input.op1 ()=symbol_expr;
94
- input.add_source_location ()=p.source_location ();
95
-
96
- init_code.move_to_operands (input);
97
-
98
- result[i]=symbol_expr;
99
- i++;
54
+ const code_typet::parametert &p=parameters[param_number];
55
+ const irep_idt base_name=p.get_base_name ().empty ()?
56
+ (" argument#" +std::to_string (param_number)):p.get_base_name ();
57
+
58
+ main_arguments[param_number]=
59
+ c_nondet_symbol_factory (
60
+ init_code,
61
+ symbol_table,
62
+ base_name,
63
+ p.type (),
64
+ p.source_location (),
65
+ true );
100
66
}
101
67
102
- return result ;
68
+ return main_arguments ;
103
69
}
104
70
105
71
/* ******************************************************************\
@@ -506,7 +472,11 @@ bool ansi_c_entry_point(
506
472
{
507
473
// produce nondet arguments
508
474
call_main.arguments ()=
509
- build_function_environment (parameters, init_code, symbol_table);
475
+ build_function_environment (
476
+ parameters,
477
+ init_code,
478
+ symbol_table,
479
+ message_handler);
510
480
}
511
481
512
482
init_code.move_to_operands (call_main);
0 commit comments