Skip to content

Commit bb3dcb4

Browse files
author
martin
committed
Move the majority of process_goto_program out of the individual tools
This requires resolving a difference in the wording of a status message that breaks a lot of tests for function pointer removal.
1 parent 00aacd8 commit bb3dcb4

File tree

4 files changed

+110
-213
lines changed

4 files changed

+110
-213
lines changed

src/cbmc/cbmc_parse_options.cpp

Lines changed: 3 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,18 @@ Author: Daniel Kroening, [email protected]
4949
#include <goto-checker/stop_on_fail_verifier_with_fault_localization.h>
5050

5151
#include <goto-programs/add_malloc_may_fail_variable_initializations.h>
52-
#include <goto-programs/adjust_float_expressions.h>
5352
#include <goto-programs/goto_inline.h>
5453
#include <goto-programs/initialize_goto_model.h>
55-
#include <goto-programs/instrument_preconditions.h>
5654
#include <goto-programs/link_to_library.h>
5755
#include <goto-programs/loop_ids.h>
58-
#include <goto-programs/mm_io.h>
5956
#include <goto-programs/process_goto_program.h>
6057
#include <goto-programs/read_goto_binary.h>
61-
#include <goto-programs/remove_complex.h>
62-
#include <goto-programs/remove_function_pointers.h>
63-
#include <goto-programs/remove_returns.h>
6458
#include <goto-programs/remove_skip.h>
6559
#include <goto-programs/remove_unused_functions.h>
66-
#include <goto-programs/remove_vector.h>
67-
#include <goto-programs/rewrite_union.h>
6860
#include <goto-programs/set_properties.h>
6961
#include <goto-programs/show_goto_functions.h>
7062
#include <goto-programs/show_properties.h>
7163
#include <goto-programs/show_symbol_table.h>
72-
#include <goto-programs/string_abstraction.h>
73-
#include <goto-programs/string_instrumentation.h>
7464
#include <goto-programs/validate_goto_model.h>
7565

