Skip to content

Commit 5ecb15e

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#671 from peterschrammel/cover-for-reachable-fun-only
Cover (and others) for reachable functions only
2 parents 6550e2c + 5e5bbca commit 5ecb15e

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

src/cbmc/cbmc_parse_options.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -540,19 +540,6 @@ int cbmc_parse_optionst::doit()
540540
return 0; // should contemplate EX_OK from sysexits.h
541541
}
542542

543-
// may replace --show-properties
544-
if(cmdline.isset("show-reachable-properties"))
545-
{
546-
const namespacet ns(symbol_table);
547-
548-
// Entry point will have been set before and function pointers removed
549-
status() << "Removing Unused Functions" << eom;
550-
remove_unused_functions(goto_functions, ui_message_handler);
551-
552-
show_properties(ns, get_ui(), goto_functions);
553-
return 0; // should contemplate EX_OK from sysexits.h
554-
}
555-
556543
if(set_properties(goto_functions))
557544
return 7; // should contemplate EX_USAGE from sysexits.h
558545

@@ -952,8 +939,14 @@ bool cbmc_parse_optionst::process_goto_program(
952939
// add loop ids
953940
goto_functions.compute_loop_numbers();
954941

955-
// instrument cover goals
942+
if(cmdline.isset("drop-unused-functions"))
943+
{
944+
// Entry point will have been set before and function pointers removed
945+
status() << "Removing Unused Functions" << eom;
946+
remove_unused_functions(goto_functions, ui_message_handler);
947+
}
956948

949+
// instrument cover goals
957950
if(cmdline.isset("cover"))
958951
{
959952
std::list<std::string> criteria_strings=
@@ -1099,6 +1092,7 @@ void cbmc_parse_optionst::help()
10991092
" --property id only check one specific property\n"
11001093
" --stop-on-fail stop analysis once a failed property is detected\n" // NOLINT(*)
11011094
" --trace give a counterexample trace for failed properties\n" //NOLINT(*)
1095+
" --drop-unused-functions drop functions trivially unreachable from main function\n" // NOLINT(*)
11021096
"\n"
11031097
"C/C++ frontend options:\n"
11041098
" -I path set include path (C/C++)\n"

src/cbmc/cbmc_parse_options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class optionst;
4141
"(little-endian)(big-endian)" \
4242
"(show-goto-functions)(show-loops)" \
4343
"(show-symbol-table)(show-parse-tree)(show-vcc)" \
44-
"(show-claims)(claim):(show-properties)(show-reachable-properties)" \
44+
"(show-claims)(claim):(show-properties)" \
45+
"(drop-unused-functions)" \
4546
"(property):(stop-on-fail)(trace)" \
4647
"(error-label):(verbosity):(no-library)" \
4748
"(nondet-static)" \

src/goto-programs/show_goto_functions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class goto_modelt;
1919
"(show-goto-functions)"
2020

2121
#define HELP_SHOW_GOTO_FUNCTIONS \
22-
" --show-goto-functions show goto program\n"
22+
" --show-goto-functions show goto program\n"
2323

2424
void show_goto_functions(
2525
const namespacet &ns,

src/symex/symex_parse_options.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Author: Daniel Kroening, [email protected]
3434
#include <goto-programs/remove_virtual_functions.h>
3535
#include <goto-programs/remove_exceptions.h>
3636
#include <goto-programs/remove_instanceof.h>
37+
#include <goto-programs/remove_unused_functions.h>
3738

3839
#include <goto-symex/rewrite_union.h>
3940
#include <goto-symex/adjust_float_expressions.h>
@@ -383,6 +384,13 @@ bool symex_parse_optionst::process_goto_program(const optionst &options)
383384
// add loop ids
384385
goto_model.goto_functions.compute_loop_numbers();
385386

387+
if(cmdline.isset("drop-unused-functions"))
388+
{
389+
// Entry point will have been set before and function pointers removed
390+
status() << "Removing Unused Functions" << eom;
391+
remove_unused_functions(goto_model.goto_functions, ui_message_handler);
392+
}
393+
386394
if(cmdline.isset("cover"))
387395
{
388396
std::string criterion=cmdline.get_value("cover");
@@ -683,6 +691,7 @@ void symex_parse_optionst::help()
683691
" --stop-on-fail stop analysis once a failed property is detected\n"
684692
// NOLINTNEXTLINE(whitespace/line_length)
685693
" --trace give a counterexample trace for failed properties\n"
694+
" --drop-unused-functions drop functions trivially unreachable from main function\n" // NOLINT(*)
686695
"\n"
687696
"Frontend options:\n"
688697
" -I path set include path (C/C++)\n"

src/symex/symex_parse_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class optionst;
4141
"(string-abstraction)(no-arch)(arch):(floatbv)(fixedbv)" \
4242
"(round-to-nearest)(round-to-plus-inf)(round-to-minus-inf)(round-to-zero)" \
4343
"(show-locs)(show-vcc)(show-properties)" \
44+
"(drop-unused-functions)" \
4445
OPT_SHOW_GOTO_FUNCTIONS \
4546
"(property):(trace)(show-trace)(stop-on-fail)(eager-infeasibility)" \
4647
"(no-simplify)(no-unwinding-assertions)(no-propagation)"

0 commit comments

Comments
 (0)