Skip to content

Commit 6037785

Browse files
author
owen-jones-diffblue
authored
Merge pull request diffblue#323 from diffblue/owen-jones-diffblue/precise-evs-loop
SEC-198: Do no export precise EVSs when a loop makes them wrong
2 parents edb2eb0 + 230a0c8 commit 6037785

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/pointer-analysis/local_value_set.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,9 @@ void local_value_sett::get_value_set_rec(
301301
bool loop_found=new_ext_set.extend_access_path(
302302
new_entry, external_value_set_typet::PRECISE);
303303

304-
// TODO: handle loops properly
305-
if(!loop_found)
304+
if(loop_found)
305+
precise_evs_curtailed_because_of_loop = true;
306+
else
306307
{
307308
new_ext_set.type()=field_type.subtype();
308309

@@ -605,8 +606,9 @@ void local_value_sett::assign_rec(
605606
bool loop_found=new_ext_set.extend_access_path(
606607
new_entry, external_value_set_typet::PRECISE);
607608

608-
// TODO: handle loops properly
609-
if(!loop_found)
609+
if(loop_found)
610+
precise_evs_curtailed_because_of_loop = true;
611+
else
610612
{
611613
const std::string basename=
612614
new_ext_set.get_access_path_basename(declared_on_type);
@@ -668,4 +670,6 @@ void local_value_sett::make_union_bookkeeping_data_structures(
668670
other.num_reads_of_field_of_external_object;
669671
num_writes_to_field_of_external_object+=
670672
other.num_writes_to_field_of_external_object;
673+
precise_evs_curtailed_because_of_loop &=
674+
other.precise_evs_curtailed_because_of_loop;
671675
}

src/pointer-analysis/local_value_set.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class local_value_sett:public value_sett
2020

2121
mutable unsigned int num_reads_of_field_of_external_object=0;
2222
mutable unsigned int num_writes_to_field_of_external_object=0;
23-
mutable bool no_merges=true;
23+
mutable bool precise_evs_curtailed_because_of_loop=false;
2424

2525
/// Determines whether we should export precise or per_field external value
2626
/// sets in function summaries.
@@ -30,8 +30,10 @@ class local_value_sett:public value_sett
3030
#ifdef DO_NOT_USE_PRECISE_EXTERNAL_VALUE_SETS
3131
return false;
3232
#else
33-
return no_merges && (num_reads_of_field_of_external_object
34-
+num_writes_to_field_of_external_object<=1);
33+
return !precise_evs_curtailed_because_of_loop &&
34+
(num_reads_of_field_of_external_object +
35+
num_writes_to_field_of_external_object <=
36+
1);
3537
#endif
3638
}
3739

0 commit comments

Comments
 (0)