Skip to content

Commit 1263f04

Browse files
committed
ai_baset: consistently use function_id instead of function_identifier
It is as clear, but makes for shorter lines.
1 parent c94cf4c commit 1263f04

File tree

2 files changed

+41
-55
lines changed

2 files changed

+41
-55
lines changed

src/analyses/ai.cpp

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void ai_baset::output(
4242

4343
void ai_baset::output(
4444
const namespacet &ns,
45-
const irep_idt &function_identifier,
45+
const irep_idt &function_id,
4646
const goto_programt &goto_program,
4747
std::ostream &out) const
4848
{
@@ -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, function_identifier, out, *i_it);
57+
goto_program.output_instruction(ns, function_id, out, *i_it);
5858
out << "\n";
5959
#endif
6060
}
@@ -84,7 +84,7 @@ jsont ai_baset::output_json(
8484

8585
jsont ai_baset::output_json(
8686
const namespacet &ns,
87-
const irep_idt &function_identifier,
87+
const irep_idt &function_id,
8888
const goto_programt &goto_program) const
8989
{
9090
json_arrayt contents;
@@ -93,7 +93,7 @@ jsont ai_baset::output_json(
9393
{
9494
// Ideally we need output_instruction_json
9595
std::ostringstream out;
96-
goto_program.output_instruction(ns, function_identifier, out, *i_it);
96+
goto_program.output_instruction(ns, function_id, out, *i_it);
9797

9898
json_objectt location(
9999
{{"locationNumber", json_numbert(std::to_string(i_it->location_number))},
@@ -134,7 +134,7 @@ xmlt ai_baset::output_xml(
134134

135135
xmlt ai_baset::output_xml(
136136
const namespacet &ns,
137-
const irep_idt &function_identifier,
137+
const irep_idt &function_id,
138138
const goto_programt &goto_program) const
139139
{
140140
xmlt function_body;
@@ -149,7 +149,7 @@ xmlt ai_baset::output_xml(
149149

150150
// Ideally we need output_instruction_xml
151151
std::ostringstream out;
152-
goto_program.output_instruction(ns, function_identifier, out, *i_it);
152+
goto_program.output_instruction(ns, function_id, out, *i_it);
153153
location.set_attribute("instruction", out.str());
154154

155155
function_body.new_element(location);
@@ -176,7 +176,7 @@ void ai_baset::entry_state(const goto_programt &goto_program)
176176
}
177177

178178
void ai_baset::initialize(
179-
const irep_idt &function_identifier,
179+
const irep_idt &function_id,
180180
const goto_functionst::goto_functiont &goto_function)
181181
{
182182
initialize(function, goto_function.body);
@@ -214,7 +214,7 @@ ai_baset::locationt ai_baset::get_next(
214214
}
215215

216216
bool ai_baset::fixedpoint(
217-
const irep_idt &function_identifier,
217+
const irep_idt &function_id,
218218
const goto_programt &goto_program,
219219
const goto_functionst &goto_functions,
220220
const namespacet &ns)
@@ -234,16 +234,15 @@ bool ai_baset::fixedpoint(
234234
locationt l=get_next(working_set);
235235

236236
// goto_program is really only needed for iterator manipulation
237-
if(visit(
238-
function_identifier, l, working_set, goto_program, goto_functions, ns))
237+
if(visit(function_id, l, working_set, goto_program, goto_functions, ns))
239238
new_data=true;
240239
}
241240

242241
return new_data;
243242
}
244243

245244
bool ai_baset::visit(
246-
const irep_idt &function_identifier,
245+
const irep_idt &function_id,
247246
locationt l,
248247
working_sett &working_set,
249248
const goto_programt &goto_program,
@@ -274,7 +273,7 @@ bool ai_baset::visit(
274273
to_code_function_call(l->code);
275274

276275
if(do_function_call_rec(
277-
function_identifier,
276+
function_id,
278277
l,
279278
to_l,
280279
code.function(),
@@ -288,8 +287,7 @@ bool ai_baset::visit(
288287
// initialize state, if necessary
289288
get_state(to_l);
290289

291-
new_values.transform(
292-
function_identifier, l, function_identifier, to_l, *this, ns);
290+
new_values.transform(function_id, l, function_id, to_l, *this, ns);
293291

294292
if(merge(new_values, l, to_l))
295293
have_new_values=true;
@@ -306,7 +304,7 @@ bool ai_baset::visit(
306304
}
307305

308306
bool ai_baset::do_function_call(
309-
const irep_idt &calling_function_identifier,
307+
const irep_idt &calling_function_id,
310308
locationt l_call,
311309
locationt l_return,
312310
const goto_functionst &goto_functions,
@@ -327,12 +325,7 @@ bool ai_baset::do_function_call(
327325
// If we don't have a body, we just do an edge call -> return
328326
std::unique_ptr<statet> tmp_state(make_temporary_state(get_state(l_call)));
329327
tmp_state->transform(
330-
calling_function_identifier,
331-
l_call,
332-
calling_function_identifier,
333-
l_return,
334-
*this,
335-
ns);
328+
calling_function_id, l_call, calling_function_id, l_return, *this, ns);
336329

337330
return merge(*tmp_state, l_call, l_return);
338331
}
@@ -350,7 +343,7 @@ bool ai_baset::do_function_call(
350343
// do the edge from the call site to the beginning of the function
351344
std::unique_ptr<statet> tmp_state(make_temporary_state(get_state(l_call)));
352345
tmp_state->transform(
353-
calling_function_identifier, l_call, f_it->first, l_begin, *this, ns);
346+
calling_function_id, l_call, f_it->first, l_begin, *this, ns);
354347

355348
bool new_data=false;
356349

@@ -378,15 +371,15 @@ bool ai_baset::do_function_call(
378371

379372
std::unique_ptr<statet> tmp_state(make_temporary_state(end_state));
380373
tmp_state->transform(
381-
f_it->first, l_end, calling_function_identifier, l_return, *this, ns);
374+
f_it->first, l_end, calling_function_id, l_return, *this, ns);
382375

383376
// Propagate those
384377
return merge(*tmp_state, l_end, l_return);
385378
}
386379
}
387380

388381
bool ai_baset::do_function_call_rec(
389-
const irep_idt &calling_function_identifier,
382+
const irep_idt &calling_function_id,
390383
locationt l_call,
391384
locationt l_return,
392385
const exprt &function,
@@ -414,13 +407,7 @@ bool ai_baset::do_function_call_rec(
414407
"Function " + id2string(identifier) + "not in function map");
415408

416409
new_data = do_function_call(
417-
calling_function_identifier,
418-
l_call,
419-
l_return,
420-
goto_functions,
421-
it,
422-
arguments,
423-
ns);
410+
calling_function_id, l_call, l_return, goto_functions, it, arguments, ns);
424411

425412
return new_data;
426413
}
@@ -454,16 +441,16 @@ void ai_baset::concurrent_fixedpoint(
454441
struct wl_entryt
455442
{
456443
wl_entryt(
457-
const irep_idt &_function_identifier,
444+
const irep_idt &_function_id,
458445
const goto_programt &_goto_program,
459446
locationt _location)
460-
: function_identifier(_function_identifier),
447+
: function_id(_function_id),
461448
goto_program(&_goto_program),
462449
location(_location)
463450
{
464451
}
465452

466-
irep_idt function_identifier;
453+
irep_idt function_id;
467454
const goto_programt *goto_program;
468455
locationt location;
469456
};
@@ -506,7 +493,7 @@ void ai_baset::concurrent_fixedpoint(
506493
goto_programt::const_targett l=get_next(working_set);
507494

508495
visit(
509-
wl_entry.function_identifier,
496+
wl_entry.function_id,
510497
l,
511498
working_set,
512499
*(wl_entry.goto_program),

src/analyses/ai.h

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ class ai_baset
4545

4646
/// Run abstract interpretation on a single function
4747
void operator()(
48-
const irep_idt &function_identifier,
48+
const irep_idt &function_id,
4949
const goto_programt &goto_program,
5050
const namespacet &ns)
5151
{
5252
goto_functionst goto_functions;
53-
initialize(function_identifier, goto_program);
53+
initialize(function_id, goto_program);
5454
entry_state(goto_program);
55-
fixedpoint(function_identifier, goto_program, goto_functions, ns);
55+
fixedpoint(function_id, goto_program, goto_functions, ns);
5656
finalize();
5757
}
5858

@@ -79,14 +79,14 @@ class ai_baset
7979

8080
/// Run abstract interpretation on a single function
8181
void operator()(
82-
const irep_idt &function_identifier,
82+
const irep_idt &function_id,
8383
const goto_functionst::goto_functiont &goto_function,
8484
const namespacet &ns)
8585
{
8686
goto_functionst goto_functions;
87-
initialize(function_identifier, goto_function);
87+
initialize(function_id, goto_function);
8888
entry_state(goto_function.body);
89-
fixedpoint(function_identifier, goto_function.body, goto_functions, ns);
89+
fixedpoint(function_id, goto_function.body, goto_functions, ns);
9090
finalize();
9191
}
9292

@@ -126,13 +126,13 @@ class ai_baset
126126

127127
/// Output the abstract states for a single function
128128
/// \param ns: The namespace
129-
/// \param function_identifier: The identifier used to find a symbol to
129+
/// \param function_id: The identifier used to find a symbol to
130130
/// identify the \p goto_program's source language
131131
/// \param goto_program: The goto program
132132
/// \param out: The ostream to direct output to
133133
virtual void output(
134134
const namespacet &ns,
135-
const irep_idt &function_identifier,
135+
const irep_idt &function_id,
136136
const goto_programt &goto_program,
137137
std::ostream &out) const;
138138

@@ -221,13 +221,12 @@ class ai_baset
221221
protected:
222222
/// Initialize all the abstract states for a single function. Override this to
223223
/// do custom per-domain initialization.
224-
virtual void initialize(
225-
const irep_idt &function_identifier,
226-
const goto_programt &goto_program);
224+
virtual void
225+
initialize(const irep_idt &function_id, const goto_programt &goto_program);
227226

228227
/// Initialize all the abstract states for a single function.
229228
virtual void initialize(
230-
const irep_idt &function_identifier,
229+
const irep_idt &function_id,
231230
const goto_functionst::goto_functiont &goto_function);
232231

233232
/// Initialize all the abstract states for a whole program. Override this to
@@ -249,23 +248,23 @@ class ai_baset
249248
/// Output the abstract states for a single function as JSON
250249
/// \param ns: The namespace
251250
/// \param goto_program: The goto program
252-
/// \param function_identifier: The identifier used to find a symbol to
251+
/// \param function_id: The identifier used to find a symbol to
253252
/// identify the source language
254253
/// \return The JSON object
255254
virtual jsont output_json(
256255
const namespacet &ns,
257-
const irep_idt &function_identifier,
256+
const irep_idt &function_id,
258257
const goto_programt &goto_program) const;
259258

260259
/// Output the abstract states for a single function as XML
261260
/// \param ns: The namespace
262261
/// \param goto_program: The goto program
263-
/// \param function_identifier: The identifier used to find a symbol to
262+
/// \param function_id: The identifier used to find a symbol to
264263
/// identify the source language
265264
/// \return The XML object
266265
virtual xmlt output_xml(
267266
const namespacet &ns,
268-
const irep_idt &function_identifier,
267+
const irep_idt &function_id,
269268
const goto_programt &goto_program) const;
270269

271270
/// The work queue, sorted by location number
@@ -285,7 +284,7 @@ class ai_baset
285284
/// Run the fixedpoint algorithm until it reaches a fixed point
286285
/// \return True if we found something new
287286
bool fixedpoint(
288-
const irep_idt &function_identifier,
287+
const irep_idt &function_id,
289288
const goto_programt &goto_program,
290289
const goto_functionst &goto_functions,
291290
const namespacet &ns);
@@ -307,7 +306,7 @@ class ai_baset
307306
/// or applications of the abstract transformer
308307
/// \return True if the state was changed
309308
bool visit(
310-
const irep_idt &function_identifier,
309+
const irep_idt &function_id,
311310
locationt l,
312311
working_sett &working_set,
313312
const goto_programt &goto_program,
@@ -316,7 +315,7 @@ class ai_baset
316315

317316
// function calls
318317
bool do_function_call_rec(
319-
const irep_idt &calling_function_identifier,
318+
const irep_idt &calling_function_id,
320319
locationt l_call,
321320
locationt l_return,
322321
const exprt &function,
@@ -325,7 +324,7 @@ class ai_baset
325324
const namespacet &ns);
326325

327326
bool do_function_call(
328-
const irep_idt &calling_function_identifier,
327+
const irep_idt &calling_function_id,
329328
locationt l_call,
330329
locationt l_return,
331330
const goto_functionst &goto_functions,

0 commit comments

Comments
 (0)