Skip to content

Commit d10989e

Browse files
author
thk123
committed
Constant array reading from top handled correctly
1 parent 67da5aa commit d10989e

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

src/analyses/variable-sensitivity/constant_array_abstract_object.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -225,26 +225,35 @@ abstract_object_pointert constant_array_abstract_objectt::read_index(
225225
const index_exprt &index,
226226
const namespacet &ns) const
227227
{
228-
mp_integer index_value;
229-
if(eval_index(index, env, ns, index_value))
228+
if(is_top())
230229
{
231-
// Here we are assuming it is always in bounds
232-
if(map.find(index_value)==map.cend())
230+
return env.abstract_object_factory(
231+
index.type(), ns, true);
232+
}
233+
else
234+
{
235+
assert(!is_bottom());
236+
mp_integer index_value;
237+
if(eval_index(index, env, ns, index_value))
233238
{
234-
return env.abstract_object_factory(type().subtype(), ns, true, false);
239+
// Here we are assuming it is always in bounds
240+
if(map.find(index_value)==map.cend())
241+
{
242+
return env.abstract_object_factory(type().subtype(), ns, true, false);
243+
}
244+
else
245+
{
246+
return map.find(index_value)->second;
247+
}
235248
}
236249
else
237250
{
238-
return map.find(index_value)->second;
251+
// Reading from somewhere in the array
252+
// TODO(tkiley): merge all the values of the array, we may be able to
253+
// do better than returning top
254+
return env.abstract_object_factory(type().subtype(), ns, true, false);
239255
}
240256
}
241-
else
242-
{
243-
// Reading from somewhere in the array
244-
// TODO(tkiley): merge all the values of the array, we may be able to
245-
// do better than returning top
246-
return env.abstract_object_factory(type().subtype(), ns, true, false);
247-
}
248257
}
249258

250259
/*******************************************************************\

0 commit comments

Comments
 (0)