7666
#include <goto-instrument/cover.h>
@@ -903,9 +893,6 @@ bool cbmc_parse_optionst::process_goto_program(
903893
const optionst &options,
904894
messaget &log)
905895
{
906-
// Common removal of types and complex constructs
907-
::process_goto_program(goto_model, options, log);
908-
909896
// Remove inline assembler; this needs to happen before
910897
// adding the library.
911898
remove_asm(goto_model);
@@ -920,54 +907,9 @@ bool cbmc_parse_optionst::process_goto_program(
920907

921908
add_malloc_may_fail_variable_initializations(goto_model);
922909

923-
if(options.get_bool_option("string-abstraction"))
924-
string_instrumentation(goto_model);
925-
926-
// remove function pointers
927-
log.status() << "Removal of function pointers and virtual functions"
928-
<< messaget::eom;
929-
remove_function_pointers(
930-
log.get_message_handler(),
931-
goto_model,
932-
options.get_bool_option("pointer-check"));
933-
934-
mm_io(goto_model);
935-
936-
// instrument library preconditions
937-
instrument_preconditions(goto_model);
938-
939-
// do partial inlining
940-
if(options.get_bool_option("partial-inline"))
941-
{
942-
log.status() << "Partial Inlining" << messaget::eom;
943-
goto_partial_inline(goto_model, log.get_message_handler());
944-
}
945-
946-
// remove returns, gcc vectors, complex
947-
remove_returns(goto_model);
948-
remove_vector(goto_model);
949-
remove_complex(goto_model);
950-
if(options.get_bool_option("rewrite-union"))
951-
rewrite_union(goto_model);
952-
953-
// add generic checks
954-
log.status() << "Generic Property Instrumentation" << messaget::eom;
955-
goto_check(options, goto_model);
956-
957-
// checks don't know about adjusted float expressions
958-
adjust_float_expressions(goto_model);
959-
960-
if(options.get_bool_option("string-abstraction"))
961-
{
962-
log.status() << "String Abstraction" << messaget::eom;
963-
string_abstraction(goto_model, log.get_message_handler());
964-
}
965-
966-
// recalculate numbers, etc.
967-
goto_model.goto_functions.update();
968-
969-
// add loop ids
970-
goto_model.goto_functions.compute_loop_numbers();
910+
// Common removal of types and complex constructs
911+
if(::process_goto_program(goto_model, options, log))
912+
return true;
971913

972914
// ignore default/user-specified initialization
973915
// of variables with static lifetime

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 12 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,16 @@ Author: Daniel Kroening, [email protected]
2727
#include <jsil/jsil_language.h>
2828

2929
#include <goto-programs/add_malloc_may_fail_variable_initializations.h>
30-
#include <goto-programs/adjust_float_expressions.h>
3130
#include <goto-programs/goto_convert_functions.h>
3231
#include <goto-programs/goto_inline.h>
3332
#include <goto-programs/initialize_goto_model.h>
34-
#include <goto-programs/instrument_preconditions.h>
3533
#include <goto-programs/link_to_library.h>
36-
#include <goto-programs/mm_io.h>
3734
#include <goto-programs/process_goto_program.h>
3835
#include <goto-programs/read_goto_binary.h>
39-
#include <goto-programs/remove_complex.h>
40-
#include <goto-programs/remove_function_pointers.h>
41-
#include <goto-programs/remove_returns.h>
42-
#include <goto-programs/remove_vector.h>
4336
#include <goto-programs/remove_virtual_functions.h>
44-
#include <goto-programs/rewrite_union.h>
4537
#include <goto-programs/set_properties.h>
4638
#include <goto-programs/show_properties.h>
4739
#include <goto-programs/show_symbol_table.h>
48-
#include <goto-programs/string_abstraction.h>
49-
#include <goto-programs/string_instrumentation.h>
5040
#include <goto-programs/validate_goto_model.h>
5141

5242
#include <analyses/call_stack_history.h>
@@ -626,7 +616,6 @@ int goto_analyzer_parse_optionst::doit()
626616
/// Depending on the command line mode, run one of the analysis tasks
627617
int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
628618
{
629-
adjust_float_expressions(goto_model);
630619
if(options.get_bool_option("taint"))
631620
{
632621
std::string taint_file=cmdline.get_value("taint");
@@ -862,69 +851,22 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
862851
bool goto_analyzer_parse_optionst::process_goto_program(
863852
const optionst &options)
864853
{
865-
// Common removal of types and complex constructs
866-
::process_goto_program(goto_model, options, log);
867-
868-
{
869-
// Remove inline assembler; this needs to happen before
870-
// adding the library.
871-
remove_asm(goto_model);
872-
873-
// add the library
874-
log.status() << "Adding CPROVER library (" << config.ansi_c.arch << ")" << messaget::eom;
875-
link_to_library(
876-
goto_model, ui_message_handler, cprover_cpp_library_factory);
877-
link_to_library(goto_model, ui_message_handler, cprover_c_library_factory);
878-
879-
add_malloc_may_fail_variable_initializations(goto_model);
880-
881-
if(options.get_bool_option("string-abstraction"))
882-
string_instrumentation(goto_model);
883-
884-
// remove function pointers
885-
log.status() << "Removal of function pointers and virtual functions"
886-
<< messaget::eom;
887-
remove_function_pointers(
888-
ui_message_handler, goto_model, options.get_bool_option("pointer-check"));
889-
890-
mm_io(goto_model);
891-
892-
// instrument library preconditions
893-
instrument_preconditions(goto_model);
854+
// Remove inline assembler; this needs to happen before
855+
// adding the library.
856+
remove_asm(goto_model);
894857

895-
// do partial inlining
896-
if(options.get_bool_option("partial-inline"))
897-
{
898-
log.status() << "Partial Inlining" << messaget::eom;
899-
goto_partial_inline(goto_model, ui_message_handler);
900-
}
901-
902-
// remove returns, gcc vectors, complex
903-
remove_returns(goto_model);
904-
remove_vector(goto_model);
905-
remove_complex(goto_model);
906-
if(options.get_bool_option("rewrite-union"))
907-
rewrite_union(goto_model);
858+
// add the library
859+
log.status() << "Adding CPROVER library (" << config.ansi_c.arch << ")"
860+
<< messaget::eom;
861+
link_to_library(goto_model, ui_message_handler, cprover_cpp_library_factory);
862+
link_to_library(goto_model, ui_message_handler, cprover_c_library_factory);
908863

909-
// add generic checks
910-
log.status() << "Generic Property Instrumentation" << messaget::eom;
911-
goto_check(options, goto_model);
864+
add_malloc_may_fail_variable_initializations(goto_model);
912865

913-
// checks don't know about adjusted float expressions
914-
adjust_float_expressions(goto_model);
915-
916-
if(options.get_bool_option("string-abstraction"))
917-
{
918-
log.status() << "String Abstraction" << messaget::eom;
919-
string_abstraction(goto_model, log.get_message_handler());
920-
}
921-
922-
// recalculate numbers, etc.
923-
goto_model.goto_functions.update();
866+
// Common removal of types and complex constructs
867+
if(::process_goto_program(goto_model, options, log))
868+
return true;
924869

925-
// add loop ids
926-
goto_model.goto_functions.compute_loop_numbers();
927-
}
928870
return false;
929871
}
930872

src/goto-diff/goto_diff_parse_options.cpp

Lines changed: 33 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -258,94 +258,45 @@ bool goto_diff_parse_optionst::process_goto_program(
258258
const optionst &options,
259259
goto_modelt &goto_model)
260260
{
261+
// Remove inline assembler; this needs to happen before
262+
// adding the library.
263+
remove_asm(goto_model);
264+
265+
// add the library
266+
log.status() << "Adding CPROVER library (" << config.ansi_c.arch << ")"
267+
<< messaget::eom;
268+
link_to_library(goto_model, ui_message_handler, cprover_cpp_library_factory);
269+
link_to_library(goto_model, ui_message_handler, cprover_c_library_factory);
270+
271+
add_malloc_may_fail_variable_initializations(goto_model);
272+
261273
// Common removal of types and complex constructs
262-
::process_goto_program(goto_model, options, log);
274+
if(::process_goto_program(goto_model, options, log))
275+
return true;
263276

277+
// instrument cover goals
278+
if(cmdline.isset("cover"))
264279
{
265-
// Remove inline assembler; this needs to happen before
266-
// adding the library.
267-
remove_asm(goto_model);
268-
269-
// add the library
270-
log.status() << "Adding CPROVER library (" << config.ansi_c.arch << ")"
271-
<< messaget::eom;
272-
link_to_library(
273-
goto_model, ui_message_handler, cprover_cpp_library_factory);
274-
link_to_library(goto_model, ui_message_handler, cprover_c_library_factory);
275-
276-
add_malloc_may_fail_variable_initializations(goto_model);
277-
278-
if(options.get_bool_option("string-abstraction"))
279-
string_instrumentation(goto_model);
280-
281-
// remove function pointers
282-
log.status() << "Removal of function pointers and virtual functions"
283-
<< messaget::eom;
284-
remove_function_pointers(
285-
ui_message_handler, goto_model, options.get_bool_option("pointer-check"));
286-
287-
mm_io(goto_model);
288-
289-
// instrument library preconditions
290-
instrument_preconditions(goto_model);
291-
292-
// do partial inlining
293-
if(options.get_bool_option("partial-inline"))
294-
{
295-
log.status() << "Partial Inlining" << messaget::eom;
296-
goto_partial_inline(goto_model, ui_message_handler);
297-
}
298-
299-
// remove returns, gcc vectors, complex
300-
remove_returns(goto_model);
301-
remove_vector(goto_model);
302-
remove_complex(goto_model);
303-
if(options.get_bool_option("rewrite-union"))
304-
rewrite_union(goto_model);
305-
306-
// add generic checks
307-
log.status() << "Generic Property Instrumentation" << messaget::eom;
308-
goto_check(options, goto_model);
309-
310-
// checks don't know about adjusted float expressions
311-
adjust_float_expressions(goto_model);
312-
313-
if(options.get_bool_option("string-abstraction"))
314-
{
315-
log.status() << "String Abstraction" << messaget::eom;
316-
string_abstraction(goto_model, log.get_message_handler());
317-
}
318-
319-
// recalculate numbers, etc.
320-
goto_model.goto_functions.update();
321-
322-
// add loop ids
323-
goto_model.goto_functions.compute_loop_numbers();
324-
325-
// instrument cover goals
326-
if(cmdline.isset("cover"))
327-
{
328-
// remove skips such that trivial GOTOs are deleted and not considered
329-
// for coverage annotation:
330-
remove_skip(goto_model);
331-
332-
const auto cover_config =
333-
get_cover_config(options, goto_model.symbol_table, ui_message_handler);
334-
if(instrument_cover_goals(cover_config, goto_model, ui_message_handler))
335-
return true;
336-
}
337-
338-
// label the assertions
339-
// This must be done after adding assertions and
340-
// before using the argument of the "property" option.
341-
// Do not re-label after using the property slicer because
342-
// this would cause the property identifiers to change.
343-
label_properties(goto_model);
344-
345-
// remove any skips introduced since coverage instrumentation
280+
// remove skips such that trivial GOTOs are deleted and not considered
281+
// for coverage annotation:
346282
remove_skip(goto_model);
283+
284+
const auto cover_config =
285+
get_cover_config(options, goto_model.symbol_table, ui_message_handler);
286+
if(instrument_cover_goals(cover_config, goto_model, ui_message_handler))
287+
return true;
347288
}
348289

290+
// label the assertions
291+
// This must be done after adding assertions and
292+
// before using the argument of the "property" option.
293+
// Do not re-label after using the property slicer because
294+
// this would cause the property identifiers to change.
295+
label_properties(goto_model);
296+
297+
// remove any skips introduced since coverage instrumentation
298+
remove_skip(goto_model);
299+
349300
return false;
350301
}
351302

0 commit comments

Comments
 (0)