Skip to content

Cover (and others) for reachable functions only #671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions src/cbmc/cbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,19 +540,6 @@ int cbmc_parse_optionst::doit()
return 0; // should contemplate EX_OK from sysexits.h
}

// may replace --show-properties
if(cmdline.isset("show-reachable-properties"))
{
const namespacet ns(symbol_table);

// Entry point will have been set before and function pointers removed
status() << "Removing Unused Functions" << eom;
remove_unused_functions(goto_functions, ui_message_handler);

show_properties(ns, get_ui(), goto_functions);
return 0; // should contemplate EX_OK from sysexits.h
}

if(set_properties(goto_functions))
return 7; // should contemplate EX_USAGE from sysexits.h

Expand Down Expand Up @@ -952,8 +939,14 @@ bool cbmc_parse_optionst::process_goto_program(
// add loop ids
goto_functions.compute_loop_numbers();

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

// instrument cover goals
if(cmdline.isset("cover"))
{
std::list<std::string> criteria_strings=
Expand Down Expand Up @@ -1099,6 +1092,7 @@ void cbmc_parse_optionst::help()
" --property id only check one specific property\n"
" --stop-on-fail stop analysis once a failed property is detected\n" // NOLINT(*)
" --trace give a counterexample trace for failed properties\n" //NOLINT(*)
" --drop-unused-functions drop functions trivially unreachable from main function\n" // NOLINT(*)
"\n"
"C/C++ frontend options:\n"
" -I path set include path (C/C++)\n"
Expand Down
3 changes: 2 additions & 1 deletion src/cbmc/cbmc_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class optionst;
"(little-endian)(big-endian)" \
"(show-goto-functions)(show-loops)" \
"(show-symbol-table)(show-parse-tree)(show-vcc)" \
"(show-claims)(claim):(show-properties)(show-reachable-properties)" \
"(show-claims)(claim):(show-properties)" \
"(drop-unused-functions)" \
"(property):(stop-on-fail)(trace)" \
"(error-label):(verbosity):(no-library)" \
"(nondet-static)" \
Expand Down
2 changes: 1 addition & 1 deletion src/goto-programs/show_goto_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class goto_modelt;
"(show-goto-functions)"

#define HELP_SHOW_GOTO_FUNCTIONS \
" --show-goto-functions show goto program\n"
" --show-goto-functions show goto program\n"

void show_goto_functions(
const namespacet &ns,
Expand Down
9 changes: 9 additions & 0 deletions src/symex/symex_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Author: Daniel Kroening, [email protected]
#include <goto-programs/remove_virtual_functions.h>
#include <goto-programs/remove_exceptions.h>
#include <goto-programs/remove_instanceof.h>
#include <goto-programs/remove_unused_functions.h>

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

if(cmdline.isset("drop-unused-functions"))
{
// Entry point will have been set before and function pointers removed
status() << "Removing Unused Functions" << eom;
remove_unused_functions(goto_model.goto_functions, ui_message_handler);
}

if(cmdline.isset("cover"))
{
std::string criterion=cmdline.get_value("cover");
Expand Down Expand Up @@ -683,6 +691,7 @@ void symex_parse_optionst::help()
" --stop-on-fail stop analysis once a failed property is detected\n"
// NOLINTNEXTLINE(whitespace/line_length)
" --trace give a counterexample trace for failed properties\n"
" --drop-unused-functions drop functions trivially unreachable from main function\n" // NOLINT(*)
"\n"
"Frontend options:\n"
" -I path set include path (C/C++)\n"
Expand Down
1 change: 1 addition & 0 deletions src/symex/symex_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class optionst;
"(string-abstraction)(no-arch)(arch):(floatbv)(fixedbv)" \
"(round-to-nearest)(round-to-plus-inf)(round-to-minus-inf)(round-to-zero)" \
"(show-locs)(show-vcc)(show-properties)" \
"(drop-unused-functions)" \
OPT_SHOW_GOTO_FUNCTIONS \
"(property):(trace)(show-trace)(stop-on-fail)(eager-infeasibility)" \
"(no-simplify)(no-unwinding-assertions)(no-propagation)"
Expand Down