File tree 9 files changed +52
-20
lines changed
contracts/function_check_04 9 files changed +52
-20
lines changed Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ static int foo ()
4
+ {
5
+ assert (1 < 0 );
6
+ }
7
+
8
+ void bar ()
9
+ {
10
+ foo ();
11
+ }
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ static int foo ()
4
+ {
5
+ assert (0 );
6
+ }
7
+
8
+ void bar ();
9
+
10
+ int main ()
11
+ {
12
+ foo ();
13
+ bar ();
14
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ bar.c
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION FAILED$
7
+ --
8
+ ^warning: ignoring
9
+ assertion\.2
10
+ --
11
+ Each of the assertions in the two functions named "foo" should have a unique
12
+ prefix, and thus be numbered "<prefix>.assertion.1."
Original file line number Diff line number Diff line change 4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
6
^\[main.assertion.1\] .* assertion x == 0: SUCCESS$
7
- ^\[foo .1\] line 9 .*: FAILURE$
7
+ ^\[__CPROVER_initialize .1\] line 9 .*: FAILURE$
8
8
^VERIFICATION FAILED$
9
9
--
10
10
--
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ void aggressive_slicert::doit()
100
100
auto property_loc = find_property (p, goto_model.goto_functions );
101
101
if (!property_loc.has_value ())
102
102
throw " unable to find property in call graph" ;
103
- note_functions_to_keep (property_loc. value (). get_function () );
103
+ note_functions_to_keep (property_loc-> first );
104
104
}
105
105
106
106
// Add functions within distance of shortest path functions
Original file line number Diff line number Diff line change @@ -67,13 +67,12 @@ void label_properties(
67
67
it->source_location_nonconst ().set_function (function_identifier);
68
68
}
69
69
70
- irep_idt function = it->source_location ().get_function ();
70
+ PRECONDITION (!function_identifier.empty ());
71
+ std::string prefix = id2string (function_identifier);
71
72
72
- std::string prefix=id2string (function);
73
73
if (!it->source_location ().get_property_class ().empty ())
74
74
{
75
- if (!prefix.empty ())
76
- prefix+=" ." ;
75
+ prefix += " ." ;
77
76
78
77
std::string class_infix =
79
78
id2string (it->source_location ().get_property_class ());
@@ -84,8 +83,7 @@ void label_properties(
84
83
prefix+=class_infix;
85
84
}
86
85
87
- if (!prefix.empty ())
88
- prefix+=" ." ;
86
+ prefix += " ." ;
89
87
90
88
std::size_t &count=property_counters[prefix];
91
89
Original file line number Diff line number Diff line change 19
19
20
20
#include " goto_model.h"
21
21
22
- optionalt<source_locationt> find_property (
23
- const irep_idt &property,
24
- const goto_functionst & goto_functions)
22
+ optionalt<std::pair<irep_idt, source_locationt>>
23
+ find_property (const irep_idt &property, const goto_functionst &goto_functions)
25
24
{
26
25
for (const auto &fct : goto_functions.function_map )
27
26
{
@@ -33,7 +32,7 @@ optionalt<source_locationt> find_property(
33
32
{
34
33
if (ins.source_location ().get_property_id () == property)
35
34
{
36
- return ins.source_location ();
35
+ return std::make_pair (fct. first , ins.source_location () );
37
36
}
38
37
}
39
38
}
Original file line number Diff line number Diff line change @@ -45,11 +45,10 @@ void show_properties(
45
45
// / \param property: irep_idt that identifies property
46
46
// / \param goto_functions: program in which to search for
47
47
// / the property
48
- // / \return optional<source_locationt> the location of the
48
+ // / \return A pair of function identifier and source location of the
49
49
// / property, if found.
50
- optionalt<source_locationt> find_property (
51
- const irep_idt &property,
52
- const goto_functionst &goto_functions);
50
+ optionalt<std::pair<irep_idt, source_locationt>>
51
+ find_property (const irep_idt &property, const goto_functionst &goto_functions);
53
52
54
53
// / \brief Collects the properties in the goto program into a `json_arrayt`
55
54
// / \param json_properties: JSON array to hold the properties
Original file line number Diff line number Diff line change @@ -197,14 +197,13 @@ irep_idt SSA_stept::get_property_id() const
197
197
else if (source.pc ->is_goto ())
198
198
{
199
199
// this is likely an unwinding assertion
200
- property_id = id2string (source.pc -> source_location (). get_function ()) +
201
- " .unwind. " + std::to_string (source.pc ->loop_number );
200
+ property_id = id2string (source.function_id ) + " .unwind. " +
201
+ std::to_string (source.pc ->loop_number );
202
202
}
203
203
else if (source.pc ->is_function_call ())
204
204
{
205
205
// this is likely a recursion unwinding assertion
206
- property_id =
207
- id2string (source.pc ->source_location ().get_function ()) + " .recursion" ;
206
+ property_id = id2string (source.function_id ) + " .recursion" ;
208
207
}
209
208
else
210
209
{
You can’t perform that action at this time.
0 commit comments