Skip to content

Commit f4f333a

Browse files
Daniel Kroeningtautschnig
Daniel Kroening
authored andcommitted
ai_baset: output now requires function identifier
We are working towards removing the "function" field from goto_programt::instructionst::instructiont, and thus need to pass the identifier of the function whenever it actually is required.
1 parent 12bce17 commit f4f333a

File tree

3 files changed

+34
-43
lines changed

3 files changed

+34
-43
lines changed

src/analyses/ai.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ void ai_baset::output(
3535
out << "////\n";
3636
out << "\n";
3737

38-
output(ns, f_it->second.body, f_it->first, out);
38+
output(ns, f_it->first, f_it->second.body, out);
3939
}
4040
}
4141
}
4242

4343
void ai_baset::output(
4444
const namespacet &ns,
45+
const irep_idt &function_identifier,
4546
const goto_programt &goto_program,
46-
const irep_idt &identifier,
4747
std::ostream &out) const
4848
{
4949
forall_goto_program_instructions(i_it, goto_program)
@@ -54,7 +54,7 @@ void ai_baset::output(
5454
abstract_state_before(i_it)->output(out, *this, ns);
5555
out << "\n";
5656
#if 1
57-
goto_program.output_instruction(ns, identifier, out, *i_it);
57+
goto_program.output_instruction(ns, function_identifier, out, *i_it);
5858
out << "\n";
5959
#endif
6060
}
@@ -70,8 +70,8 @@ jsont ai_baset::output_json(
7070
{
7171
if(f_it->second.body_available())
7272
{
73-
result[id2string(f_it->first)]=
74-
output_json(ns, f_it->second.body, f_it->first);
73+
result[id2string(f_it->first)] =
74+
output_json(ns, f_it->first, f_it->second.body);
7575
}
7676
else
7777
{
@@ -90,16 +90,16 @@ jsont ai_baset::output_json(
9090
/// \return The JSON object
9191
jsont ai_baset::output_json(
9292
const namespacet &ns,
93-
const goto_programt &goto_program,
94-
const irep_idt &identifier) const
93+
const irep_idt &function,
94+
const goto_programt &goto_program) const
9595
{
9696
json_arrayt contents;
9797

9898
forall_goto_program_instructions(i_it, goto_program)
9999
{
100100
// Ideally we need output_instruction_json
101101
std::ostringstream out;
102-
goto_program.output_instruction(ns, identifier, out, *i_it);
102+
goto_program.output_instruction(ns, function, out, *i_it);
103103

104104
json_objectt location(
105105
{{"locationNumber", json_numbert(std::to_string(i_it->location_number))},
@@ -129,7 +129,7 @@ xmlt ai_baset::output_xml(
129129

130130
if(f_it->second.body_available())
131131
{
132-
function.new_element(output_xml(ns, f_it->second.body, f_it->first));
132+
function.new_element(output_xml(ns, f_it->first, f_it->second.body));
133133
}
134134

135135
program.new_element(function);
@@ -146,8 +146,8 @@ xmlt ai_baset::output_xml(
146146
/// \return The XML object
147147
xmlt ai_baset::output_xml(
148148
const namespacet &ns,
149-
const goto_programt &goto_program,
150-
const irep_idt &identifier) const
149+
const irep_idt &function,
150+
const goto_programt &goto_program) const
151151
{
152152
xmlt function_body;
153153

@@ -161,7 +161,7 @@ xmlt ai_baset::output_xml(
161161

162162
// Ideally we need output_instruction_xml
163163
std::ostringstream out;
164-
goto_program.output_instruction(ns, identifier, out, *i_it);
164+
goto_program.output_instruction(ns, function, out, *i_it);
165165
location.set_attribute("instruction", out.str());
166166

167167
function_body.new_element(location);

src/analyses/ai.h

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,18 @@ class ai_baset
124124
{
125125
}
126126

127+
/// Output the abstract states for a single function
128+
/// \param ns: The namespace
129+
/// \param identifier: The identifier used to find a symbol to identify the
130+
/// \param goto_program: The goto program
131+
/// source language
132+
/// \param out: The ostream to direct output to
133+
virtual void output(
134+
const namespacet &ns,
135+
const irep_idt &identifier,
136+
const goto_programt &goto_program,
137+
std::ostream &out) const;
138+
127139
/// Output the abstract states for a whole program
128140
virtual void output(
129141
const namespacet &ns,
@@ -139,22 +151,13 @@ class ai_baset
139151
output(ns, goto_model.goto_functions, out);
140152
}
141153

142-
/// Output the abstract states for a function
143-
void output(
144-
const namespacet &ns,
145-
const goto_programt &goto_program,
146-
std::ostream &out) const
147-
{
148-
output(ns, goto_program, "", out);
149-
}
150-
151154
/// Output the abstract states for a function
152155
void output(
153156
const namespacet &ns,
154157
const goto_functionst::goto_functiont &goto_function,
155158
std::ostream &out) const
156159
{
157-
output(ns, goto_function.body, "", out);
160+
output(ns, "", goto_function.body, out);
158161
}
159162

160163
/// Output the abstract states for the whole program as JSON
@@ -175,15 +178,15 @@ class ai_baset
175178
const namespacet &ns,
176179
const goto_programt &goto_program) const
177180
{
178-
return output_json(ns, goto_program, "");
181+
return output_json(ns, "", goto_program);
179182
}
180183

181184
/// Output the abstract states for a single function as JSON
182185
jsont output_json(
183186
const namespacet &ns,
184187
const goto_functionst::goto_functiont &goto_function) const
185188
{
186-
return output_json(ns, goto_function.body, "");
189+
return output_json(ns, "", goto_function.body);
187190
}
188191

189192
/// Output the abstract states for the whole program as XML
@@ -204,15 +207,15 @@ class ai_baset
204207
const namespacet &ns,
205208
const goto_programt &goto_program) const
206209
{
207-
return output_xml(ns, goto_program, "");
210+
return output_xml(ns, "", goto_program);
208211
}
209212

210213
/// Output the abstract states for a single function as XML
211214
xmlt output_xml(
212215
const namespacet &ns,
213216
const goto_functionst::goto_functiont &goto_function) const
214217
{
215-
return output_xml(ns, goto_function.body, "");
218+
return output_xml(ns, "", goto_function.body);
216219
}
217220

218221
protected:
@@ -239,18 +242,6 @@ class ai_baset
239242
/// entry state required by the analysis
240243
void entry_state(const goto_functionst &goto_functions);
241244

242-
/// Output the abstract states for a single function
243-
/// \param ns: The namespace
244-
/// \param goto_program: The goto program
245-
/// \param identifier: The identifier used to find a symbol to identify the
246-
/// source language
247-
/// \param out: The ostream to direct output to
248-
virtual void output(
249-
const namespacet &ns,
250-
const goto_programt &goto_program,
251-
const irep_idt &identifier,
252-
std::ostream &out) const;
253-
254245
/// Output the abstract states for a single function as JSON
255246
/// \param ns: The namespace
256247
/// \param goto_program: The goto program
@@ -259,8 +250,8 @@ class ai_baset
259250
/// \return The JSON object
260251
virtual jsont output_json(
261252
const namespacet &ns,
262-
const goto_programt &goto_program,
263-
const irep_idt &identifier) const;
253+
const irep_idt &function,
254+
const goto_programt &goto_program) const;
264255

265256
/// Output the abstract states for a single function as XML
266257
/// \param ns: The namespace
@@ -270,8 +261,8 @@ class ai_baset
270261
/// \return The XML object
271262
virtual xmlt output_xml(
272263
const namespacet &ns,
273-
const goto_programt &goto_program,
274-
const irep_idt &identifier) const;
264+
const irep_idt &function,
265+
const goto_programt &goto_program) const;
275266

276267
/// The work queue, sorted by location number
277268
typedef std::map<unsigned, locationt> working_sett;

src/goto-instrument/uninitialized.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void show_uninitialized(
223223
out << "////\n\n";
224224
uninitialized_analysist uninitialized_analysis;
225225
uninitialized_analysis(f_it->first, f_it->second.body, ns);
226-
uninitialized_analysis.output(ns, f_it->second.body, out);
226+
uninitialized_analysis.output(ns, f_it->first, f_it->second.body, out);
227227
}
228228
}
229229
}

0 commit comments

Comments
 (0)