Skip to content

Commit 5e52cc8

Browse files
authored
Merge pull request diffblue#255 from diffblue/owen/precise-access-paths
Added a test and fixed some minor things in C++ code
2 parents b081635 + 500da4b commit 5e52cc8

File tree

6 files changed

+40
-13
lines changed

6 files changed

+40
-13
lines changed
-119 Bytes
Binary file not shown.
Binary file not shown.
399 Bytes
Binary file not shown.

regression/LVSA/TestPreciseAccessPaths/Test.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class Test {
55
A left_a;
66
A right_a;
77

8-
public class A {
8+
public static class A {
99
Object left_object;
1010
Object right_object;
1111
}
@@ -44,4 +44,19 @@ public void call_function_to_allocate_new_object(A param_A) {
4444
allocate_new_object(param_A);
4545
output = param_A.left_object;
4646
}
47+
48+
public static class ListNode {
49+
ListNode next;
50+
Object data;
51+
}
52+
53+
// Even with precise access paths we'll have to use an imprecise EVS for
54+
// output, because there are an unbounded number of precise access paths for
55+
// it: list_node, list_node.next, list_node.next.next, ...
56+
public void get_list_node(ListNode list_node, int index) {
57+
for (int i = 0; i < index; ++i) {
58+
list_node = list_node.next;
59+
}
60+
output = list_node.data;
61+
}
4762
}

regression/LVSA/TestPreciseAccessPaths/test_precise_access_paths.py

+11
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,14 @@ def test_call_function_to_allocate_new_object(tmpdir):
7171
output_value_expectation.check_number_of_values(2)
7272
output_value_expectation.check_contains_external_value_set()
7373
output_value_expectation.check_contains_dynamic_object()
74+
75+
76+
def test_get_list_node(tmpdir):
77+
# This test should not change when precise access paths have been implemented
78+
lvsa_driver = LvsaDriver(tmpdir, folder_name).with_test_function('get_list_node')
79+
lvsa_expectation = lvsa_driver.run()
80+
81+
output_value_expectation = lvsa_expectation.check_output()
82+
83+
output_value_expectation.check_number_of_values(1)
84+
output_value_expectation.check_contains_external_value_set()

src/pointer-analysis/local_value_set.h

+13-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class local_value_sett:public value_sett
1414
{
15-
public:
15+
public:
1616
typedef value_sett baset;
1717

1818
#ifdef USE_DSTRING
@@ -37,31 +37,32 @@ class local_value_sett:public value_sett
3737
const namespacet &ns,
3838
bool is_simplified) const override;
3939

40-
void get_value_set_rec(
41-
const exprt &expr,
42-
object_mapt &dest,
43-
const std::string &suffix,
44-
const typet &original_type,
45-
const namespacet &ns) const override;
46-
4740
void assign(
4841
const exprt &lhs,
4942
const exprt &rhs,
5043
const namespacet &ns,
5144
bool is_simplified,
5245
bool add_to_sets) override;
5346

47+
void apply_code(
48+
const codet &,
49+
const namespacet &) override;
50+
51+
protected:
52+
void get_value_set_rec(
53+
const exprt &expr,
54+
object_mapt &dest,
55+
const std::string &suffix,
56+
const typet &original_type,
57+
const namespacet &ns) const override;
58+
5459
void assign_rec(
5560
const exprt &lhs,
5661
const object_mapt &values_rhs,
5762
const std::string &suffix,
5863
const namespacet &ns,
5964
bool add_to_sets) override;
6065

61-
void apply_code(
62-
const codet &,
63-
const namespacet &) override;
64-
6566
void apply_side_effects(
6667
const exprt &rhs,
6768
const namespacet &ns);

0 commit comments

Comments
 (0)