Skip to content

Commit 7789d01

Browse files
smowtonpeterschrammel
authored andcommitted
Add dynamic-object-expr recency
This adds the recency attribute and a simple pretty-printer.
1 parent dcd058a commit 7789d01

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

src/pointer-analysis/value_set.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,16 @@ void value_sett::output(
195195
else
196196
{
197197
result="<"+from_expr(ns, identifier, o)+", ";
198+
if(o.id()==ID_dynamic_object)
199+
{
200+
dynamic_object_exprt::recencyt recency=
201+
to_dynamic_object_expr(o).get_recency();
202+
203+
if(recency==dynamic_object_exprt::recencyt::MOST_RECENT_ALLOCATION)
204+
result+=as_string(ID_most_recent_allocation)+", ";
205+
else if(recency==dynamic_object_exprt::recencyt::ANY_ALLOCATION)
206+
result+=as_string(ID_any_allocation)+", ";
207+
}
198208

199209
if(o_it->second.offset_is_set)
200210
result+=integer2string(o_it->second.offset)+"";

src/util/irep_ids.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ overflow_mult overflow-*
511511
overflow_unary_minus overflow-unary-
512512
object_descriptor
513513
dynamic_object
514+
is_most_recent_allocation
515+
most_recent_allocation
516+
any_allocation
514517
object_size
515518
good_pointer
516519
integer_address

src/util/std_expr.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,8 @@ inline object_descriptor_exprt &to_object_descriptor_expr(exprt &expr)
14901490
class dynamic_object_exprt:public exprt
14911491
{
14921492
public:
1493+
enum recencyt { MOST_RECENT_ALLOCATION, ANY_ALLOCATION, RECENCY_UNSET };
1494+
14931495
dynamic_object_exprt():exprt(ID_dynamic_object)
14941496
{
14951497
operands().resize(2);
@@ -1505,6 +1507,40 @@ class dynamic_object_exprt:public exprt
15051507
op1().id(ID_unknown);
15061508
}
15071509

1510+
explicit dynamic_object_exprt(bool recent):
1511+
exprt(ID_dynamic_object)
1512+
{
1513+
operands().resize(2);
1514+
op0().id(ID_unknown);
1515+
op1().id(ID_unknown);
1516+
set_recency(recent);
1517+
}
1518+
1519+
dynamic_object_exprt(const typet &type, bool recent):
1520+
exprt(ID_dynamic_object, type)
1521+
{
1522+
operands().resize(2);
1523+
op0().id(ID_unknown);
1524+
op1().id(ID_unknown);
1525+
set_recency(recent);
1526+
}
1527+
1528+
recencyt get_recency() const
1529+
{
1530+
if(get(ID_is_most_recent_allocation)==ID_most_recent_allocation)
1531+
return MOST_RECENT_ALLOCATION;
1532+
else if(get(ID_is_most_recent_allocation)==ID_any_allocation)
1533+
return ANY_ALLOCATION;
1534+
else
1535+
return RECENCY_UNSET;
1536+
}
1537+
1538+
void set_recency(bool recent)
1539+
{
1540+
set(ID_is_most_recent_allocation,
1541+
(recent ? ID_most_recent_allocation : ID_any_allocation));
1542+
}
1543+
15081544
exprt &instance()
15091545
{
15101546
return op0();

0 commit comments

Comments
 (0)