Skip to content

Commit bfe3dd2

Browse files
Petr BauchPetr Bauch
Petr Bauch
authored and
Petr Bauch
committed
Fix based on reviews
1 parent ed85c7f commit bfe3dd2

File tree

6 files changed

+36
-17
lines changed

6 files changed

+36
-17
lines changed

src/cbmc/cbmc_parse_options.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,7 @@ void cbmc_parse_optionst::help()
933933
" --cover CC create test-suite with coverage criterion CC\n" // NOLINT(*)
934934
" --mm MM memory consistency model for concurrent programs\n" // NOLINT(*)
935935
HELP_REACHABILITY_SLICER
936+
HELP_REACHABILITY_SLICER_FB
936937
" --full-slice run full slicer (experimental)\n" // NOLINT(*)
937938
" --drop-unused-functions drop functions trivially unreachable from main function\n" // NOLINT(*)
938939
"\n"

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
14361436

14371437
status() << "Performing a function pointer reachability slice" << eom;
14381438
function_path_reachability_slicer(
1439-
goto_model, cmdline.get_value("fp-reachability-slice"));
1439+
goto_model, cmdline.get_comma_separated_values("fp-reachability-slice"));
14401440
}
14411441

14421442
// full slice?
@@ -1619,10 +1619,7 @@ void goto_instrument_parse_optionst::help()
16191619
" --render-cluster-function clusterises the dot by functions\n"
16201620
"\n"
16211621
"Slicing:\n"
1622-
" --fp-reachability-slice <f> remove instructions that cannot appear on a\n" // NOLINT(*)
1623-
" trace that visits all given functions. The list of functions has to be\n" // NOLINT(*)
1624-
" given as a comma separated list.\n"
1625-
" --reachability-slice slice away instructions that can't reach assertions\n" // NOLINT(*)
1622+
HELP_REACHABILITY_SLICER
16261623
" --full-slice slice away instructions that don't affect assertions\n" // NOLINT(*)
16271624
" --property id slice with respect to specific property only\n" // NOLINT(*)
16281625
" --slice-global-inits slice away initializations of unused global variables\n" // NOLINT(*)

src/goto-instrument/reachability_slicer.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,15 @@ void reachability_slicer(
245245
/// Perform reachability slicing on goto_model for selected functions.
246246
/// \param goto_model Goto program to slice
247247
/// \param functions_list The functions relevant for the slicing (i.e. starting
248-
/// point for the search in the cfg). Anything that is reachable in the CFG
248+
/// point for the search in the CFG). Anything that is reachable in the CFG
249249
/// starting from these functions will be kept.
250250
void function_path_reachability_slicer(
251251
goto_modelt &goto_model,
252-
const std::string &functions_list)
252+
const std::list<std::string> &functions_list)
253253
{
254-
std::istringstream functions_stream(functions_list);
255-
std::string single_function;
256-
while(std::getline(functions_stream, single_function, ','))
254+
for(const auto &function : functions_list)
257255
{
258-
in_function_criteriont matching_criterion(single_function);
256+
in_function_criteriont matching_criterion(function);
259257
reachability_slicert slicer;
260258
slicer(goto_model.goto_functions, matching_criterion, true);
261259
}

src/goto-instrument/reachability_slicer.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void reachability_slicer(
2525

2626
void function_path_reachability_slicer(
2727
goto_modelt &goto_model,
28-
const std::string &functions_list);
28+
const std::list<std::string> &functions_list);
2929

3030
void reachability_slicer(
3131
goto_modelt &,
@@ -41,12 +41,16 @@ void reachability_slicer(
4141
"(fp-reachability-slice):(reachability-slice)(reachability-slice-fb)" // NOLINT(*)
4242

4343
#define HELP_REACHABILITY_SLICER \
44-
" --fp-reachability-slice <f> remove instructions that cannot appear on a " \
45-
"trace that visits all given functions. The list of functions has to be " \
46-
"given as a comma separated list.\n" \
44+
" --fp-reachability-slice f remove instructions that cannot appear on a " \
45+
"trace\n that visits all given functions. The " \
46+
"list of\n functions has to be given as a " \
47+
"comma separated\n list f.\n" \
4748
" --reachability-slice remove instructions that cannot appear on a " \
48-
"trace from entry point to a property\n" \
49+
"trace\n from entry point to a property" \
50+
"\n" // NOLINT(*)
51+
#define HELP_REACHABILITY_SLICER_FB \
4952
" --reachability-slice-fb remove instructions that cannot appear on a " \
50-
"trace from entry point through a property\n" // NOLINT(*)
53+
"trace\n from entry point through a property" \
54+
"\n" // NOLINT(*)
5155
// clang-format on
5256
#endif // CPROVER_GOTO_INSTRUMENT_REACHABILITY_SLICER_H

src/util/cmdline.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,23 @@ const std::list<std::string> &cmdlinet::get_values(
118118
return immutable_empty_list;
119119
}
120120

121+
std::list<std::string>
122+
cmdlinet::get_comma_separated_values(const char *option) const
123+
{
124+
std::list<std::string> separated_values;
125+
auto i = getoptnr(option);
126+
if(i.has_value() && !options[*i].values.empty())
127+
{
128+
std::istringstream values_stream(options[*i].values.front());
129+
std::string single_value;
130+
while(std::getline(values_stream, single_value, ','))
131+
{
132+
separated_values.push_back(single_value);
133+
}
134+
}
135+
return separated_values;
136+
}
137+
121138
optionalt<std::size_t> cmdlinet::getoptnr(char option) const
122139
{
123140
for(std::size_t i=0; i<options.size(); i++)

src/util/cmdline.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class cmdlinet
2727
const std::list<std::string> &get_values(const std::string &option) const;
2828
const std::list<std::string> &get_values(char option) const;
2929

30+
std::list<std::string> get_comma_separated_values(const char *option) const;
31+
3032
virtual bool isset(char option) const;
3133
virtual bool isset(const char *option) const;
3234
virtual void set(const std::string &option);

0 commit comments

Comments
 (0)