@@ -65,38 +65,27 @@ static void build_dead_map_from_ai(
65
65
66
66
static void output_dead_plain (
67
67
const namespacet &ns,
68
+ const irep_idt &function_identifier,
68
69
const goto_programt &goto_program,
69
70
const dead_mapt &dead_map,
70
71
std::ostream &os)
71
72
{
72
- assert (!goto_program.instructions .empty ());
73
- goto_programt::const_targett end_function=
74
- goto_program.instructions .end ();
75
- --end_function;
76
- assert (end_function->is_end_function ());
77
-
78
- os << " \n *** " << end_function->function << " ***\n " ;
73
+ os << " \n *** " << function_identifier << " ***\n " ;
79
74
80
75
for (dead_mapt::const_iterator it=dead_map.begin ();
81
76
it!=dead_map.end ();
82
77
++it)
83
- goto_program.output_instruction (ns, " " , os, *it->second );
78
+ goto_program.output_instruction (ns, function_identifier , os, *it->second );
84
79
}
85
80
86
81
static void add_to_xml (
82
+ const irep_idt &function_identifier,
87
83
const goto_programt &goto_program,
88
84
const dead_mapt &dead_map,
89
85
xmlt &dest)
90
86
{
91
- PRECONDITION (!goto_program.instructions .empty ());
92
- goto_programt::const_targett end_function=
93
- goto_program.instructions .end ();
94
- --end_function;
95
- DATA_INVARIANT (end_function->is_end_function (),
96
- " The last instruction in a goto-program must be END_FUNCTION" );
97
-
98
87
xmlt &x = dest.new_element (" function" );
99
- x.set_attribute (" name" , id2string (end_function-> function ));
88
+ x.set_attribute (" name" , id2string (function_identifier ));
100
89
101
90
for (dead_mapt::const_iterator it=dead_map.begin ();
102
91
it!=dead_map.end ();
@@ -113,20 +102,21 @@ static void add_to_xml(
113
102
114
103
static void add_to_json (
115
104
const namespacet &ns,
105
+ const irep_idt &function_identifier,
116
106
const goto_programt &goto_program,
117
107
const dead_mapt &dead_map,
118
108
json_arrayt &dest)
119
109
{
120
- json_objectt &entry=dest.push_back ().make_object ();
121
-
122
110
PRECONDITION (!goto_program.instructions .empty ());
123
111
goto_programt::const_targett end_function=
124
112
goto_program.instructions .end ();
125
113
--end_function;
126
114
DATA_INVARIANT (end_function->is_end_function (),
127
115
" The last instruction in a goto-program must be END_FUNCTION" );
128
116
129
- entry[" function" ] = json_stringt (end_function->function );
117
+ json_objectt &entry = dest.push_back ().make_object ();
118
+
119
+ entry[" function" ] = json_stringt (function_identifier);
130
120
entry[" fileName" ]=
131
121
json_stringt (concat_dir_file (
132
122
id2string (end_function->source_location .get_working_directory ()),
@@ -191,9 +181,9 @@ void unreachable_instructions(
191
181
if (!dead_map.empty ())
192
182
{
193
183
if (!json)
194
- output_dead_plain (ns, goto_program, dead_map, os);
184
+ output_dead_plain (ns, f_it-> first , goto_program, dead_map, os);
195
185
else
196
- add_to_json (ns, goto_program, dead_map, json_result);
186
+ add_to_json (ns, f_it-> first , goto_program, dead_map, json_result);
197
187
}
198
188
}
199
189
@@ -225,16 +215,16 @@ bool static_unreachable_instructions(
225
215
{
226
216
if (options.get_bool_option (" json" ))
227
217
{
228
- add_to_json (ns, f_it->second .body , dead_map, json_result);
218
+ add_to_json (ns, f_it->first , f_it-> second .body , dead_map, json_result);
229
219
}
230
220
else if (options.get_bool_option (" xml" ))
231
221
{
232
- add_to_xml (f_it->second .body , dead_map, xml_result);
222
+ add_to_xml (f_it->first , f_it-> second .body , dead_map, xml_result);
233
223
}
234
224
else
235
225
{
236
226
// text or console
237
- output_dead_plain (ns, f_it->second .body , dead_map, out);
227
+ output_dead_plain (ns, f_it->first , f_it-> second .body , dead_map, out);
238
228
}
239
229
}
240
230
}
0 commit comments