Skip to content

Commit 02c4ac6

Browse files
author
Daniel Kroening
authored
Merge pull request #1303 from diffblue/cleanup-goto-inline
Cleanup goto inline
2 parents 3dd8fe5 + 9e43500 commit 02c4ac6

File tree

3 files changed

+111
-230
lines changed

3 files changed

+111
-230
lines changed

src/goto-programs/goto_inline.cpp

+31-30
Original file line numberDiff line numberDiff line change
@@ -49,40 +49,42 @@ void goto_inline(
4949

5050
typedef goto_functionst::goto_functiont goto_functiont;
5151

52-
// find entry point
53-
goto_functionst::function_mapt::iterator it=
54-
goto_functions.function_map.find(goto_functionst::entry_point());
52+
// find entry point
53+
goto_functionst::function_mapt::iterator it=
54+
goto_functions.function_map.find(goto_functionst::entry_point());
5555

56-
if(it==goto_functions.function_map.end())
57-
return;
56+
if(it==goto_functions.function_map.end())
57+
return;
5858

59-
goto_functiont &goto_function=it->second;
60-
assert(goto_function.body_available());
59+
goto_functiont &goto_function=it->second;
60+
DATA_INVARIANT(
61+
goto_function.body_available(),
62+
"body of entry point function must be available");
6163

62-
// gather all calls
63-
// we use non-transitive inlining to avoid the goto program
64-
// copying that goto_inlinet would do otherwise
65-
goto_inlinet::inline_mapt inline_map;
64+
// gather all calls
65+
// we use non-transitive inlining to avoid the goto program
66+
// copying that goto_inlinet would do otherwise
67+
goto_inlinet::inline_mapt inline_map;
6668

67-
Forall_goto_functions(f_it, goto_functions)
68-
{
69-
goto_functiont &goto_function=f_it->second;
69+
Forall_goto_functions(f_it, goto_functions)
70+
{
71+
goto_functiont &goto_function=f_it->second;
7072

71-
if(!goto_function.body_available())
72-
continue;
73+
if(!goto_function.body_available())
74+
continue;
7375

74-
goto_inlinet::call_listt &call_list=inline_map[f_it->first];
76+
goto_inlinet::call_listt &call_list=inline_map[f_it->first];
7577

76-
goto_programt &goto_program=goto_function.body;
78+
goto_programt &goto_program=goto_function.body;
7779

78-
Forall_goto_program_instructions(i_it, goto_program)
79-
{
80-
if(!goto_inlinet::is_call(i_it))
81-
continue;
80+
Forall_goto_program_instructions(i_it, goto_program)
81+
{
82+
if(!i_it->is_function_call())
83+
continue;
8284

83-
call_list.push_back(goto_inlinet::callt(i_it, false));
84-
}
85+
call_list.push_back(goto_inlinet::callt(i_it, false));
8586
}
87+
}
8688

8789
goto_inline.goto_inline(
8890
goto_functionst::entry_point(), goto_function, inline_map, true);
@@ -164,14 +166,13 @@ void goto_partial_inline(
164166

165167
Forall_goto_program_instructions(i_it, goto_program)
166168
{
167-
if(!goto_inlinet::is_call(i_it))
169+
if(!i_it->is_function_call())
168170
continue;
169171

170172
exprt lhs;
171173
exprt function_expr;
172174
exprt::operandst arguments;
173-
exprt constrain;
174-
goto_inlinet::get_call(i_it, lhs, function_expr, arguments, constrain);
175+
goto_inlinet::get_call(i_it, lhs, function_expr, arguments);
175176

176177
if(function_expr.id()!=ID_symbol)
177178
// Can't handle pointers to functions
@@ -199,7 +200,7 @@ void goto_partial_inline(
199200
if(goto_function.is_inlined() ||
200201
goto_program.instructions.size()<=smallfunc_limit)
201202
{
202-
assert(goto_inlinet::is_call(i_it));
203+
INVARIANT(i_it->is_function_call(), "is a call");
203204
call_list.push_back(goto_inlinet::callt(i_it, false));
204205
}
205206
}
@@ -273,7 +274,7 @@ void goto_function_inline(
273274

274275
Forall_goto_program_instructions(i_it, goto_program)
275276
{
276-
if(!goto_inlinet::is_call(i_it))
277+
if(!i_it->is_function_call())
277278
continue;
278279

279280
call_list.push_back(goto_inlinet::callt(i_it, true));
@@ -318,7 +319,7 @@ jsont goto_function_inline_and_log(
318319

319320
Forall_goto_program_instructions(i_it, goto_program)
320321
{
321-
if(!goto_inlinet::is_call(i_it))
322+
if(!i_it->is_function_call())
322323
continue;
323324

324325
call_list.push_back(goto_inlinet::callt(i_it, true));

0 commit comments

Comments
 (0)