Skip to content

Commit c5c615e

Browse files
author
owen-jones-diffblue
authored
Merge pull request diffblue#420 from diffblue/owen-jones-diffblue/lvsa-only-track-pointers
LVSA: don't bother tracking non-pointer-typed fields
2 parents e7393ba + 6eddd7e commit c5c615e

File tree

7 files changed

+31
-0
lines changed

7 files changed

+31
-0
lines changed

cbmc/src/pointer-analysis/value_set.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,9 @@ void value_sett::assign(
12831283
}
12841284
else
12851285
{
1286+
if(!should_track_value(lhs))
1287+
return;
1288+
12861289
// basic type
12871290
object_mapt values_rhs;
12881291
get_value_set(rhs, values_rhs, ns, is_simplified);

cbmc/src/pointer-analysis/value_set.h

+7
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,13 @@ class value_sett
565565
const codet &code,
566566
const namespacet &ns);
567567

568+
/// Subclass customisation point for limiting which fields are considered
569+
/// interesting:
570+
virtual bool should_track_value(const exprt &e) const
571+
{
572+
return true;
573+
}
574+
568575
private:
569576
/// Subclass customisation point to filter or otherwise alter the value-set
570577
/// returned from get_value_set before it is passed into assign. For example,
-82 Bytes
Binary file not shown.

regression/LVSA/TestBasic/Test.class

-65 Bytes
Binary file not shown.

regression/LVSA/TestBasic/Test.java

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
public class Test {
44
static A output;
5+
static int output_int;
56

67
public class A {
78
public Object instanceObj;
@@ -25,4 +26,8 @@ public void outputs_dynamic_object_with_allocated_field() {
2526
output = new A();
2627
output.instanceObj = new Object();
2728
}
29+
30+
public void only_track_pointers() {
31+
output_int = 42;
32+
}
2833
}

regression/LVSA/TestBasic/test_basic.py

+10
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,13 @@ def test_outputs_dynamic_object_with_allocated_field(tmpdir):
3939

4040
value_set_expectation.check_number_of_values(1)
4141
value_set_expectation.check_contains_dynamic_object()
42+
43+
44+
def test_only_track_pointers(tmpdir):
45+
lvsa_driver = LvsaDriver(tmpdir, folder_name).with_test_function('only_track_pointers')
46+
lvsa_expectation = lvsa_driver.run()
47+
48+
fq_class = lvsa_expectation.fq_class_with_java_prefix
49+
fq_variable_name = fq_class + '.output_int'
50+
matches = [var_state for var_state in lvsa_expectation.state if var_state['id'] == fq_variable_name]
51+
assert(not matches)

src/pointer-analysis/local_value_set.h

+6
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ class local_value_sett : public value_sett
147147
/// \param loc_number: the location number for the dynamic objects we are
148148
/// looking for
149149
void demote_most_recent_dynamic_objects(const unsigned loc_number);
150+
151+
/// Suppress tracking any non-pointer-typed values
152+
bool should_track_value(const exprt &e) const override
153+
{
154+
return e.type().id() == ID_pointer;
155+
}
150156
};
151157

152158
/// Soft cast (i.e. using field accesses rather than a typecast) `expr` to its

0 commit comments

Comments
 (0)