@@ -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,6 +102,7 @@ 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)
@@ -125,7 +115,7 @@ static void add_to_json(
125
115
" The last instruction in a goto-program must be END_FUNCTION" );
126
116
127
117
json_objectt entry (
128
- {{" function" , json_stringt (end_function-> function )},
118
+ {{" function" , json_stringt (function_identifier )},
129
119
{" fileName" ,
130
120
json_stringt (concat_dir_file (
131
121
id2string (end_function->source_location .get_working_directory ()),
@@ -192,9 +182,9 @@ void unreachable_instructions(
192
182
if (!dead_map.empty ())
193
183
{
194
184
if (!json)
195
- output_dead_plain (ns, goto_program, dead_map, os);
185
+ output_dead_plain (ns, f_it-> first , goto_program, dead_map, os);
196
186
else
197
- add_to_json (ns, goto_program, dead_map, json_result);
187
+ add_to_json (ns, f_it-> first , goto_program, dead_map, json_result);
198
188
}
199
189
}
200
190
@@ -226,16 +216,16 @@ bool static_unreachable_instructions(
226
216
{
227
217
if (options.get_bool_option (" json" ))
228
218
{
229
- add_to_json (ns, f_it->second .body , dead_map, json_result);
219
+ add_to_json (ns, f_it->first , f_it-> second .body , dead_map, json_result);
230
220
}
231
221
else if (options.get_bool_option (" xml" ))
232
222
{
233
- add_to_xml (f_it->second .body , dead_map, xml_result);
223
+ add_to_xml (f_it->first , f_it-> second .body , dead_map, xml_result);
234
224
}
235
225
else
236
226
{
237
227
// text or console
238
- output_dead_plain (ns, f_it->second .body , dead_map, out);
228
+ output_dead_plain (ns, f_it->first , f_it-> second .body , dead_map, out);
239
229
}
240
230
}
241
231
}
0 commit comments