@@ -20,16 +20,23 @@ Author: Peter Schrammel
20
20
#include < util/config.h>
21
21
#include < util/options.h>
22
22
#include < util/make_unique.h>
23
+ #include < util/exit_codes.h>
23
24
24
25
#include < langapi/language.h>
25
26
26
27
#include < goto-programs/goto_convert_functions.h>
28
+ #include < goto-programs/instrument_preconditions.h>
29
+ #include < goto-programs/mm_io.h>
27
30
#include < goto-programs/remove_function_pointers.h>
31
+ #include < goto-programs/remove_virtual_functions.h>
32
+ #include < goto-programs/remove_instanceof.h>
28
33
#include < goto-programs/remove_returns.h>
34
+ #include < goto-programs/remove_exceptions.h>
29
35
#include < goto-programs/remove_vector.h>
30
36
#include < goto-programs/remove_complex.h>
31
37
#include < goto-programs/remove_asm.h>
32
38
#include < goto-programs/remove_unused_functions.h>
39
+ #include < goto-programs/remove_skip.h>
33
40
#include < goto-programs/goto_inline.h>
34
41
#include < goto-programs/show_properties.h>
35
42
#include < goto-programs/set_properties.h>
@@ -39,6 +46,11 @@ Author: Peter Schrammel
39
46
#include < goto-programs/loop_ids.h>
40
47
#include < goto-programs/link_to_library.h>
41
48
49
+ #include < goto-symex/rewrite_union.h>
50
+ #include < goto-symex/adjust_float_expressions.h>
51
+
52
+ #include < goto-instrument/cover.h>
53
+
42
54
#include < pointer-analysis/add_failed_symbols.h>
43
55
44
56
#include < langapi/mode.h>
@@ -99,7 +111,7 @@ void goto_diff_parse_optionst::get_command_line_options(optionst &options)
99
111
options.set_option (" show-vcc" , true );
100
112
101
113
if (cmdline.isset (" cover" ))
102
- options. set_option ( " cover " , cmdline. get_value ( " cover " ) );
114
+ parse_cover_options (cmdline, options );
103
115
104
116
if (cmdline.isset (" mm" ))
105
117
options.set_option (" mm" , cmdline.get_value (" mm" ));
@@ -122,22 +134,8 @@ void goto_diff_parse_optionst::get_command_line_options(optionst &options)
122
134
if (cmdline.isset (" cpp11" ))
123
135
config.cpp .set_cpp11 ();
124
136
125
- if (cmdline.isset (" no-simplify" ))
126
- options.set_option (" simplify" , false );
127
- else
128
- options.set_option (" simplify" , true );
129
-
130
- if (cmdline.isset (" all-claims" ) || // will go away
131
- cmdline.isset (" all-properties" )) // use this one
132
- options.set_option (" all-properties" , true );
133
- else
134
- options.set_option (" all-properties" , false );
135
-
136
- if (cmdline.isset (" unwind" ))
137
- options.set_option (" unwind" , cmdline.get_value (" unwind" ));
138
-
139
- if (cmdline.isset (" depth" ))
140
- options.set_option (" depth" , cmdline.get_value (" depth" ));
137
+ // all checks supported by goto_check
138
+ PARSE_OPTIONS_GOTO_CHECK (cmdline, options);
141
139
142
140
if (cmdline.isset (" debug-level" ))
143
141
options.set_option (" debug-level" , cmdline.get_value (" debug-level" ));
@@ -308,10 +306,6 @@ int goto_diff_parse_optionst::doit()
308
306
cmdline.isset (" forward-impact" ) ||
309
307
cmdline.isset (" backward-impact" ))
310
308
{
311
- // Workaround to avoid deps not propagating between return and end_func
312
- remove_returns (goto_model1);
313
- remove_returns (goto_model2);
314
-
315
309
impact_modet impact_mode=
316
310
cmdline.isset (" forward-impact" ) ?
317
311
impact_modet::FORWARD :
@@ -393,6 +387,9 @@ int goto_diff_parse_optionst::get_goto_program(
393
387
goto_model.goto_functions ,
394
388
ui_message_handler);
395
389
390
+ if (process_goto_program (options, goto_model))
391
+ return 6 ;
392
+
396
393
// if we had a second argument then we will handle it next
397
394
if (arg2!=" " )
398
395
cmdline.args [0 ]=arg2;
@@ -405,46 +402,72 @@ bool goto_diff_parse_optionst::process_goto_program(
405
402
const optionst &options,
406
403
goto_modelt &goto_model)
407
404
{
408
- symbol_tablet &symbol_table = goto_model.symbol_table ;
409
- goto_functionst &goto_functions = goto_model.goto_functions ;
410
-
411
405
try
412
406
{
413
- namespacet ns (symbol_table);
414
-
415
407
// Remove inline assembler; this needs to happen before
416
408
// adding the library.
417
409
remove_asm (goto_model);
418
410
419
411
// add the library
420
- link_to_library (symbol_table, goto_functions, ui_message_handler );
412
+ link_to_library (goto_model, get_message_handler () );
421
413
422
414
// remove function pointers
423
- status () << " Function Pointer Removal " << eom;
415
+ status () << " Removal of function pointers and virtual functions " << eom;
424
416
remove_function_pointers (
425
- get_message_handler (),
426
- symbol_table,
427
- goto_functions,
428
- cmdline.isset (" pointer-check" ));
417
+ get_message_handler (), goto_model, cmdline.isset (" pointer-check" ));
418
+
419
+ // Java virtual functions -> explicit dispatch tables:
420
+ remove_virtual_functions (goto_model);
421
+ // remove catch and throw
422
+ remove_exceptions (goto_model);
423
+ // Java instanceof -> clsid comparison:
424
+ remove_instanceof (goto_model);
429
425
430
- // do partial inlining
431
- status () << " Partial Inlining" << eom;
432
- goto_partial_inline (goto_functions, ns, ui_message_handler);
426
+ mm_io (goto_model);
427
+
428
+ // instrument library preconditions
429
+ instrument_preconditions (goto_model);
433
430
434
431
// remove returns, gcc vectors, complex
435
- remove_returns (symbol_table, goto_functions);
436
- remove_vector (symbol_table, goto_functions);
437
- remove_complex (symbol_table, goto_functions);
432
+ remove_returns (goto_model);
433
+ remove_vector (goto_model);
434
+ remove_complex (goto_model);
435
+ rewrite_union (goto_model);
436
+
437
+ // add generic checks
438
+ status () << " Generic Property Instrumentation" << eom;
439
+ goto_check (options, goto_model);
438
440
439
- // add failed symbols
440
- // needs to be done before pointer analysis
441
- add_failed_symbols (symbol_table);
441
+ // checks don't know about adjusted float expressions
442
+ adjust_float_expressions (goto_model);
442
443
443
444
// recalculate numbers, etc.
444
- goto_functions.update ();
445
+ goto_model. goto_functions .update ();
445
446
446
447
// add loop ids
447
- goto_functions.compute_loop_numbers ();
448
+ goto_model.goto_functions .compute_loop_numbers ();
449
+
450
+ // remove skips such that trivial GOTOs are deleted and not considered
451
+ // for coverage annotation:
452
+ remove_skip (goto_model);
453
+
454
+ // instrument cover goals
455
+ if (cmdline.isset (" cover" ))
456
+ {
457
+ if (instrument_cover_goals (options, goto_model, get_message_handler ()))
458
+ return true ;
459
+ }
460
+
461
+ // label the assertions
462
+ // This must be done after adding assertions and
463
+ // before using the argument of the "property" option.
464
+ // Do not re-label after using the property slicer because
465
+ // this would cause the property identifiers to change.
466
+ label_properties (goto_model);
467
+
468
+ // remove any skips introduced since coverage instrumentation
469
+ remove_skip (goto_model);
470
+ goto_model.goto_functions .update ();
448
471
}
449
472
450
473
catch (const char *e)
@@ -459,14 +482,16 @@ bool goto_diff_parse_optionst::process_goto_program(
459
482
return true ;
460
483
}
461
484
462
- catch (int )
485
+ catch (int e )
463
486
{
487
+ error () << " Numeric exception: " << e << eom;
464
488
return true ;
465
489
}
466
490
467
491
catch (const std::bad_alloc &)
468
492
{
469
493
error () << " Out of memory" << eom;
494
+ exit (CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY);
470
495
return true ;
471
496
}
472
497
@@ -476,6 +501,7 @@ bool goto_diff_parse_optionst::process_goto_program(
476
501
// / display command line help
477
502
void goto_diff_parse_optionst::help ()
478
503
{
504
+ // clang-format off
479
505
std::cout <<
480
506
" \n "
481
507
// NOLINTNEXTLINE(whitespace/line_length)
@@ -498,9 +524,15 @@ void goto_diff_parse_optionst::help()
498
524
" --backward-impact output unified diff with forward&backward/forward/backward dependencies\n "
499
525
" --compact-output output dependencies in compact mode\n "
500
526
" \n "
527
+ " Program instrumentation options:\n "
528
+ HELP_GOTO_CHECK
529
+ " --cover CC create test-suite with coverage criterion CC\n " // NOLINT(*)
530
+ " Java Bytecode frontend options:\n "
531
+ JAVA_BYTECODE_LANGUAGE_OPTIONS_HELP
501
532
" Other options:\n "
502
533
" --version show version and exit\n "
503
534
" --json-ui use JSON-formatted output\n "
504
535
HELP_TIMESTAMP
505
536
" \n " ;
537
+ // clang-format on
506
538
}
0 commit comments