Skip to content

Commit 744f918

Browse files
authored
Merge pull request #2758 from nmanthey/upstream-slice-functions
Upstream slice functions
2 parents 273f375 + d86701c commit 744f918

File tree

14 files changed

+228
-13
lines changed

14 files changed

+228
-13
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
void a()
2+
{
3+
int e;
4+
}
5+
6+
void b()
7+
{
8+
double f;
9+
if(f == 0)
10+
a();
11+
}
12+
13+
void c()
14+
{
15+
int d;
16+
}
17+
18+
int main()
19+
{
20+
int k;
21+
if(k == 0)
22+
{
23+
int l;
24+
a();
25+
c();
26+
}
27+
else
28+
{
29+
b();
30+
}
31+
int n;
32+
a();
33+
return n;
34+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--fp-reachability-slice c
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
1: ASSUME FALSE
7+
dead e;
8+
dead d;
9+
--
10+
^warning: ignoring
11+
dead f;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
void a()
2+
{
3+
int e;
4+
}
5+
6+
void b()
7+
{
8+
double f;
9+
if(f == 0)
10+
a();
11+
}
12+
13+
void c()
14+
{
15+
int d;
16+
}
17+
18+
int main()
19+
{
20+
int k;
21+
if(k == 0)
22+
{
23+
int l;
24+
a();
25+
c();
26+
}
27+
else
28+
{
29+
b();
30+
}
31+
int n;
32+
a();
33+
return n;
34+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--fp-reachability-slice a,c
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
dead d;
7+
dead e;
8+
--
9+
^warning: ignoring
10+
dead f;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
void a()
2+
{
3+
int e;
4+
}
5+
6+
void b()
7+
{
8+
double f;
9+
if(f == 0)
10+
a();
11+
}
12+
13+
void c()
14+
{
15+
int d;
16+
}
17+
18+
int main()
19+
{
20+
int k;
21+
if(k == 0)
22+
{
23+
int l;
24+
a();
25+
c();
26+
}
27+
else
28+
{
29+
b();
30+
}
31+
int n;
32+
a();
33+
return n;
34+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--fp-reachability-slice b,c
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
1 file main.c line 34
7+
--
8+
^warning: ignoring
9+
dead d;
10+
dead e;
11+
dead f;

src/cbmc/cbmc_parse_options.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@ void cbmc_parse_optionst::help()
940940
" --cover CC create test-suite with coverage criterion CC\n" // NOLINT(*)
941941
" --mm MM memory consistency model for concurrent programs\n" // NOLINT(*)
942942
HELP_REACHABILITY_SLICER
943+
HELP_REACHABILITY_SLICER_FB
943944
" --full-slice run full slicer (experimental)\n" // NOLINT(*)
944945
" --drop-unused-functions drop functions trivially unreachable from main function\n" // NOLINT(*)
945946
"\n"

src/goto-instrument/full_slicer_class.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,23 @@ class assert_criteriont:public slicing_criteriont
113113
}
114114
};
115115

116+
class in_function_criteriont : public slicing_criteriont
117+
{
118+
public:
119+
explicit in_function_criteriont(const std::string &function_name)
120+
: target_function(function_name)
121+
{
122+
}
123+
124+
virtual bool operator()(goto_programt::const_targett target)
125+
{
126+
return target->function == target_function;
127+
}
128+
129+
protected:
130+
const irep_idt target_function;
131+
};
132+
116133
class properties_criteriont:public slicing_criteriont
117134
{
118135
public:

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,15 @@ void goto_instrument_parse_optionst::instrument_goto_program()
14301430
reachability_slicer(goto_model);
14311431
}
14321432

1433+
if(cmdline.isset("fp-reachability-slice"))
1434+
{
1435+
do_indirect_call_and_rtti_removal();
1436+
1437+
status() << "Performing a function pointer reachability slice" << eom;
1438+
function_path_reachability_slicer(
1439+
goto_model, cmdline.get_comma_separated_values("fp-reachability-slice"));
1440+
}
1441+
14331442
// full slice?
14341443
if(cmdline.isset("full-slice"))
14351444
{
@@ -1610,7 +1619,7 @@ void goto_instrument_parse_optionst::help()
16101619
" --render-cluster-function clusterises the dot by functions\n"
16111620
"\n"
16121621
"Slicing:\n"
1613-
" --reachability-slice slice away instructions that can't reach assertions\n" // NOLINT(*)
1622+
HELP_REACHABILITY_SLICER
16141623
" --full-slice slice away instructions that don't affect assertions\n" // NOLINT(*)
16151624
" --property id slice with respect to specific property only\n" // NOLINT(*)
16161625
" --slice-global-inits slice away initializations of unused global variables\n" // NOLINT(*)

src/goto-instrument/goto_instrument_parse_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Author: Daniel Kroening, [email protected]
7171
"(show-struct-alignment)(interval-analysis)(show-intervals)" \
7272
"(show-uninitialized)(show-locations)" \
7373
"(full-slice)(reachability-slice)(slice-global-inits)" \
74+
"(fp-reachability-slice):" \
7475
"(inline)(partial-inline)(function-inline):(log):(no-caching)" \
7576
OPT_REMOVE_CONST_FUNCTION_POINTERS \
7677
"(print-internal-representation)" \

0 commit comments

Comments
 (0)