Skip to content

Commit 2d8187c

Browse files
authored
Merge pull request diffblue#1 from mariusmc92/security_scanner_support
Updated LVSA data structures for Recency Analysis
2 parents 5026087 + fc5ca14 commit 2d8187c

File tree

3 files changed

+78
-3
lines changed

3 files changed

+78
-3
lines changed

src/pointer-analysis/value_set.cpp

+39-3
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,17 @@ void value_sett::output(
195195
else
196196
{
197197
result="<"+from_expr(ns, identifier, o)+", ";
198-
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+
}
208+
199209
if(o_it->second.offset_is_set)
200210
result+=integer2string(o_it->second.offset)+"";
201211
else
@@ -894,10 +904,23 @@ void value_sett::get_value_set_rec(
894904
{
895905
const dynamic_object_exprt &dynamic_object=
896906
to_dynamic_object_expr(expr);
907+
std::string recency_str="";
908+
909+
if(dynamic_object.get_recency()==
910+
dynamic_object_exprt::recencyt::MOST_RECENT_ALLOCATION)
911+
{
912+
recency_str=as_string(ID_most_recent_allocation);
913+
}
914+
else if(dynamic_object.get_recency()==
915+
dynamic_object_exprt::recencyt::ANY_ALLOCATION)
916+
{
917+
recency_str=as_string(ID_any_allocation);
918+
}
897919

898920
const std::string prefix=
899921
"value_set::dynamic_object"+
900-
dynamic_object.instance().get_string(ID_value);
922+
dynamic_object.instance().get_string(ID_value)+
923+
recency_str;
901924

902925
// first try with suffix
903926
const std::string full_name=prefix+suffix;
@@ -1532,10 +1555,23 @@ void value_sett::assign_rec(
15321555
{
15331556
const dynamic_object_exprt &dynamic_object=
15341557
to_dynamic_object_expr(lhs);
1558+
std::string recency_str="";
1559+
1560+
if(dynamic_object.get_recency()==
1561+
dynamic_object_exprt::recencyt::MOST_RECENT_ALLOCATION)
1562+
{
1563+
recency_str=as_string(ID_most_recent_allocation);
1564+
}
1565+
else if(dynamic_object.get_recency()==
1566+
dynamic_object_exprt::recencyt::ANY_ALLOCATION)
1567+
{
1568+
recency_str=as_string(ID_any_allocation);
1569+
}
15351570

15361571
const std::string name=
15371572
"value_set::dynamic_object"+
1538-
dynamic_object.instance().get_string(ID_value);
1573+
dynamic_object.instance().get_string(ID_value)+
1574+
recency_str;
15391575

15401576
entryt &e=get_entry(entryt(name, suffix), lhs.type(), ns);
15411577

src/util/irep_ids.txt

+3
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

+36
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)