Skip to content

Commit 8fdad56

Browse files
author
Owen Jones
committed
Only expand lhs EVS if rhs is not initializer
This replaces the previous logic involving `lhs_written`, which wasn't doing quite the right thing.
1 parent a4d6b5a commit 8fdad56

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

regression/LVSA/TestPreciseAccessPaths/test_precise_access_paths.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def test_get_list_node(tmpdir):
8686
value_set_expectation.check_contains_external_value_set()
8787

8888

89-
@pytest.mark.xfail(strict=True)
9089
def test_check_using_imprecise_access_paths(tmpdir):
9190
# This test should change when precise access paths have been implemented
9291
lvsa_driver = LvsaDriver(tmpdir, folder_name).with_test_function('check_using_imprecise_access_paths')

src/pointer-analysis/local_value_set_analysis.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,9 @@ void local_value_set_analysist::transform_function_stub(
173173
std::map<exprt, local_value_sett::object_mapt> pre_call_rhs_value_sets;
174174
const std::string per_field_evs_prefix="external_objects";
175175

176-
std::set<std::pair<std::string, std::string> > lhs_written;
177-
178176
for(const auto &assignment : assignments)
179177
{
180178
++nstub_assignments;
181-
const auto &lhs_fieldname=assignment.first;
182179
const auto &rhs_expr=assignment.second;
183180
if(pre_call_rhs_value_sets.count(rhs_expr))
184181
continue;
@@ -191,11 +188,6 @@ void local_value_set_analysist::transform_function_stub(
191188
const std::string &evse_label=
192189
id2string(to_constant_expr(evse.label()).get_value());
193190

194-
// Differentiate external-set entries that only contain
195-
// their initialiser from ones that have been written:
196-
if(!evse.is_initializer())
197-
lhs_written.insert({lhs_fieldname.base_name, lhs_fieldname.field_name});
198-
199191
if(has_prefix(evse_label, per_field_evs_prefix))
200192
{
201193
// This external value set denotes either all pointers stored in a
@@ -275,7 +267,6 @@ void local_value_set_analysist::transform_function_stub(
275267
// Ordinary value set member (not an external value set);
276268
// just add to the RHS map.
277269
valuesets.insert(rhs_map, rhs_expr);
278-
lhs_written.insert({lhs_fieldname.base_name, lhs_fieldname.field_name});
279270
}
280271
}
281272

@@ -295,12 +286,21 @@ void local_value_set_analysist::transform_function_stub(
295286
const auto find_pair=std::make_pair(
296287
lhs_fieldname.base_name,
297288
lhs_fieldname.field_name);
298-
if(lhs_written.count(find_pair))
289+
290+
const bool rhs_is_initializer_per_field_evs =
291+
assignment.second.id() == ID_external_value_set &&
292+
to_external_value_set(assignment.second)
293+
.get_external_value_set_type() ==
294+
external_value_set_typet::PER_FIELD &&
295+
to_external_value_set(assignment.second).is_initializer();
296+
if(!rhs_is_initializer_per_field_evs)
297+
{
299298
get_all_field_value_sets(
300299
lhs_fieldname.field_name,
301300
lhs_fieldname.declared_on_type,
302301
valuesets,
303302
lhs_entries);
303+
}
304304

305305
// Also write to the external value set itself, representing writes
306306
// whose effects are external to this context too:

0 commit comments

Comments
 (0)